How fatemezamanian/yolov5-fruit-detector works
Main Components
• Data Layer
– Raw datasets (coco, VOC, Argoverse, etc.) under data/
– Data-preprocessing & augmentation (utils/datasets.py, utils/autoanchor.py)
• Model Layer
– Core model definitions (models/yolo.py, models/common.py, models/experimental.py)
– Predefined configs (models/hub/*.yaml)
– Weight files (weights/*.pt)
• Training Pipeline
– train.py (trains YOLO models with hyperparameters in data/hyp*.yaml)
– Logging & metrics (utils/loss.py, utils/metrics.py, utils/plots.py, utils/wandb_logging/)
• Inference & Export
– detect.py (image/video inference)
– export.py (ONNX, Torchscript via models/export.py)
– YoloToONNX.ipynb notebook
• Frontend UI
– Qt form (ui/form.ui) launched by main.py
– main.py handles user input (image/video), calls detect.py/detector.py
• REST API Server
– utils/flask_rest_api/restapi.py with example_request.py
• Deployment & Ops
– AWS helpers (utils/aws/) for S3, EC2 userdata, resume hooks
– Google App Engine config (utils/google_app_engine/)
– hubconf.py (exposes PyTorch Hub interface)
Relationships & Data Flows
Raw data → preprocessing → training → model weights → inference
Weights → export → ONNX/TorchScript
• Control Flow
UI (main.py) → detector.py → model (loaded via hubconf.py) → display results
REST API → detect function → returns JSON/HTTP response
• Deployment Flow
git push → cloud build (GAE Dockerfile) → running REST API service
AWS scripts → provision/auto-scale training or inference endpoints
Architectural Patterns
• Modular ML Pipeline: clear separation of data, training, inference, and export modules
• MVC-style UI: form.ui (view) ↔ main.py/controller ↔ detector/model
• Adapter Pattern: hubconf.py adapts local models to PyTorch Hub API
• Micro-services style: optional REST API layer decoupled from UI
Key Technologies & Frameworks
• Python 3.6+, PyTorch 1.7+
• YAML for configs (data/, models/hub/)
• Flask for REST API
• Qt (PyQt) for desktop UI
• AWS shell scripts, GAE Dockerfiles for deployment
• Weights management via shell scripts in weights/