# ayushsinghrana15/multi-class-fishimage-classification architecture

> Architecture diagram of the GitHub repository ayushsinghrana15/multi-class-fishimage-classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayushsinghrana15/multi-class-fishimage-classification
- Repository: https://github.com/ayushsinghrana15/multi-class-fishimage-classification

## Overview

##### Project Type and Purpose
- This is an end-to-end machine-learning application with two main phases:
a. Offline training pipeline (data preprocessing, model training, evaluation)
b. Online interactive deployment (Streamlit web app for image upload and inference)
- Purpose: classify images into 11 fish/seafood species using both custom CNN and five transfer-learning models, then let end users query alongside confidence visualizations.

##### File Structure
- Top-level scripts & notebooks:
- Multiclass Fish Image Classification.ipynb (exploratory & proof-of-concept)
- train_models.py (implied; described in README)
- fishclass.py (Streamlit app entry point)
- Model artifacts (.h5) saved at top level: best_model.h5, best_resnet50.h5, etc.
- Dataset hierarchy under images.cv_*: data/{train,val,test}/{class-folders}
- sample_fish_images/: sample inputs for deployment
- requirements.txt & .devcontainer/: dependency management & dev environment
- README.md: architecture & usage summary

##### README
- Confirms use of TensorFlow/Keras for training, scikit-learn/matplotlib/seaborn for evaluation, and Streamlit for deployment.
- Phases: data preprocessing & augmentation → model training (+ fine-tuning) → evaluation (metrics + confusion matrices) → interactive app (upload/select image, top-3 predictions, bar chart, info panels).

##### Diagramming the Architecture
a. Main Components
1. Data Storage
- Raw images on disk (images.cv_…/data)
- sample_fish_images folder
2. Preprocessing & Augmentation Module
- Python scripts/notebooks reading from Data Storage
- Applies resizing, normalization, flips/rotations
3. Model Training & Fine-Tuning Module
- Custom CNN training pipeline
- Transfer-learning pipelines: VGG16, ResNet50, MobileNet, InceptionV3, EfficientNetB0
- Outputs: trained .h5 model artifacts
4. Model Evaluation Module
- Runs test-set predictions
- Computes accuracy, precision, recall, F1, confusion matrix
- Visualization using matplotlib/seaborn
5. Deployment App (Streamlit)
- fishclass.py: loads saved .h5 models
- UI: image upload or sample selection
- Inference engine: preprocess → model.predict → post-process top-3 classes + confidences
- Visualization: confidence bar chart + species info
6. Dev/Runtime Environment
- Python environment with requirements.txt
- Optional Docker/Devcontainer for repeatable builds

b. Relationships & Data Flows
- Data Storage → Preprocessing → Model Training → Model Artifacts
- Model Artifacts → Model Evaluation → Metrics & Plots
- Model Artifacts → Deployment App
- End-User (Browser) ↔ Streamlit App ↔ Inference Engine ↔ Model Artifacts
- Dev/CI (GitHub, Devcontainer) supports all phases

c. Architectural Patterns & Principles
- Layered architecture: clearly separate data layer, processing/training layer, evaluation layer, deployment layer
- Reusable artifacts: .h5 models serve both evaluation and deployment
- Modularity: each ML component (custom vs. transfer learning) is pluggable

d. Key Technologies/Frameworks
- TensorFlow/Keras (modeling)
- NumPy/Pillow (data handling)
- scikit-learn (metrics)
- matplotlib/seaborn (visualizations)
- Streamlit (web UI)
- Docker/Devcontainer (optional containerization)

##### Detailed Capture of Essential Elements
- Fact that multiple models (five pretrained + custom) can be toggled/trained
- Metrics module outputs (confusion matrix charts)
- Sample image directory as optional input to Streamlit
- That fishclass.py both loads models and handles user interactions

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Offline Pipeline"
        DS["Raw Data Storage"]:::data
        DS2["Sample Images"]:::data
        PP["Preprocessing & Augmentation"]:::compute
        TR["Model Training & Fine-Tuning"]:::compute
        subgraph "Model Artifacts"
            BM["best_model.h5"]:::compute
            BV["best_vgg16.h5"]:::compute
            BR["best_resnet50.h5"]:::compute
            BMN["best_mobilenet.h5"]:::compute
            BI["best_inceptionv3.h5"]:::compute
            BE["best_efficientnetb0.h5"]:::compute
        end
        EV["Model Evaluation & Metrics"]:::compute
    end

    subgraph "Online Deployment"
        ST["Streamlit App"]:::serve
        UB["User Browser"]:::serve
    end

    subgraph "Development Environment"
        REQ["requirements.txt"]:::env
        DEV[".devcontainer"]:::env
    end

    DS --> PP --> TR
    TR --> BM
    TR --> BV
    TR --> BR
    TR --> BMN
    TR --> BI
    TR --> BE
    BM --> EV
    BV --> EV
    BR --> EV
    BMN --> EV
    BI --> EV
    BE --> EV
    BM --> ST
    BV --> ST
    BR --> ST
    BMN --> ST
    BI --> ST
    BE --> ST
    DS2 --> ST
    ST --> UB

    REQ --> PP
    REQ --> TR
    REQ --> EV
    REQ --> ST
    DEV --> PP
    DEV --> TR
    DEV --> EV
    DEV --> ST

    click DS "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/tree/main/images.cv_jzk6llhf18tm3k0kyttxz/data"
    click DS2 "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/tree/main/sample_fish_images/"
    click PP "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/Multiclass Fish Image Classification.ipynb"
    click TR "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/Multiclass Fish Image Classification.ipynb"
    click EV "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/Multiclass Fish Image Classification.ipynb"
    click BM "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/best_model.h5"
    click BV "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/best_vgg16.h5"
    click BR "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/best_resnet50.h5"
    click BMN "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/best_mobilenet.h5"
    click BI "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/best_inceptionv3.h5"
    click BE "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/best_efficientnetb0.h5"
    click ST "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/fishclass.py"
    click REQ "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/requirements.txt"
    click DEV "https://github.com/ayushsinghrana15/multi-class-fishimage-classification/blob/main/.devcontainer/devcontainer.json"

    classDef data fill:#E0F7FA,stroke:#00838F,color:#004D40
    classDef compute fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20
    classDef serve fill:#FFF3E0,stroke:#EF6C00,color:#E65100
    classDef env fill:#ECEFF1,stroke:#607D8B,color:#263238
```
