# fab16bsb/image_classification architecture

> Architecture diagram of the GitHub repository fab16bsb/image_classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fab16bsb/image_classification
- Repository: https://github.com/fab16bsb/image_classification

## Overview

##### Project Type and Purpose
- This is a **Machine Learning (Deep Learning) Pipeline** for **image classification** using **Convolutional Neural Networks (CNNs)**, built with **Python/Keras**.
- Core use cases:
- Data preparation (scraping, organizing images)
- Model creation & training
- Model loading & inference
- Explainability (feature maps, saliency maps)

##### File Structure
- Top–level directories:
- **code/**: scripts & notebooks for training (`Creer_model.ipynb`, `creer_model.py`) and inference (`Load_model.ipynb`, `load_model.py`)
- **data/**: three dataset subfolders (dragonball, fairytail, pokemon), each with `train/`, `validation/`, `predict/`
- **modele/**: stored model artifacts (architecture JSON, weights `.h5`, `labels.txt`)
- Other files:
- `requirement.txt`: dependency list
- README files, LICENSE

##### Key Insights from the README
- Three datasets, four classes each
- Data augmentation steps using Keras’ ImageDataGenerator
- CNN architecture: convolutional layers → pooling → dense layers
- Explainability modules: feature‐map and saliency‐map generation
- No external web service or UI—everything runs locally via CLI or notebooks

##### Main Components and Their Relationships
a. Data Sources & Storage
- Raw images on local filesystem (`data/<dataset>/{train,validation,predict}`)
- Data augmentation module reads from disk, produces augmented batches
b. Training Pipeline
- **Data Loader & Augmentor** (creer_model.py / Creer_model.ipynb)
- **CNN Trainer** (Keras model definition → compile → fit)
- **Model Export**: save architecture JSON + weights `.h5` + labels.txt → `modele/<dataset>_model/`
c. Inference Pipeline
- **Model Loader** (load_model.py / Load_model.ipynb)
- **Prediction Module**: loads saved model + labels → runs inference on `data/<dataset>/predict` → writes results to `result/`
d. Explainability Module
- Hooks into trained model to extract feature maps & saliency maps → outputs visualization images under `result/`
e. Environment & Dependencies
- Python 3.12, Keras, listed in requirements.txt
- (Optional) GPU accelerator block for model training

##### Architectural Patterns & Design Principles
- **Layered Architecture**: clearly separate data ingestion, training logic, inference logic, and visualization.
- **Modularity**: each dataset (Dragon Ball, Fairy Tail, Pokémon) follows the same pipeline steps—use a parameterized script.
- **Artifact Repository**: local file‐based model registry under `modele/`, versionable via Git.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Storage Layer
    subgraph "Data Storage (Raw Images)"
        direction TB
        DB["dragonball"]:::dataStore
        FT["fairytail"]:::dataStore
        PK["pokemon"]:::dataStore
    end

    %% Data Augmentation Module
    DataAug["Data Augmentation Module"]:::compute

    %% Model Trainer
    Trainer["Model Trainer (CNN)"]:::compute

    %% Model Artifact Store
    subgraph "Model Artifact Store"
        direction TB
        DBM["dragonball_model"]:::artifact
        FTM["fairytail_model"]:::artifact
        PKM["pokemon_model"]:::artifact
    end

    %% Inference Engine
    Inference["Inference Engine"]:::compute

    %% Explainability Engine
    Explain["Explainability Engine"]:::compute

    %% Results Storage
    Results["Results (Predictions & Visualizations)"]:::artifact

    %% Data Flow
    DB -->|reads images| DataAug
    FT -->|reads images| DataAug
    PK -->|reads images| DataAug

    DataAug -->|augmented image batches| Trainer

    Trainer -->|model JSON & weights| DBM
    Trainer -->|model JSON & weights| FTM
    Trainer -->|model JSON & weights| PKM

    DBM -->|loads model| Inference
    FTM -->|loads model| Inference
    PKM -->|loads model| Inference

    Inference -->|predictions| Results

    Trainer -->|feature maps| Explain
    Explain -->|saliency maps| Results

    %% Click Events
    click DB "https://github.com/fab16bsb/image_classification/tree/main/data/dragonball/"
    click FT "https://github.com/fab16bsb/image_classification/tree/main/data/fairytail/"
    click PK "https://github.com/fab16bsb/image_classification/tree/main/data/pokemon/"

    click DataAug "https://github.com/fab16bsb/image_classification/blob/main/code/creer_model.py"
    click Trainer "https://github.com/fab16bsb/image_classification/blob/main/code/Creer_model.ipynb"

    click DBM "https://github.com/fab16bsb/image_classification/blob/main/modele/dragonball_model/dragonball_model.json"
    click FTM "https://github.com/fab16bsb/image_classification/blob/main/modele/fairytail_model/fairytail_model.json"
    click PKM "https://github.com/fab16bsb/image_classification/blob/main/modele/pokemon_model/pokemon_model.json"

    click Inference "https://github.com/fab16bsb/image_classification/blob/main/code/load_model.py"
    click Explain "https://github.com/fab16bsb/image_classification/blob/main/code/load_model.py"

    click Results "https://github.com/fab16bsb/image_classification/tree/main/result/"

    %% Styling
    classDef compute fill:#ADD8E6,stroke:#006699,color:#000
    classDef dataStore fill:#98FB98,stroke:#2E8B57,color:#000
    classDef artifact fill:#FFA500,stroke:#CC5500,color:#000
```
