# bhooyas/colorization architecture

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

- Interactive diagram: https://gitdiagram.com/bhooyas/colorization
- Repository: https://github.com/bhooyas/colorization

## Overview

##### Project type and purpose
- This is a machine-learning / computer-vision pipeline focusing on image colorization. It uses a PyTorch implementation of a U-Net architecture.
- The end goal is to download a dataset, preprocess it into subsets, train a U-Net model, and run inference to colorize grayscale images.

##### File structure
- Top-level scripts:
- get_dataset.sh / get_dataset.ps1 – download raw image dataset.
- create_subset.py – preprocess and split raw images into training/validation subsets.
- train.py – execute the training loop, save model checkpoints.
- inference.py – load a trained model and perform colorization on new images.
- Core modules:
- config.py – central configuration (paths, hyperparameters).
- model.py – defines the U-Net architecture.
- utils.py – helper functions (data loaders, image transforms, logging, checkpoint I/O).
- Requirements and metadata:
- requirements.txt – Python dependencies.
- README.md – usage instructions and project overview.

##### README for additional insights
- Confirms PyTorch + U-Net, steps (“clone → install → get_dataset → create_subset → train → inference”).

##### Elements
- Raw Data → Preprocessor
- Preprocessor → Trainer
- Trainer → Checkpoint Store
- Checkpoint Store + Model Definition + Config → Inferencer
- Blue for data pipeline stages
- Green for model & training
- Orange for configuration
- Purple for inference
- Connectors showing which scripts or modules implement each component:
- Preprocessor: create_subset.py + utils.py
- Trainer: train.py + model.py + utils.py
- Inferencer: inference.py + model.py + utils.py
- Config: config.py

##### Final recommendations
- Keep it simple and linear, reflecting the step-by-step nature of the pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Acquisition
    subgraph "Data Acquisition"
        Download["Dataset Downloader\n(get_dataset.sh, get_dataset.ps1)"]:::dataPipeline
    end

    %% Data Preprocessing
    subgraph "Data Preprocessing"
        Preprocessor["Preprocessor\n(create_subset.py, utils.py)"]:::dataPipeline
    end

    %% Model & Training
    subgraph "Model & Training"
        Trainer["Trainer\n(train.py, model.py, utils.py)"]:::modelTraining
        Checkpoints["Checkpoint Store"]:::modelTraining
    end

    %% Inference
    subgraph "Inference"
        Inferencer["Inferencer\n(inference.py, model.py, utils.py)"]:::inference
    end

    %% Configuration Manager
    subgraph "Configuration"
        Config["Config Manager\n(config.py)"]:::config
    end

    %% Meta
    subgraph "Project Metadata"
        Req["Requirements\n(requirements.txt)"]:::external
        Readme["README\n(README.md)"]:::external
    end

    %% Connections
    Download -->|"raw images"| Preprocessor
    Preprocessor -->|"processed images"| Trainer
    Trainer -->|"model checkpoints"| Checkpoints
    Checkpoints -->|"load checkpoint"| Inferencer
    Config -->|"parameters"| Trainer
    Config -->|"parameters"| Inferencer

    %% Click Events
    click Download "https://github.com/bhooyas/colorization/blob/main/get_dataset.sh"
    click Download "https://github.com/bhooyas/colorization/blob/main/get_dataset.ps1"
    click Preprocessor "https://github.com/bhooyas/colorization/blob/main/create_subset.py"
    click Preprocessor "https://github.com/bhooyas/colorization/blob/main/utils.py"
    click Trainer "https://github.com/bhooyas/colorization/blob/main/train.py"
    click Trainer "https://github.com/bhooyas/colorization/blob/main/model.py"
    click Trainer "https://github.com/bhooyas/colorization/blob/main/utils.py"
    click Checkpoints "https://github.com/bhooyas/colorization/blob/main/config.py"
    click Inferencer "https://github.com/bhooyas/colorization/blob/main/inference.py"
    click Inferencer "https://github.com/bhooyas/colorization/blob/main/model.py"
    click Inferencer "https://github.com/bhooyas/colorization/blob/main/utils.py"
    click Config "https://github.com/bhooyas/colorization/blob/main/config.py"
    click Req "https://github.com/bhooyas/colorization/blob/main/requirements.txt"
    click Readme "https://github.com/bhooyas/colorization/blob/main/README.md"

    %% Styles
    classDef dataPipeline fill:#a6cee3,stroke:#333,stroke-width:1px;
    classDef modelTraining fill:#b2df8a,stroke:#333,stroke-width:1px;
    classDef config fill:#fdbf6f,stroke:#333,stroke-width:1px;
    classDef inference fill:#cab2d6,stroke:#333,stroke-width:1px;
    classDef external fill:#dddddd,stroke:#333,stroke-width:1px;
```
