# hamster-yang/ai_captcha architecture

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

- Interactive diagram: https://gitdiagram.com/hamster-yang/ai_captcha
- Repository: https://github.com/hamster-yang/ai_captcha

## Overview

##### Main Components

A. Data Processing Pipeline
- Input Sources (marked in blue)
- Video Capture System (based on video-related files)
- Static CAPTCHA Images
- Training Data Generation

B. Model Training System (marked in green)
- Multiple Model Versions (evident from model_*.h5 files)
- Training Scripts
- Model Evaluation

C. CAPTCHA Recognition System (marked in orange)
- Image Preprocessing
- Character Segmentation
- Recognition Engine
- Output Processing

**[Data Collection Layer]**

- Video Input ──────┐
- Static Images ────┤
- Generated Data ───┘

- ▼
**[Preprocessing Layer]**

- Image Processing
- Data Augmentation

- ▼
**[Training System]**

- Model Architecture
- Training Pipeline
- Model Versioning

- ▼
**[Recognition System]**

- Image Capture
- Preprocessing
- Character Recognition

- ▼
**[Application Layer]**

- Web Integration

##### Key Elements to Highlight

a. Data Flow Directions:

b. Component Categories:
- Processing Units (rectangles)
- Input/Output Points (rounded rectangles)
- Decision Points (diamonds)

##### Notes for Implementation

- Clear separation between training and inference paths
- Data validation points
- Model checkpoint locations
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef input fill:#a8d1f0,stroke:#333
    classDef processing fill:#90EE90,stroke:#333
    classDef recognition fill:#FFB366,stroke:#333
    classDef storage fill:#D3D3D3,stroke:#333
    classDef web fill:#FFE5CC,stroke:#333
    classDef legacy fill:#E6E6E6,stroke:#333

    %% Data Collection Layer
    subgraph DataCollection
        VI["Video Input"]:::input
        SI["Static Images"]:::input
        GD["Generated Data"]:::input
    end

    %% Preprocessing Layer
    subgraph Preprocessing
        IP["Image Processing"]:::processing
        LP["Label Processing"]:::processing
        DA["Data Augmentation"]:::processing
    end

    %% Training System
    subgraph Training
        MA["Model Architecture"]:::processing
        TP["Training Pipeline"]:::processing
        MV["Model Versions"]:::storage
    end

    %% Recognition System
    subgraph Recognition
        IC["Image Capture"]:::recognition
        PP["Preprocessing"]:::recognition
        CR["Character Recognition"]:::recognition
    end

    %% Application Layer
    subgraph Application
        WI["Web Interface"]:::web
    end

    %% Legacy Components
    subgraph Legacy
        OT["Old Tests"]:::legacy
    end

    %% Connections
    VI --> IP
    SI --> IP
    GD --> IP
    IP --> LP
    LP --> DA
    DA --> TP
    TP --> MV
    MV --> CR
    IC --> PP
    PP --> CR
    CR --> WI

    %% Click Events
    click VI "https://github.com/Hamster-yang/ai_captcha/blob/main/video.py"
    click IP "https://github.com/Hamster-yang/ai_captcha/blob/main/findsquare.py"
    click CR "https://github.com/Hamster-yang/ai_captcha/blob/main/captchaV4_local.py"
    click WI "https://github.com/Hamster-yang/ai_captcha/blob/main/web.py"
    click TP "https://github.com/Hamster-yang/ai_captcha/blob/main/train1.py"
    click MV "https://github.com/Hamster-yang/ai_captcha/blob/main/model_v5_1.h5"
    click OT "https://github.com/Hamster-yang/ai_captcha/tree/main/old_test_v0"
    click LP "https://github.com/Hamster-yang/ai_captcha/tree/main/label"
    click DA "https://github.com/Hamster-yang/ai_captcha/tree/main/AI_CAPTCHA"

    %% Legend
    subgraph Legend
        L1["Input Components"]:::input
        L2["Processing Components"]:::processing
        L3["Recognition Components"]:::recognition
        L4["Storage Components"]:::storage
        L5["Web Components"]:::web
        L6["Legacy Components"]:::legacy
    end
```
