A computer-vision-powered clothing compliance detection system built with YOLOv8 for real-time dress-code validation.
- Overview
- Features
- Architecture
- Prerequisites
- Installation
- Running the Application
- API Endpoints
- Configuration
- Network Access
- Detection Flow
- Troubleshooting
- Development
- Performance Optimization
- Security Considerations
- Additional Resources
- License
- Contributors
- Contributing
DressGuard is a full-stack system designed to detect clothing items and validate them against predefined compliance rules.
It consists of:
- FastAPI backend
- React (Vite) frontend
- YOLOv8-based object detection engine
Supports real-time detection via:
- Webcam
- Image upload
- Video file
- IP cameras
- Multiple Detection Modes (Image, Webcam, Video, IP Camera)
- Multi-Model Support (Switch between YOLO models dynamically)
- Compliance Checking (Configurable validation rules)
- Distance Checking (Ensures correct user positioning)
- Real-Time Visualization (Bounding boxes and confidence scores)
- Structured Rotating Logs
- RESTful API with OpenAPI documentation
- Modern Responsive UI (React + Vite)
- Performance-Optimized Frame Handling
DressGuard/
├── backend/ (FastAPI + YOLOv8)
│ ├── main.py
│ ├── detector.py
│ ├── config.py
│ └── utils/
│ ├── compliance.py
│ └── logger.py
│
└── frontend/ (React + Vite)
├── src/
│ ├── components/
│ └── utils/
└── public/
- Python 3.8+
- pip
- CUDA 12.x (optional, for GPU acceleration)
- Node.js 16+
- Modern browser
git clone <repository-url>
cd DressGuard
pip install -r requirements.txt
mkdir models
cp .env.example .env
Add your YOLO model files inside the models/ directory.
cd frontend
npm install
cp .env.example .env
cd ..
uvicorn main:app --reload
For network access:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
Backend URLs:
cd frontend
npm run dev
Method Endpoint Description
GET / API information
GET /health Health check
GET /models List available YOLO models
GET /current-model Get active model
POST /detect Detect clothing in image
POST /switch-model Switch YOLO model
COMPLIANT_CLOTHES = {"full sleeve shirt", "pants", "id card"}
NON_COMPLIANT_CLOTHES = {"t-shirt", "shorts"}
COMPLIANCE_RULES = {
"min_confidence": 0.5,
"require_all_compliant": True
}
Ensure .pt files are located in the models/ directory.
Disable GPU in config.py:
ENABLE_GPU = False
- Validate upload file types
- Use environment variables for sensitive information
- Employ HTTPS in production
- Restrict CORS origins
- Consider implementing rate limiting
MIT License
Alston Daniel Mendonca Reevan D Mello
- Fork the repository
- Create a new branch
- Commit your changes
- Open a Pull Request