# anubhavparas/image-classification-using-cnn architecture

> Architecture diagram of the GitHub repository anubhavparas/image-classification-using-cnn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anubhavparas/image-classification-using-cnn
- Repository: https://github.com/anubhavparas/image-classification-using-cnn

## Overview

##### Project type and purpose
- This is an image‐classification pipeline built in Python using convolutional neural networks (CNNs).
- Its goal is to ingest a folder of cat/dog images, preprocess them, train a CNN, save model artifacts, and run inference producing evaluation plots and a prediction video.

##### File structure
- Top‐level:
- Code/ – all Python modules and folders for training & preprocessing
- README.md & Report.pdf – project description and academic report
- output/ – generated plots, MP4 prediction video
- Code/:
- constants.py – hyperparameters, filepaths
- data_prep.py – dataset loading, resizing, train/validation split
- model.py – CNN architecture definition (Keras/TensorFlow)
- main.py – orchestrates data prep, model instantiation, training loop, saving weights
- models/ – checkpointed .h5 weights and pickled history
- notebook/gpu_classification.ipynb – exploratory analysis and GPU‐enabled experimentation

##### README
- Describes a pipeline: data ingestion → training (15 epochs, 80/20 split) → evaluation
- Shows performance metrics, accuracy/loss graphs, sample predictions

a. Main components
- Data Store: raw image dataset (external input)
- Data Preparation Module: Code/data_prep.py + constants.py
- Model Definition Module: Code/model.py
- Training Orchestrator: Code/main.py
- Model Artifact Store: Code/models/*.h5 + *.pickle
- Evaluation & Visualization:
– Automated plots (output/*.png)
– Prediction video (output/*.mp4)
- Notebook Interface: Code/notebook/gpu_classification.ipynb for interactive runs
- Documentation: README.md + Report.pdf

b. Relationships & interactions
- Raw images → Data Preparation → formatted tensors
- Tensors + hyperparameters → Model Definition → compiled model
- Training Orchestrator passes data & model → GPU/CPU compute → training loop
- At each checkpoint → save weights to Model Artifact Store
- Post‐training → load weights → run evaluation → generate plots & video in output/
- Notebook can tap into Data Preparation, Model Definition, and Artifact Store for interactive experiments

c. Architectural patterns/design principles
- Pipeline pattern: clear separation of data preparation, model definition, training, and evaluation
- Modularity: each concern isolated in its own file
- Reproducibility: constants.py centralizes hyperparameters, model artifacts are versioned

d. Key technologies & libraries
- Python 3.x
- Keras/TensorFlow (model serialization to .h5)
- pickle (history serialization)
- Jupyter Notebook
- Matplotlib/seaborn (plots)
- FFmpeg or OpenCV (video generation)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Input
    RawImages["Raw Image Dataset"]:::data

    subgraph "Code Layer"
        Constants["constants.py"]:::code
        DataPrep["data_prep.py"]:::code
        ModelDef["model.py"]:::code
        Trainer["main.py"]:::code
    end

    subgraph "Storage Layer"
        ModelStore["Model Artifact Store\n(.h5 weights & .pickle)"]:::artifact
        subgraph "Evaluation & Visualization"
            Plots["Evaluation Plots (PNG)"]:::artifact
            Video["Prediction Video (MP4)"]:::artifact
        end
    end

    subgraph "Presentation Layer"
        Notebook["gpu_classification.ipynb"]:::notebook
        DocReadme["README.md"]:::doc
        DocReport["Report.pdf"]:::doc
    end

    %% Data Flow
    RawImages -->|"image batches"| DataPrep
    Constants --> DataPrep
    DataPrep -->|"tensors"| ModelDef
    ModelDef -->|"compiled model"| Trainer
    DataPrep --> Trainer
    Trainer -->|"save checkpoints"| ModelStore
    Trainer -->|"trained model"| ModelStore
    ModelStore -->|"load weights"| Trainer
    Trainer -->|"metrics & predictions"| Plots
    Trainer -->|"video frames"| Video

    %% Interactive Notebook Paths
    Notebook --> DataPrep
    Notebook --> ModelDef
    Notebook --> ModelStore

    %% Documentation references
    DocReadme -.-> Notebook
    DocReport -.-> Notebook

    %% Click Events
    click Constants "https://github.com/anubhavparas/image-classification-using-cnn/blob/master/Code/constants.py"
    click DataPrep "https://github.com/anubhavparas/image-classification-using-cnn/blob/master/Code/data_prep.py"
    click ModelDef "https://github.com/anubhavparas/image-classification-using-cnn/blob/master/Code/model.py"
    click Trainer "https://github.com/anubhavparas/image-classification-using-cnn/blob/master/Code/main.py"
    click ModelStore "https://github.com/anubhavparas/image-classification-using-cnn/tree/master/Code/models/"
    click Video "https://github.com/anubhavparas/image-classification-using-cnn/blob/master/output/predictions_on_test_folder_data.mp4"
    click Notebook "https://github.com/anubhavparas/image-classification-using-cnn/blob/master/Code/notebook/gpu_classification.ipynb"
    click DocReadme "https://github.com/anubhavparas/image-classification-using-cnn/blob/master/README.md"
    click DocReport "https://github.com/anubhavparas/image-classification-using-cnn/blob/master/Report.pdf"

    %% Styles
    classDef code fill:#D0E6FF,stroke:#2B65EC,color:#000;
    classDef data fill:#D5F5E3,stroke:#27AE60,color:#000;
    classDef artifact fill:#FFE5B4,stroke:#E67E22,color:#000;
    classDef notebook fill:#F0D9FF,stroke:#8E44AD,color:#000;
    classDef doc fill:#FADBD8,stroke:#C0392B,color:#000;
```
