# geragzgm/readpapers architecture

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

- Interactive diagram: https://gitdiagram.com/geragzgm/readpapers
- Repository: https://github.com/geragzgm/readpapers

## Overview

##### Project type and purpose
- This is a Python-based, configuration-driven image classification framework.
- It provides a standardized training and inference pipeline for multiple CNN architectures (AlexNet, GoogLeNet/InceptionV1, ResNet18, VGG16, MobileNet-V1/V2, custom back-prop network).
- Key use cases: training with checkpointing, reproducible experiments, inference, and extension with new models or datasets (including CIFAR-10 and Kaggle).

##### File structure
- Top-level files:
- run_model.py – entrypoint for both training and inference
- build_config.py – reads JSON configs and prepares runtime parameters
- utils.py – miscellaneous helper functions
- Configuration directory:
- _configs/*.json – per-model+dataset hyperparameter files
- Dataset loaders:
- dataset_loaders/base_dataset.py – abstract dataset interface
- dataset_loaders/__init__.py – registry for adding new datasets
- Models hierarchy:
- models/base_models.py – abstract Model class and registry
- models/<ModelName>/src/model.py – concrete model definitions
- logs for HandwrittenDigitRecognition… – tensorboard events under logs/
- Training pipeline:
- train/base_train.py – generic Trainer class (load data, train loop, checkpoint)
- train/src/classification.py – classification-specific Trainer subclass
- train/inference.py – inference routines
- Testing:
- tests/test_registers.py – ensures dataset/model registries work
- No separate “frontend” or “backend”—it’s a library/app with a CLI entrypoint.

##### README for additional insights
- Architecture is config-driven: JSON → build_config → trainer & dataset/model registries
- Quick-start examples show “run_model.py --run_type train/inference --config_file …”
- Emphasis on extensibility and reproducibility, checkpointing under out_dir.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Config & CLI Layer
    subgraph "Config & CLI" 
        direction TB
        ConfigFiles["_configs/*.json"]:::config
        BuildConfig["build_config.py"]:::config
        CLI["run_model.py"]:::cli
    end

    %% Registries & Factories Layer
    subgraph "Registries & Factories"
        direction TB
        DatasetInit["dataset_loaders/__init__.py"]:::registry
        BaseDataset["dataset_loaders/base_dataset.py"]:::registry
        ModelInit["models/__init__.py"]:::registry
        BaseModels["models/base_models.py"]:::registry
    end

    %% Data Pipeline Layer
    subgraph "Data Pipeline"
        direction TB
        Transforms["Image Transforms"]:::data
        DataLoader["DataLoader"]:::data
    end

    %% Model Layer
    subgraph "Model Layer"
        direction TB
        AbstractModel["AbstractModel"]:::model
        AlexNet["AlexNet"]:::model
        GoogLeNet["GoogLeNet/InceptionV1"]:::model
        ResNet["ResNet18"]:::model
        VGG16["VGG16"]:::model
        MobileV1["MobileNet-V1"]:::model
        MobileV2["MobileNet-V2"]:::model
        CustomNet["Custom BackProp Net"]:::model
    end

    %% Training & Inference Engines Layer
    subgraph "Engines"
        direction TB
        TrainerBase["train/base_train.py"]:::engine
        TrainerCls["train/src/classification.py"]:::engine
        Inference["train/inference.py"]:::engine
        Predictions["Predictions"]:::engine
    end

    %% Utilities & Tests
    subgraph "Utilities & Tests"
        direction TB
        Utils["utils.py"]:::util
        Tests["tests/test_registers.py"]:::util
    end

    %% Logs & External Services
    subgraph "External & Logs"
        direction TB
        Logs["TensorBoard Logs"]:::logs
        External["Kaggle API"]:::external
    end

    %% Connections
    CLI -->|"parse args & call"| BuildConfig
    ConfigFiles -->|"load_configs()"| BuildConfig
    BuildConfig -->|"train"| TrainerCls
    BuildConfig -->|"inference"| Inference
    BuildConfig --> Utils

    TrainerCls -->|"use DatasetFactory"| DatasetInit
    TrainerCls --> BaseDataset
    TrainerCls -->|"use ModelFactory"| ModelInit
    TrainerCls --> BaseModels
    TrainerCls --> Transforms
    Transforms --> DataLoader
    DatasetInit --> DataLoader
    DataLoader -->|"train_step()"| TrainerCls
    BaseModels --> AbstractModel
    AbstractModel --> AlexNet
    AbstractModel --> GoogLeNet
    AbstractModel --> ResNet
    AbstractModel --> VGG16
    AbstractModel --> MobileV1
    AbstractModel --> MobileV2
    AbstractModel --> CustomNet
    TrainerCls -->|"save_checkpoint() & write_logs()"| Logs

    Inference -->|"load_saved_model()"| Logs
    Inference --> DataLoader
    Inference --> AbstractModel
    DataLoader --> Inference
    Inference --> Predictions
    Inference --> Utils

    Utils --> TrainerBase
    Utils --> Inference
    Utils --> BuildConfig

    Tests --> DatasetInit
    Tests --> ModelInit

    External --> DatasetInit

    %% Click Events
    click ConfigFiles "https://github.com/geragzgm/readpapers/tree/master/_configs/"
    click BuildConfig "https://github.com/geragzgm/readpapers/blob/master/build_config.py"
    click CLI "https://github.com/geragzgm/readpapers/blob/master/run_model.py"
    click DatasetInit "https://github.com/geragzgm/readpapers/blob/master/dataset_loaders/__init__.py"
    click BaseDataset "https://github.com/geragzgm/readpapers/blob/master/dataset_loaders/base_dataset.py"
    click ModelInit "https://github.com/geragzgm/readpapers/blob/master/models/__init__.py"
    click BaseModels "https://github.com/geragzgm/readpapers/blob/master/models/base_models.py"
    click AlexNet "https://github.com/geragzgm/readpapers/blob/master/models/AlexNet/src/model.py"
    click GoogLeNet "https://github.com/geragzgm/readpapers/blob/master/models/GoogLeNet/src/model.py"
    click ResNet "https://github.com/geragzgm/readpapers/blob/master/models/ResNet/src/model.py"
    click VGG16 "https://github.com/geragzgm/readpapers/blob/master/models/VGG/src/model.py"
    click MobileV1 "https://github.com/geragzgm/readpapers/blob/master/models/MobileNet/v1/src/model.py"
    click MobileV2 "https://github.com/geragzgm/readpapers/blob/master/models/MobileNet/v2/src/model.py"
    click CustomNet "https://github.com/geragzgm/readpapers/blob/master/models/HandwrittenDigitRecognitionWithBackPropNetwork/src/model.py"
    click TrainerBase "https://github.com/geragzgm/readpapers/blob/master/train/base_train.py"
    click TrainerCls "https://github.com/geragzgm/readpapers/blob/master/train/src/classification.py"
    click Inference "https://github.com/geragzgm/readpapers/blob/master/train/inference.py"
    click Utils "https://github.com/geragzgm/readpapers/blob/master/utils.py"
    click Tests "https://github.com/geragzgm/readpapers/blob/master/tests/test_registers.py"
    click Logs "https://github.com/geragzgm/readpapers/tree/master/models/HandwrittenDigitRecognitionWithBackPropNetwork/logs/"

    %% Styles
    classDef config fill:#E3F2FD,stroke:#2196F3,color:#0D47A1;
    classDef cli fill:#BBDEFB,stroke:#1976D2,color:#0D47A1;
    classDef registry fill:#E8F5E9,stroke:#388E3C,color:#1B5E20;
    classDef data fill:#C8E6C9,stroke:#2E7D32,color:#1B5E20;
    classDef model fill:#FFE0B2,stroke:#FB8C00,color:#E65100;
    classDef engine fill:#E1BEE7,stroke:#8E24AA,color:#4A148C;
    classDef util fill:#F5F5F5,stroke:#9E9E9E,color:#424242;
    classDef logs fill:#FFF9C4,stroke:#FBC02D,color:#F57F17;
    classDef external fill:#FFECB3,stroke:#FFA000,color:#E65100;
```
