# shanelin0107/ba865_recycling-with-deep-learning architecture

> Architecture diagram of the GitHub repository shanelin0107/ba865_recycling-with-deep-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shanelin0107/ba865_recycling-with-deep-learning
- Repository: https://github.com/shanelin0107/ba865_recycling-with-deep-learning

## Overview

##### Project type and purpose
- This is a machine-learning prototype for waste classification, implemented as a single notebook/script.
- Purpose: train and compare CNN architectures (custom and transfer-learning variants) to classify six waste categories, with the goal of embedding a model in a smart bin edge device.

##### File structure
- Top-level files:
– README.md (project overview, instructions, architecture description)
– final_notebook_ba865_group_project.py (monolithic training, evaluation, and visualization pipeline)
- No separate frontend, backend, or service directories – code lives in one script.

##### Extract architectural insights from README
- Data ingestion: custom image dataset, train/validation/test splits
- Preprocessing: resizing, normalization, augmentations (flip, rotation, zoom)
- Model training:
– Custom CNN pipeline
– Transfer learning via ResNet50
– Transfer learning via MobileNetV2 with CutMix
- Evaluation: accuracy and loss metrics, comparison of model variants
- Future deployment target: edge device (e.g., Raspberry Pi + OpenCV)

##### Main components
a. Data Storage & Ingestion
– Raw image dataset (JPEG, PNG, HEIC)
– Split into train/validation/test buckets
b. Preprocessing & Augmentation
– Resize to 224×224, scale pixels
– Augmentation pipeline (flip, rotation, zoom, CutMix)
c. Model Training & Selection
– Custom CNN branch
– ResNet50 branch (frozen backbone + custom head)
– MobileNetV2 + CutMix branch
d. Model Evaluation
– Compute accuracy, loss, confusion matrix
e. Deployment Target
– Edge inference layer (Raspberry Pi + OpenCV)

##### Relationships and data flow
- Raw dataset → preprocessing/augmentation module
- Preprocessed data → three parallel training modules (custom CNN, ResNet50, MobileNetV2+CutMix)
- Outputs of training modules → centralized evaluation module
- Best model → deployment packaging → edge inference component

##### Architectural patterns and design principles
- Modular pipeline: distinct stages for data prep, training, evaluation
- Parallel experiment branches to compare different architectures
- Reproducibility via notebook/script, environment isolation (Python 3.8+, TensorFlow 2.x, numpy, pandas, scikit-learn, matplotlib)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Storage
    Dataset["Dataset (JPEG, PNG, HEIC)"]:::data

    %% Preprocessing
    Preproc["Preprocessing & Augmentation\n(resize, normalize, flip, rotation, zoom, CutMix)"]:::process

    %% Training Modules
    subgraph "Model Training (Parallel Experiments)"
        direction LR
        CustomCNN["Custom CNN Training"]:::model
        ResNet50["ResNet50 Transfer Learning"]:::model
        MobileNet["MobileNetV2 + CutMix"]:::model
    end

    %% Evaluation and Deployment
    Eval["Model Evaluation\n(accuracy, loss, confusion matrix)"]:::process
    Deploy["Edge Deployment\n(Raspberry Pi + OpenCV)"]:::deploy

    %% Connections
    Dataset -->|"split train/val/test"| Preproc
    Preproc -->|"resize & augment"| CustomCNN
    Preproc -->|"resize & augment"| ResNet50
    Preproc -->|"resize & augment & CutMix"| MobileNet

    CustomCNN -->|"train with RMSprop"| Eval
    ResNet50 -->|"train with RMSprop"| Eval
    MobileNet -->|"train with RMSprop"| Eval

    Eval -->|"select best model"| Deploy

    %% Click Events
    click Preproc "https://github.com/shanelin0107/ba865_recycling-with-deep-learning/blob/main/final_notebook_ba865_group_project.py"
    click CustomCNN "https://github.com/shanelin0107/ba865_recycling-with-deep-learning/blob/main/final_notebook_ba865_group_project.py"
    click ResNet50 "https://github.com/shanelin0107/ba865_recycling-with-deep-learning/blob/main/final_notebook_ba865_group_project.py"
    click MobileNet "https://github.com/shanelin0107/ba865_recycling-with-deep-learning/blob/main/final_notebook_ba865_group_project.py"
    click Eval "https://github.com/shanelin0107/ba865_recycling-with-deep-learning/blob/main/final_notebook_ba865_group_project.py"
    click Deploy "https://github.com/shanelin0107/ba865_recycling-with-deep-learning/blob/main/README.md"

    %% Styles
    classDef data fill:#AED6F1,stroke:#333,stroke-width:1px;
    classDef process fill:#ABEBC6,stroke:#333,stroke-width:1px;
    classDef model fill:#F5B041,stroke:#333,stroke-width:1px;
    classDef deploy fill:#D7BDE2,stroke:#333,stroke-width:1px;
```
