How lynguyenminh/cs114.m11.vietnam-traffic-sign-detection works
Project type and purpose
• This is a full-stack, ML-powered web application whose goal is “Phát hiện và nhận dạng 50+ biển báo giao thông” (detect and recognize 50+ Vietnamese road signs).
• The top-level “Final_Project/API” folder implements a Flask (or similar Python) REST service with a simple HTML/JS frontend. The “Source code” notebooks show your training/inference experiments (YOLOv4, YOLOv5).
File structure
• Final_Project/API
• app.py – the main HTTP server (Flask)
• detect.py – inference entrypoint (loads model, runs detection)
• export.py – exports a model to a deployable format
• models/ – YOLO model definitions and config (yolov5s.yaml, common.py, yolo.py, tf.py, experimental.py)
• utils/ – helper routines (dataloaders, augmentations, loss, metrics, plotting, etc.)
• data/coco128.yaml – dataset/class definitions
• static/ + templates/ – frontend assets (HTML, CSS, JS) and result display
• Dockerfile, run.sh, test/Dockerfile – containerization and launch scripts
• Source code notebooks are separate and used offline for data collection and model training.
Main components and their relationships
• Browser / User Interface
• index.html + index.js form a simple upload UI.
• On form submission, JavaScript issues an HTTP POST/GET to the API endpoint (e.g. /detect).
• API Server (app.py)
• Receives HTTP requests, routes them to detect.py or export.py.
• Renders templates (output.html) or returns JSON for frontend to consume.
• Inference Engine
• detect.py loads a pre-trained YOLO model (from models/) using torch_utils, common, etc.
• Data & Config
• data/coco128.yaml defines classes and dataset paths.
• yolov5s.yaml (and other model configs) define architecture/hyperparameters.
• Deployment / DevOps
• Dockerfile builds a container image with Python, dependencies (requirements.txt) and your API.
• run.sh (or docker-compose) starts the server.
• test/Dockerfile can be used for CI or staging.
Architectural patterns and design principles
• MVC-like separation:
• Model = your ML code + weights (models/, utils/)
• View = HTML templates (templates/), static assets (static/)
• Controller = app.py routes + detect.py logic
• Modularization: each utility (dataloaders, augmentations, metrics) lives in its own module.
• Containerization ensures environment reproducibility.
Detail
• Every folder (models, utils, data) is represented if it plays a runtime role.
• Optional “Offline Training” path as a separate notebook component that writes model weights used by the inference pipeline.