Spaces:
Running
A newer version of the Gradio SDK is available:
6.5.1
title: AI Queue Management - Time in Zone Tracking
emoji: π―
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 6.4.0
app_file: app.py
pinned: false
license: mit
AI Queue Management System - Time in Zone Tracking
An end-to-end AI-powered queue management solution that combines computer vision for real-time tracking with Large Language Models for business intelligence.
π Features
- Real-time Object Tracking: YOLOv8 detection with ByteTrack tracking
- Time-in-Zone Analytics: Precise measurement of dwell time in defined zones using Roboflow Supervision
- AI-Powered Insights: LLM analysis of performance logs using Qwen-2.5-1.5B-Instruct
- Comprehensive Error Handling: Robust error handling throughout the application with graceful degradation
- Multiple Input Formats: Support for video, image, and YouTube URL processing
- YouTube Integration: Optional support for processing YouTube videos with real-time streaming
- Import Error Handling: Graceful handling of missing dependencies with informative error messages
π Use Cases
- Retail Analytics: Track customer movement and dwell time in product sections
- Bank Branch Efficiency: Monitor counter service times and optimize staffing
- Airport Security: Predict wait times and manage security lane staffing
- Hospital ER: Ensure patients are seen within target wait times
- Smart Parking: Monitor parking bay occupancy and turnover rates
- Safety Monitoring: Alert security if someone enters or lingers in restricted areas
π οΈ Technical Stack
- Detection Model: YOLOv8 (Ultralytics)
- Tracking: ByteTrack (Supervision)
- Time Tracking: Supervision TimeInZone
- LLM: Qwen-2.5-1.5B-Instruct
- Framework: Gradio
π¦ Installation
Local Installation
pip install -r requirements.txt
Running Locally
python app.py
The application will be available at http://localhost:7860
π Deployment on Hugging Face Spaces
Step 1: Create a New Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose:
- SDK: Gradio
- Hardware: CPU Basic (free) or upgrade to GPU if needed
- Visibility: Public or Private
Step 2: Upload Files
Upload the following files to your Space:
app.py- Main application filequeue_monitor.py- Core tracking logicllm_analyzer.py- LLM analysis componentrequirements.txt- Python dependenciesREADME.md- This file
Step 3: Configure Environment (Optional)
The application uses a Hugging Face token for model access. You can configure it in two ways:
Option 1: Environment Variable (Recommended for Spaces)
- Go to Space Settings
- Add a Secret named
HF_TOKEN - Paste your Hugging Face token (get it from Settings)
Option 2: Default Token The application includes a default token for testing. For production, use Option 1.
Step 4: Deploy
The Space will automatically build and deploy. You can monitor the build logs in the Space interface.
π Usage
Video Processing
- Upload a video file (MP4, AVI, MOV)
- Adjust confidence threshold (0.1-1.0)
- Set maximum frames to process
- Click "Process Video"
- View processed frame and zone statistics
YouTube Processing (Optional)
- Enter a YouTube URL in the YouTube Processing tab
- Choose between "Download & Process" (full video) or "Real-time Stream" (single frame)
- Adjust confidence threshold
- View processed results with zone tracking
- Note: Requires
pytubelibrary. Install with:pip install pytube
Image Processing
- Upload an image (JPG, PNG)
- Adjust confidence threshold
- Click "Process Image"
- View annotated image with zone tracking
AI Log Analysis
- Enter queue log data in JSON format (or use sample)
- Click "Generate AI Insights"
- Review AI-generated recommendations
π Log Data Format
The LLM expects logs in the following JSON format:
{
"date": "2026-01-24",
"branch": "SBI Jabalpur",
"avg_wait_time_sec": 420,
"max_wait_time_sec": 980,
"customers_served": 134,
"counter_1_avg_service": 180,
"counter_2_avg_service": 310,
"peak_hour": "12:00-13:00",
"queue_overflow_events": 5
}
π§ Configuration
Default Zone
The application uses a default rectangular zone. You can modify it in app.py:
DEFAULT_ZONE = np.array([[100, 100], [1100, 100], [1100, 600], [100, 600]])
Model Configuration
- YOLO Model: Defaults to
yolov8s.pt(can be changed inQueueMonitor.__init__) - LLM Model: Defaults to
Qwen/Qwen2.5-1.5B-Instruct(can be changed inLogAnalyzer.__init__)
β οΈ Error Handling
The application includes comprehensive error handling for:
- Invalid video/image formats
- Model loading failures
- Zone configuration errors
- JSON parsing errors
- Processing exceptions
- Memory management
- Frame processing errors
π License
MIT License
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π§ Support
For issues and questions, please open an issue on the repository.