# manumathewthomas/imagedenoisinggan architecture

> Architecture diagram of the GitHub repository manumathewthomas/imagedenoisinggan, 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/manumathewthomas/imagedenoisinggan
- Repository: https://github.com/manumathewthomas/imagedenoisinggan

## Overview

##### Project Type and Purpose
- This is a full-stack ML web application centered on a Generative Adversarial Network (GAN) for image denoising.
- It has two main facets:
a. A training pipeline (train.py, test.py) that consumes a dataset, builds and optimizes the GAN, and writes model checkpoints.
b. An inference/demo web server (main.py + templates/static) that loads pretrained checkpoints and serves a browser-based UI for denoising images in real time.

##### File Structure Analysis
- Top-level scripts:
- train.py – training loop, loss functions, checkpoint saving
- test.py – evaluation on held-out data
- main.py – launches a web server (likely Flask) on port 8888 for inference
- model.py – defines generator / discriminator architectures
- conv_helper.py, utils.py, libs/utils.py, libs/vgg16.py – shared utilities, feature‐loss extraction
- Frontend:
- templates/index.html – Jinja2 template for the UI
- static/css, static/js, static/fonts – Bootstrap, custom styling, jQuery
- External resources:
- dataset/ – raw and noisy images for training
- Checkpoints/ – serialized TensorFlow model weights
- Configuration & dependencies: Python 3.5, TensorFlow v1.x, PIL

##### Relationships & Data Flows
- Training Path: Dataset → Training Script → TensorFlow Graph → Checkpoints
- Inference Path: Browser → HTTP → Web Server → Load Checkpoint → TensorFlow Inference → Return Denoised Image → Browser
- Utility modules (conv_helper.py, libs/) are shared by both training and inference

##### Architectural Patterns & Principles
- MVC-style separation:
- Model layer = model.py + TensorFlow code
- View layer = templates/index.html + static assets
- Controller layer = main.py routing + input handling
- Modular design: helper libraries in libs/ for reusability
- Pipeline separation: distinct training vs. inference workflows

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI" 
        direction TB
        Browser["Browser Client"]:::frontend
        Index["templates/index.html"]:::frontend
        CSS1["4-col-portfolio.css"]:::frontend
        CSS2["bootstrap.css"]:::frontend
        CSS3["style.css"]:::frontend
        JS1["bootstrap.js"]:::frontend
        JS2["jquery.js"]:::frontend
        Fonts["static/fonts/"]:::frontend
    end

    %% Controller Layer
    subgraph "Web Server (Controller)" 
        direction TB
        Server["Flask Server\n(main.py)"]:::backend
    end

    %% ML Model Layer
    subgraph "Model Layer (Core GAN Architectures & Helpers)"
        direction TB
        ModelDef["model.py"]:::ml
        ConvHelper["conv_helper.py"]:::ml
        Utils["utils.py"]:::ml
        LibUtils["libs/utils.py"]:::ml
        VGG16["libs/vgg16.py"]:::ml
    end

    %% Training Pipeline
    subgraph "Training Pipeline" 
        direction TB
        Train["train.py"]:::ml
        Test["test.py"]:::ml
    end

    %% Storage
    subgraph "Storage" 
        direction TB
        Dataset["dataset/"]:::storage
        Checkpoints["Checkpoints/"]:::storage
    end

    %% External Libraries
    subgraph "External Libraries & Frameworks"
        direction TB
        TF["TensorFlow v1.x"]:::external
        PIL["PIL"]:::external
        FlaskLib["Flask"]:::external
        BootstrapLib["Bootstrap"]:::external
        JQueryLib["jQuery"]:::external
    end

    %% Data Flows
    Dataset -->|"training data"| Train
    Train -->|"builds GAN\n& optimizes"| ModelDef
    ModelDef -->|"checkpoint save"| Checkpoints

    ConvHelper -- shared utils --> Train
    ConvHelper -- shared utils --> Server
    LibUtils -- shared libs --> Train
    LibUtils -- shared libs --> Server
    VGG16 -- feature-loss --> Train

    Browser -->|"upload noisy image"| Server
    Server -->|"load checkpoint\n& inference"| ModelDef
    ModelDef -->|"denoised image"| Server
    Server -->|"return image"| Browser

    %% External libs usage
    Train --> TF
    Server --> TF
    Server --> PIL
    Server --> FlaskLib
    Browser --> BootstrapLib
    Browser --> JQueryLib

    %% Click Events
    click Index "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/templates/index.html"
    click CSS1 "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/static/css/4-col-portfolio.css"
    click CSS2 "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/static/css/bootstrap.css"
    click CSS3 "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/static/style.css"
    click JS1 "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/static/js/bootstrap.js"
    click JS2 "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/static/js/jquery.js"
    click Fonts "https://github.com/manumathewthomas/imagedenoisinggan/tree/master/static/fonts/"
    click Server "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/main.py"
    click ModelDef "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/model.py"
    click ConvHelper "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/conv_helper.py"
    click Utils "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/utils.py"
    click LibUtils "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/libs/utils.py"
    click VGG16 "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/libs/vgg16.py"
    click Train "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/train.py"
    click Test "https://github.com/manumathewthomas/imagedenoisinggan/blob/master/test.py"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef ml fill:#FFA500,stroke:#333,stroke-width:1px
    classDef storage fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
