# qsang793/soict-hackathon-2024 architecture

> Architecture diagram of the GitHub repository qsang793/soict-hackathon-2024, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qsang793/soict-hackathon-2024
- Repository: https://github.com/qsang793/soict-hackathon-2024

## Overview

##### Main Components
- Docker & Deployment: Include the Dockerfile (in the deployment folder), the shell scripts (deploy.sh, Makefile targets, etc.), and the environment setup (.env) for running the containerized app.
- NAFNet Core Module: This is the deep learning component that handles image restoration and super-resolution. Within this component, note submodules such as:
- Data Modules (basicsr/data): Handles different datasets (FFHQ, REDS, Vimeo90K, etc.) and related utilities.
- Model Architectures (basicsr/models/archs): Contains different architecture implementations (NAFNet_arch, NAFSSR_arch, etc.).
- Losses & Metrics: Subdirectories for losses (losses) and evaluation (metrics like PSNR, NIQE, FID).
- Options/Configuration: Training and testing configuration files (YML files under options) that fine-tune experiments.
- Data Preparation Pipeline (src/src_data): Components like image conversion, deblurring, exposure adjustment, object removal (e.g., remove_motorbike.py), and copy-paste augmentation illustrate the “pre-processing” step for preparing input data.
- Inference Pipeline (src/src_infer): Scripts such as infer_pipeline.py and infer_yolo_light.py indicate the integration of real-time processing (possibly object detection with YOLO via src/utils/yolo_utils.py) on the processed imagery.
- Training Pipeline (src/src_train): Contains scripts for training classifiers, vehicle detection modules, and data-detection (with YAML configurations). This is your “model training” section.
- Auxiliary Components:
- “LoLi_IEA” module: Likely an additional image enhancement or analysis tool (with LoLi_IEA.py and colorSpace.py).
- Utilities: Helpers for YOLO, file management, logging, and more.
- Pre-trained Weights: The “weights” directory holds pre-populated configurations that are loaded by NAFNet.

##### Their Relationships and Interactions
- Data Flow: Start with raw data and pre-processing in the “src/src_data” module. Prepared data then feeds into the NAFNet training and inference pipelines.
- Model Training and Inference: The training module (src/src_train) uses data and configuration options from the “NAFNet/options/train” to update model parameters in the core NAFNet component. In parallel, the inference module (src/src_infer) uses either newly trained weights (supported by the “weights” folder) or pre-installed models (set up via “python setup.py develop” in NAFNet) to run predictions.
- YOLO Integration: Indicate the connection between YOLO utilities (in src/utils/yolo_utils.py) and the inference module (e.g., via infer_yolo_light.py), which likely provides object detection for surveillance purposes.
- Docker and Deployment: The container houses the entire pipeline; the Docker image is built using the provided deployment scripts and then runs the inference or training processes inside the container environment.
- External Commands and Data Storage: Show that users (or external systems) interact through command-line operations (Makefile, docker run) and that results (e.g., prediction outputs) are stored and can be extracted (docker cp).

##### Architectural Patterns & Technologies
- Modular Design: The project clearly separates concerns into data preparation, model training/inference, and deployment.
- Configurable Experiments: Use of YAML configuration files under “options” directories suggests that experiments are customizable based on dataset (GoPro, REDS, SIDD, etc.) and model type (NAFNet, NAFSSR).
- Containerization: Docker is leveraged for consistent runtime environments.
- Deep Learning Framework: While not explicit, the setup files (setup.py, pyproject.toml, requirements.txt) likely point to Python-based libraries such as PyTorch or TensorFlow that drive the model implementations.
- Utility & Extensions: The inclusion of scripts for data download, preparation, and even “face_util” or “flow_util” implies additional image processing support.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Docker & Deployment Layer
    subgraph "Docker & Deployment"
        D1["Dockerfile"] 
        D2["Deployment Script"]
        D3["Makefile"]
    end

    %% Data Preparation Pipeline
    subgraph "Data Preparation Pipeline"
        DP["Pre-processing Scripts"]
    end

    %% NAFNet Core Module
    subgraph "NAFNet Core Module"
        subgraph "Data Modules"
            NA1["Data Handling"]
        end
        subgraph "Model Architectures"
            NA2["Architectures"]
        end
        subgraph "Losses & Metrics"
            NA3["Losses"]
            NA4["Metrics"]
        end
        subgraph "Options/Configuration"
            NA5["Configuration Files"]
        end
    end

    %% Pre-trained Weights Storage
    subgraph "Pre-trained Weights"
        W["Weights Storage"]
    end

    %% Training Pipeline
    subgraph "Training Pipeline"
        T["Training Scripts"]
    end

    %% Inference Pipeline
    subgraph "Inference Pipeline"
        I1["Inference Script"]
        I2["YOLO Integration Utility"]
    end

    %% Auxiliary Components
    subgraph "Auxiliary Components"
        A["LoLi_IEA Module"]
    end

    %% Data Flow and Interactions
    D1 -->|"builds"| DP
    D1 -->|"builds"| T
    D1 -->|"builds"| I1
    D2 -->|"deploys"| D1
    D3 -->|"triggers"| D2

    DP -->|"feeds"| T
    DP -->|"feeds"| I1

    T -->|"updates"| NA1
    T -->|"updates"| NA2
    T -->|"updates"| NA3
    T -->|"updates"| NA4
    NA5 -->|"configures"| T
    NA5 -->|"configures"| I1

    I1 -->|"uses"| W
    I1 -->|"calls"| I2

    A ---|"aux_support"| I1

    %% Click Events for Mapped Components
    click D1 "https://github.com/qsang793/soict-hackathon-2024/tree/main/deployment/Dockerfile"
    click D2 "https://github.com/qsang793/soict-hackathon-2024/blob/main/deployment/deploy.sh"
    click D3 "https://github.com/qsang793/soict-hackathon-2024/tree/main/Makefile"
    click NA1 "https://github.com/qsang793/soict-hackathon-2024/tree/main/NAFNet/basicsr/data"
    click NA2 "https://github.com/qsang793/soict-hackathon-2024/tree/main/NAFNet/basicsr/models/archs"
    click NA3 "https://github.com/qsang793/soict-hackathon-2024/tree/main/NAFNet/basicsr/models/losses"
    click NA4 "https://github.com/qsang793/soict-hackathon-2024/tree/main/NAFNet/basicsr/metrics"
    click NA5 "https://github.com/qsang793/soict-hackathon-2024/tree/main/NAFNet/options"
    click W "https://github.com/qsang793/soict-hackathon-2024/tree/main/weights"
    click DP "https://github.com/qsang793/soict-hackathon-2024/tree/main/src/src_data"
    click I1 "https://github.com/qsang793/soict-hackathon-2024/blob/main/src/src_infer/infer_pipeline.py"
    click I2 "https://github.com/qsang793/soict-hackathon-2024/blob/main/src/utils/yolo_utils.py"
    click T "https://github.com/qsang793/soict-hackathon-2024/tree/main/src/src_train"
    click A "https://github.com/qsang793/soict-hackathon-2024/tree/main/src/LoLi_IEA"

    %% Style Definitions
    classDef deployment fill:#cceeff,stroke:#333,stroke-width:2px;
    classDef core fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef weights fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef dataPrep fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef training fill:#e0ccff,stroke:#333,stroke-width:2px;
    classDef inference fill:#ffcce0,stroke:#333,stroke-width:2px;
    classDef auxiliary fill:#dddddd,stroke:#333,stroke-width:2px;

    %% Assign Classes to Nodes
    class D1,D2,D3 deployment;
    class NA1,NA2,NA3,NA4,NA5 core;
    class W weights;
    class DP dataPrep;
    class T training;
    class I1,I2 inference;
    class A auxiliary;
```
