# wufan-tb/autolabelimg architecture

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

- Interactive diagram: https://gitdiagram.com/wufan-tb/autolabelimg
- Repository: https://github.com/wufan-tb/autolabelimg

## Overview

##### Project type and purpose
- This is an open‑source, desktop GUI application for image/video annotation called AutoLabelImg.
- It extends the original labelImg tool by adding:
- Auto‑annotation via a YOLOv5 detector
- Video tracking annotation (OpenCV)
- Auxiliary tools (magnifying lens, data augmentation, search)
- It packages as a standalone Python/PyQt5 app with cross‑platform build scripts.

##### File structure
- Top level
- labelImg.py – the main entry point
- libs/     – reusable PyQt5 UI modules, data‑model classes, file I/O
- pytorch_yolov5/ – cloned YOLOv5 code (models, utils, weights)
- build-tools/ – shell scripts and helpers to package for macOS, Windows, Linux, PyPI
- data/ – sample XML templates and predefined classes
- tests/ – unit tests for I/O, utilities, Qt wrappers
- setup.py, Makefile, requirements.txt – build, deployment, dependencies
- Pattern: a monolithic desktop app structured around MVC‑style separation
- View: PyQt5 widgets in libs (canvas, toolbars, dialogs)
- Model: annotation data structures and file I/O (pascal_voc_io.py, yolo_io.py)
- Controller/Services: labelImg.py orchestrates user actions, ML inference, tracking, augment

##### README for additional insights
- Confirms use of PyQt5, YOLOv5, OpenCV
- Steps to prepare weights and compile the Qt resources
- No external database; annotations are saved to disk in XML formats

##### Essential elements
- Clear component names (e.g., “YOLOv5 Model Loader,” “Canvas Widget”)
- Data flows between GUI, ML engine, file system
- External dependencies (PyQt5, PyTorch, OpenCV)
- Entry point (labelImg.py) and packaging scripts
- Modules under libs/ that implement major functions (auto‑annotation, augment, search)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend UI"
        LI["labelImg.py"]:::ui
        Canvas["Canvas Widget"]:::ui
        ToolBar["ToolBar"]:::ui
        Zoom["Zoom Widget"]:::ui
        Color["Color Dialog"]:::ui
        Combo["ComboBox"]:::ui
        LabelD["Label Dialog"]:::ui
    end

    subgraph "Annotation Data Layer"
        LF["LabelFile"]:::data
        PV["PascalVOC IO"]:::data
        YOIO["YOLO IO"]:::data
        Disk[(File System: XML)]:::data
    end

    subgraph "ML Inference Engine"
        Models["YOLOv5 Model Loader"]:::ml
        UtilsML["YOLOv5 Utils"]:::ml
        Weights["Weights"]:::ml
    end

    subgraph "Video Processing/Tracking"
        Video["Video Tracker & Utils"]:::video
    end

    subgraph "Auxiliary Tools"
        Aug["Data Augmentation"]:::aux
        SB["String Bundle"]:::aux
        Settings["Settings"]:::aux
    end

    subgraph "Build & Deployment"
        BT["build-tools/"]:::build
        Setup["setup.py"]:::build
        Make["Makefile"]:::build
        Req["requirements.txt"]:::build
    end

    LI -->|"load/save XML"| LF
    LI -->|"load/save XML"| PV
    LI -->|"load/save XML"| YOIO
    LF -->|"read/write"| Disk
    PV -->|"read/write"| Disk
    YOIO -->|"read/write"| Disk

    LI -->|"run inference"| Models
    LI -->|"run inference"| UtilsML
    LI -->|"use weights"| Weights

    LI -->|"track frames"| Video

    LI -->|"augment data"| Aug
    LI -->|"search labels"| SB
    LI -->|"search labels"| Settings

    BT -->|"package app"| LI
    Setup -->|"configure build"| BT
    Make -->|"invoke scripts"| BT
    Req -->|"install deps"| LI

    click LI "https://github.com/wufan-tb/autolabelimg/blob/master/labelImg.py"
    click Canvas "https://github.com/wufan-tb/autolabelimg/blob/master/libs/canvas.py"
    click ToolBar "https://github.com/wufan-tb/autolabelimg/blob/master/libs/toolBar.py"
    click Zoom "https://github.com/wufan-tb/autolabelimg/blob/master/libs/zoomWidget.py"
    click Color "https://github.com/wufan-tb/autolabelimg/blob/master/libs/colorDialog.py"
    click Combo "https://github.com/wufan-tb/autolabelimg/blob/master/libs/combobox.py"
    click LabelD "https://github.com/wufan-tb/autolabelimg/blob/master/libs/labelDialog.py"
    click LF "https://github.com/wufan-tb/autolabelimg/blob/master/libs/labelFile.py"
    click PV "https://github.com/wufan-tb/autolabelimg/blob/master/libs/pascal_voc_io.py"
    click YOIO "https://github.com/wufan-tb/autolabelimg/blob/master/libs/yolo_io.py"
    click Models "https://github.com/wufan-tb/autolabelimg/tree/master/pytorch_yolov5/models/"
    click UtilsML "https://github.com/wufan-tb/autolabelimg/tree/master/pytorch_yolov5/utils/"
    click Weights "https://github.com/wufan-tb/autolabelimg/tree/master/pytorch_yolov5/weights/"
    click Video "https://github.com/wufan-tb/autolabelimg/blob/master/libs/utils.py"
    click Aug "https://github.com/wufan-tb/autolabelimg/blob/master/libs/utils.py"
    click SB "https://github.com/wufan-tb/autolabelimg/blob/master/libs/stringBundle.py"
    click Settings "https://github.com/wufan-tb/autolabelimg/blob/master/libs/settings.py"
    click BT "https://github.com/wufan-tb/autolabelimg/tree/master/build-tools/"
    click Setup "https://github.com/wufan-tb/autolabelimg/blob/master/setup.py"
    click Make "https://github.com/wufan-tb/autolabelimg/tree/master/Makefile"
    click Req "https://github.com/wufan-tb/autolabelimg/blob/master/requirements.txt"

    classDef ui fill:#b3cde3,stroke:#03396c,color:#03396c;
    classDef data fill:#c7e9c0,stroke:#006d2c,color:#006d2c;
    classDef ml fill:#fdae6b,stroke:#e6550d,color:#e6550d;
    classDef video fill:#cbc9e2,stroke:#6a51a3,color:#6a51a3;
    classDef aux fill:#fee0d2,stroke:#de2d26,color:#de2d26;
    classDef build fill:#d9d9d9,stroke:#636363,color:#252525;
```
