How qunmasj-vision-studio/construction-dataset232 works
Project type and purpose
• This is a Python-based object-detection system built around an improved YOLOv11 model, specialized for detecting 39 classes of construction-site objects (concrete mixers, cranes, personnel, pipelines, etc.).
• It provides three core scripts—train.py (training, mentioned in the README), val.py (validation/metrics), and predict.py (inference)—plus a UI front end (ui.py) to load models, adjust thresholds, and run detection on images, video or live camera.
File structure
• Top-level files:
– README.md / README.docx for project background, data and usage.
– predict.py: inference component (inherits BasePredictor).
– val.py: validation component (inherits BaseValidator).
– ui.py: web/desktop UI to wrap predictor, accept user inputs (confidence, IOU, weight file), display/save results.
• Training (train.py) is described in README but not shown; treat it as a sibling script that outputs model weights (best.pt).
• Key external dependencies: PyTorch, ultralytics, OpenCV (for video/camera), a web framework or GUI toolkit in ui.py.
Extract architecture insights from README
• Modular design following separation of concerns:
– Data layer (datasets of images annotated in YOLOv8 format)
– Training layer (train.py, uses ultralytics engine, various custom blocks like C3k2, C2PSA, RepViT, attention modules)
– Validation layer (val.py) computing mAP, confusion matrix
– Presentation layer (ui.py) exposing a UI that loads weights, sets thresholds, visualizes and exports results.
• Architectural patterns:
– Pipeline pattern for training/validation/inference (preprocess → model → postprocess → results).
– Component modularity: each script encapsulates one responsibility.
– Layered separation between core ML code (ultralytics/PyTorch) and UI code.
Main components & relationships
a. Components:
1) Dataset Storage: raw images + annotations
2) Training Engine (train.py, ultralytics) → produces best.pt
3) Validator (val.py) → consumes model & val data → outputs metrics
4) Predictor (predict.py) → consumes model & data → outputs detection results
5) UI Layer (ui.py) → wraps predictor → user interactions (thresholds, weight loading, export)
6) Model Files: .pt weight files
7) External Libraries: PyTorch, ultralytics, OpenCV, GUI/web framework
b. Interactions:
• Training: Dataset → train.py → YOLOv11 submodules → Weights
• Validation: Weights + Validation split → val.py → Metrics, Confusion Matrix
• Inference: Weights + Input (image/video/camera) → predict.py → Raw detections → post-NMS → Results
Architectural patterns and design principles
• Single Responsibility: each script handles one stage of the ML lifecycle.
• Pipeline Stages: clear preprocess → forward → postprocess → metrics/results.
• Extensibility: new YOLO blocks (C3k2, PSA, RepViT, attention) are encapsulated in custom modules, easily pluggable.
• Layered UI: separates ML logic from presentation, enabling swapping of UI (CLI, web, desktop).
Technologies and frameworks
• Core ML: PyTorch, ultralytics engine (BasePredictor, BaseValidator, Ops, Results)
• Data I/O: OpenCV/video, standard Python file I/O, Excel exporter
• UI: likely Flask, FastAPI or a GUI toolkit (Tkinter, PyQt) in ui.py
• Annotation Format: YOLOv8 text files, COCO style conversions
Suggested component breakdown
• Data Layer:
– “Dataset (YOLOv8 annotations + Images)”
• ML Core Layer:
– “Training Engine (train.py + custom blocks)”
• Inside: C3k2, C2PSA, RepViTBlock, attention modules
– “Validation (val.py → DetMetrics, ConfusionMatrix)”
– “Inference (predict.py → NMS, Results)”
• UI Layer:
– “UI (ui.py)”
• Load weights (.pt)
• Set conf & IOU thresholds
• Input sources: Camera / Image / Video
• Output views: BBox overlay, Export Excel
• External:
– “Frameworks” cluster (PyTorch, ultralytics, OpenCV, Web/GUI)