# tomato-data/a-yo-image-experiments architecture

> Architecture diagram of the GitHub repository tomato-data/a-yo-image-experiments, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tomato-data/a-yo-image-experiments
- Repository: https://github.com/tomato-data/a-yo-image-experiments

## Overview

##### Main Components

a) Data Processing Layer:
- Input Processing Module (handles sprite first frame)
- Image Preprocessing Pipeline
- Data Augmentation System
- Frame Sequence Management

b) Model Architecture Layer (show both parallel architectures):
- Conditional U-Net Pipeline
- Encoder Blocks
- Decoder Blocks
- Skip Connections
- FrameCascadeGAN Pipeline
- Generator Chain
- Discriminator Chain
- Cascade Connection Flow

c) Training Infrastructure:
- Loss Function Module (custom mse_rgb)
- Model Training Pipeline
- Validation System

d) Service Layer:
- API Gateway
- Model Selection Interface
- Frame Generation Service
- Result Processing

**[Input Layer]**
- ↓
**[Preprocessing Layer]**
- ↓
**[Model Selection Layer]**
- ↙     ↘
**[U-Net Path] [CascadeGAN Path]**
- ↘     ↙
**[Post-processing Layer]**
- ↓
**[Output Layer]**

##### Specific Implementation Details

a) Input Section:
- Single frame input handler
- Format validation
- Preprocessing steps

b) Model Architecture Section:
- Split into two parallel paths
- Detail the internal structure of each model
- How they converge for output

c) Service Layer:
- API endpoints
- Model selection logic
- Result delivery system

##### Important Relationships to Highlight

- Data flow between components
- Model selection decision points
- Training vs. inference paths
- Error handling routes
- Validation checkpoints

##### Technical Details

- Input/Output formats
- Key technologies (Python, PyTorch)
- Resource requirements (CUDA support)
- API specifications

##### Implementation Notes

- Experiment tracking from 'initial-experiments'
- Different model variations from notebooks
- Dataset organization from image folders

Remember to include:
- Version control integration
- Testing frameworks
- Deployment paths
- Monitoring systems

This will create a comprehensive system design that accurately represents the AYO-IMAGE project's architecture while maintaining clarity and usefulness for development and documentation purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Data Processing Layer"
        Input["Input Processing"]
        Preprocess["Image Preprocessing"]
        DataAug["Data Augmentation"]
        FrameSeq["Frame Sequence Management"]
    end

    subgraph "Model Architecture Layer"
        subgraph "Conditional U-Net Pipeline"
            UNetEnc["Encoder Blocks"]
            UNetDec["Decoder Blocks"]
            SkipConn["Skip Connections"]
        end
        
        subgraph "FrameCascadeGAN Pipeline"
            Generator["Generator Chain"]
            Discriminator["Discriminator Chain"]
            CascadeFlow["Cascade Connection Flow"]
        end
    end

    subgraph "Training Infrastructure"
        LossFn["Loss Function Module"]
        TrainPipe["Model Training Pipeline"]
        Validation["Validation System"]
        TrainData["Training Data"]
        TestData["Test Data"]
        ModelOut["Model Output"]
    end

    subgraph "Service Layer"
        API["API Gateway"]
        ModelSelect["Model Selection Interface"]
        FrameGen["Frame Generation Service"]
        ResultProc["Result Processing"]
    end

    Input --> Preprocess
    Preprocess --> DataAug
    DataAug --> FrameSeq
    FrameSeq --> ModelSelect

    ModelSelect --> UNetEnc
    ModelSelect --> Generator

    UNetEnc --> UNetDec
    UNetEnc --> SkipConn
    SkipConn --> UNetDec

    Generator --> Discriminator
    Generator --> CascadeFlow
    Discriminator --> CascadeFlow

    UNetDec --> ResultProc
    CascadeFlow --> ResultProc

    TrainData --> TrainPipe
    TestData --> Validation
    TrainPipe --> ModelOut
    LossFn --> TrainPipe
    Validation --> TrainPipe

    ResultProc --> API

    %% Click events for component mapping
    click Input "https://github.com/tomato-data/a-yo-image-experiments/blob/main/initial-experiments/tomato/image separator.ipynb"
    click FrameSeq "https://github.com/tomato-data/a-yo-image-experiments/tree/main/initial-experiments/tomato/image folder"
    click UNetEnc "https://github.com/tomato-data/a-yo-image-experiments/blob/main/initial-experiments/mongoose/conditional_u_net.ipynb"
    click Generator "https://github.com/tomato-data/a-yo-image-experiments/blob/main/initial-experiments/mongoose/1_GAN-생성자와 판별자 모델.ipynb"
    click TrainData "https://github.com/tomato-data/a-yo-image-experiments/tree/main/initial-experiments/tomato/train"
    click TestData "https://github.com/tomato-data/a-yo-image-experiments/tree/main/initial-experiments/tomato/test_frames"
    click ModelOut "https://github.com/tomato-data/a-yo-image-experiments/tree/main/initial-experiments/tomato/output"
    click LossFn "https://github.com/tomato-data/a-yo-image-experiments/blob/main/initial-experiments/tomato/Perceptual Loss (VGG) test.ipynb"

    %% Styling
    classDef processing fill:#B3E0FF,stroke:#333,stroke-width:2px
    classDef model fill:#98FB98,stroke:#333,stroke-width:2px
    classDef service fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#E6E6E6,stroke:#333,stroke-width:2px
    classDef critical fill:#FFB6C1,stroke:#333,stroke-width:2px

    class Input,Preprocess,DataAug,FrameSeq processing
    class UNetEnc,UNetDec,SkipConn,Generator,Discriminator,CascadeFlow model
    class API,ModelSelect,FrameGen,ResultProc service
    class TrainPipe,Validation,TrainData,TestData,ModelOut,LossFn infrastructure
    class ModelSelect critical
```
