How kandasamy21/ppe_compliance works
Purpose and Entry Points
This repository exposes a FastAPI service for PPE (Personal Protective Equipment) detection on uploaded images using a custom YOLO model. The runtime entry point is main.py, launched with uvicorn main:app --reload. The public API consists of GET / for health checking and POST /detect for image inference.
HTTP API Layer
main.py owns the FastAPI application and request lifecycle. POST /detect accepts an image file through multipart form upload, invokes model inference, and returns detection results. This API boundary separates clients from local model-loading and image-processing details.
Grounding:
• main.py
• README.md
Model Inference Boundary
The service depends on a custom-trained PyTorch .pt model. Model location is configurable through the PPE_MODEL_PATH environment variable; otherwise the application uses a repository-local default path configured in main.py. The README describes a YOLOv9 artifact location, while the file tree contains a yolov5 directory; this naming/path mismatch should be verified before deployment.
Grounding:
• main.py
• yolov5
• README.md
Detection Flow
Primary control flow is:
1. Client uploads an image to POST /detect.
2. FastAPI receives and validates the multipart file.
3. The server loads or uses the configured YOLO model.
4. Inference identifies PPE-related objects in the image.
5. Detection results are serialized into the HTTP response.
The external boundary is the uploaded image on input and structured detection output on response; model weights are a local deployment dependency rather than an API-managed resource.
Grounding:
• main.py
• README.md
UI Assets
The repository includes static HTML and CSS assets that may support a lightweight browser-facing interface. Their presence does not establish that FastAPI serves them; integration should be confirmed in main.py.
Grounding:
• static/index.html
• static/style.css
• main.py
Runtime and Dependencies
The system runs on Python with FastAPI and Uvicorn. Inference requires the dependencies declared in requirements.txt and a compatible local YOLO/PyTorch model environment. No database, queue, cloud service, or remote inference provider is documented.
Grounding:
• requirements.txt
• main.py
• README.md
Supporting Code
model.py likely provides a local model-related abstraction, but its role cannot be determined from the supplied tree alone. Test.py and Test_1.py appear to be ad hoc validation or experiment entry points rather than documented production interfaces.
Grounding:
• model.py
• Test.py
• Test_1.py
Main entry points: main.py FastAPI App · requirements.txt Python Dependencies · yolov5 YOLO Runtime Source · model.py Model Abstraction
Components 13
Python Service
- FastAPI App · Provides health and image-detection endpoints.
main.py - GET /
main.py - POST /detect · Accepts an uploaded image for inference.
main.py - Python Dependencies · Declares FastAPI, Uvicorn, and inference dependencies.
requirements.txt
Local Inference
- Model Loading · Uses PPE_MODEL_PATH or the local default model path.
main.py - YOLO Inference · Identifies PPE-related objects in the uploaded image.
main.py - Custom .pt Weights · Deployment-provided PyTorch model weights.
- YOLO Runtime Source · Repository-local YOLO directory; artifact naming should be verified.
yolov5 - Model Abstraction · Its production role is not established.
model.py
Other components
- API Client · Uploads PPE images and receives detection output.
- Detection Results
main.py - Browser HTML · May support a lightweight UI; serving integration is unconfirmed.
static/index.html - Browser CSS
static/style.css
Connections 12
- API Client → FastAPI App: HTTP requests
- FastAPI App → GET /: routes
- FastAPI App → POST /detect: routes
- POST /detect → Model Loading: invokes
- Model Loading → Custom .pt Weights: loads
- Model Loading → YOLO Inference: provides model
- YOLO Runtime Source → YOLO Inference: runtime support
- YOLO Inference → Detection Results: serializes detections
- Detection Results → API Client: HTTP response
- Python Dependencies → FastAPI App: provides runtime packages
- Model Abstraction → Model Loading: possible support · Role requires confirmation.
- Browser HTML → Browser CSS: styles