Spaces:
Running
Running
File size: 5,238 Bytes
ad1bda5 1754e30 ad1bda5 1754e30 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
---
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
```bash
pip install -r requirements.txt
```
### Running Locally
```bash
python app.py
```
The application will be available at `http://localhost:7860`
## π Deployment on Hugging Face Spaces
### Step 1: Create a New Space
1. Go to [Hugging Face Spaces](https://huggingface.co/spaces)
2. Click "Create new Space"
3. 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 file
- `queue_monitor.py` - Core tracking logic
- `llm_analyzer.py` - LLM analysis component
- `requirements.txt` - Python dependencies
- `README.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)**
1. Go to Space Settings
2. Add a **Secret** named `HF_TOKEN`
3. Paste your Hugging Face token (get it from [Settings](https://huggingface.co/settings/tokens))
**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
1. Upload a video file (MP4, AVI, MOV)
2. Adjust confidence threshold (0.1-1.0)
3. Set maximum frames to process
4. Click "Process Video"
5. View processed frame and zone statistics
### YouTube Processing (Optional)
1. Enter a YouTube URL in the YouTube Processing tab
2. Choose between "Download & Process" (full video) or "Real-time Stream" (single frame)
3. Adjust confidence threshold
4. View processed results with zone tracking
5. **Note**: Requires `pytube` library. Install with: `pip install pytube`
### Image Processing
1. Upload an image (JPG, PNG)
2. Adjust confidence threshold
3. Click "Process Image"
4. View annotated image with zone tracking
### AI Log Analysis
1. Enter queue log data in JSON format (or use sample)
2. Click "Generate AI Insights"
3. Review AI-generated recommendations
## π Log Data Format
The LLM expects logs in the following JSON format:
```json
{
"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`:
```python
DEFAULT_ZONE = np.array([[100, 100], [1100, 100], [1100, 600], [100, 600]])
```
### Model Configuration
- **YOLO Model**: Defaults to `yolov8s.pt` (can be changed in `QueueMonitor.__init__`)
- **LLM Model**: Defaults to `Qwen/Qwen2.5-1.5B-Instruct` (can be changed in `LogAnalyzer.__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. |