# we0091234/chinese_license_plate_detection_recognition architecture

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

- Interactive diagram: https://gitdiagram.com/we0091234/chinese_license_plate_detection_recognition
- Repository: https://github.com/we0091234/chinese_license_plate_detection_recognition

## Overview

##### Main Components
- Detection Module:
– Core detection scripts (e.g., detect_plate.py, detect_demo.py)
– Model definitions are stored in the “models” directory (various YOLO variants such as yolov5s, yolov5m, etc.)
– Data configuration and hyperparameter YAML files in the “data” folder (coco.yaml, voc.yaml, hyp configurations, etc.)

- Recognition Module:
– Plate recognition logic within the “plate_recognition” directory (scripts like plateNet.py, plate_rec.py, and merging/splitting utilities)
– This module likely fetches plate regions from the detection module and then applies a dedicated CNN or CRNN-based recognition process.

- Data & Configuration:
– “data” directory holds dataset configurations, training scripts (e.g., train2yolo.py, train.py), and data download scripts (in “data/scripts”).
– “weights” directory contains pre-trained model files that the detection and recognition modules load.

- Inference & Deployment:
– Additional inference scripts (onnx_infer.py, openvino_infer.py) support deploying models using ONNX, TensorRT (see torch2trt folder), and OpenVINO.
– The project also provides deployment scripts and even links to Android/NCNN examples.

- Utilities & Helper Modules:
– “utils” directory includes data loaders, loss functions, metrics, plotting utilities, and modules for integration with external systems (e.g., AWS, Google App Engine).
– “torch2trt” folder offers conversion utilities for TensorRT optimization.

##### Relationships and Interactions
- Data Flow:
– Input images/videos (from the “imgs” folder for demos) are processed by the Detection Module.
– The detected license plate areas or regions of interest are passed to the Recognition Module.
– Processed output (detected and recognized plate numbers) is saved to an “output” or “result” directory.

- Model Training & Tuning:
– Data configuration files (YAMLs within the “data” folder) enable training both detection and recognition networks.
– Training scripts like train.py, ccpt_process.py, and test scripts coordinate training/validation benchmarks.

- Deployment Paths:
– Separate inference pipelines exist for different model formats (pure PyTorch, ONNX, TensorRT, OpenVINO).
– Conversion/inference scripts show how the same core detection-recognition pipeline is repurposed for production deployments.

##### Architectural Patterns and Design Principles
- Modular Design:
– The project separates concerns by having dedicated directories and scripts for detection, recognition, training, inference, and utility functions.

- Configuration-Driven:
– Extensive use of YAML configuration files for datasets, model hyperparameters, and training policies.

- Multi-Deployment Strategy:
– Flexibility is provided by having different inference scripts for various deployment targets (e.g., onnx_infer.py, openvino_infer.py, Torch2TRT tools).

- Extensibility:
– The separation of detection and recognition facilitates independent updates or swaps for each module.

##### Key Technologies and Frameworks
- Python as the primary language.
- PyTorch for model training and inference.
- YOLO-based model architectures for detection.
- Deployment tools: ONNX, TensorRT, OpenVINO for converting and serving the models.
- Supplementary libraries for data augmentation, loss computations, metrics, logging (including wandb_logging).

##### Putting It All Together
- Branch out from that block into at least four high-level modules:
– Input Processing (images, videos)
– Detection Module (and details: model configuration, YOLO variants, data YAMLs)
– Recognition Module (plate recognition scripts, plateNet, plate_rec)
– Utility/Training/Deployment (training scripts, conversion tools, and integration utilities)
- Interconnections, such as configuration flows (YAML files feeding into training and detection modules) and model weight usage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Input Images/Videos"]:::input

    subgraph "Detection Module (YOLO)"
        DS["Detection Scripts"]:::detection
        DS1["detect_plate.py"]:::detection
        DS2["detect_demo.py"]:::detection
        MD["Model Definitions (YOLO Models)"]:::detection
        DC["Data Configuration (YAML)"]:::detection
    end

    subgraph "Recognition Module (Plate Recognition)"
        PR["Plate Recognition Logic"]:::recognition
        PR1["plateNet.py"]:::recognition
        PR2["plate_rec.py"]:::recognition
        PR3["double_plate_split_merge.py"]:::recognition
    end

    O["Output/Results"]:::output

    subgraph "Training/Deployment & Utilities"
        TS["Training Scripts"]:::support
        MW["Pre-trained Weights"]:::support
        IS["Inference Scripts"]:::support
        IS1["onnx_infer.py"]:::support
        IS2["openvino_infer.py"]:::support
        CT["Conversion Tools (TensorRT)"]:::support
        U["Utilities & Helper Modules"]:::support
    end

    %% Data Flow Connections
    A -->|"feeds"| DS
    DS1 --> DS
    DS2 --> DS
    DS -->|"utilizes"| MD
    DS -->|"reads"| DC
    DS -->|"passes_ROI_to"| PR
    PR1 --> PR
    PR2 --> PR
    PR3 --> PR
    PR -->|"produces"| O

    %% Support & Deployment Connections
    DC -->|"config_feeds"| TS
    MW -->|"provides_weights_to"| DS
    MW -->|"provides_weights_to"| PR
    IS1 --> IS
    IS2 --> IS
    IS -->|"supports"| DS
    IS -->|"supports"| PR
    CT -->|"optimizes"| DS
    CT -->|"optimizes"| PR
    U -->|"assists"| DS
    U -->|"assists"| PR

    %% Click Events
    click DS1 "https://github.com/we0091234/chinese_license_plate_detection_recognition/blob/main/detect_plate.py"
    click DS2 "https://github.com/we0091234/chinese_license_plate_detection_recognition/blob/main/detect_demo.py"
    click MD "https://github.com/we0091234/chinese_license_plate_detection_recognition/tree/main/models/"
    click DC "https://github.com/we0091234/chinese_license_plate_detection_recognition/tree/main/data/"
    click PR1 "https://github.com/we0091234/chinese_license_plate_detection_recognition/blob/main/plate_recognition/plateNet.py"
    click PR2 "https://github.com/we0091234/chinese_license_plate_detection_recognition/blob/main/plate_recognition/plate_rec.py"
    click PR3 "https://github.com/we0091234/chinese_license_plate_detection_recognition/blob/main/plate_recognition/double_plate_split_merge.py"
    click TS "https://github.com/we0091234/chinese_license_plate_detection_recognition/tree/main/data/"
    click MW "https://github.com/we0091234/chinese_license_plate_detection_recognition/tree/main/weights/"
    click IS1 "https://github.com/we0091234/chinese_license_plate_detection_recognition/blob/main/onnx_infer.py"
    click IS2 "https://github.com/we0091234/chinese_license_plate_detection_recognition/blob/main/openvino_infer.py"
    click CT "https://github.com/we0091234/chinese_license_plate_detection_recognition/tree/main/torch2trt/"
    click U "https://github.com/we0091234/chinese_license_plate_detection_recognition/tree/main/utils/"

    %% Styles
    classDef input fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef detection fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef recognition fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef support fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef output fill:#e6e6e6,stroke:#333,stroke-width:2px;
```
