Spaces:
Build error
Build error
A newer version of the Gradio SDK is available:
6.1.0
metadata
title: AI Video Analysis
emoji: π₯
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.0.0
app_file: gradio_ai_enhanced.py
pinned: false
license: mit
π₯ AI-Enhanced Video Analysis
Real-time object detection from your webcam with AI-powered query capabilities using GPT-4o-mini and vector search.
π Features
- Live Object Detection: YOLOv8 analyzes your webcam feed in real-time
- Color Recognition: Identifies object colors (red, blue, green, etc.)
- AI Queries: Ask questions about what appeared in the video
- Vector Search: Semantic search through video history using ChromaDB
- Frame Chunking: Automatic grouping of video events for efficient storage
π― How to Use
Enter your OpenAI API key in the text box and click "Connect"
- Get a key from: https://platform.openai.com/api-keys
- Alternatively, the Space admin can set it as a repository secret
Click the webcam button to start video streaming
- Allow camera permissions when prompted
- Wait a few seconds for YOLO model to load (first time only)
Watch objects being detected in real-time with bounding boxes and labels
Ask questions about the video:
- "What objects have appeared in the last minute?"
- "When did you see a red object?"
- "How many different objects were detected?"
π§ Technical Stack
- YOLOv8: Real-time object detection
- Gradio WebRTC: Smooth video streaming with Cloudflare TURN servers
- OpenAI GPT-4o-mini: Natural language query understanding
- OpenAI Embeddings: Semantic search capabilities
- ChromaDB: Vector database for storing video events
π° Costs
- Hugging Face Spaces: Free (this Space)
- Cloudflare TURN Servers: Free 10GB/month via Gradio FastRTC
- OpenAI API: Pay-as-you-go
- Embeddings: ~$0.0001 per chunk
- GPT-4o-mini: ~$0.0001 per query
- Typical usage: <$1/month for moderate use
π οΈ Local Development
# Clone the repo
git clone https://github.com/ratandeepbansal/yolo2.git
cd yolo2
# Install dependencies
pip install -r requirements_gradio.txt
# Set up API key
cp .env.example .env
# Edit .env and add your OpenAI API key
# Run the app
python gradio_ai_enhanced.py
π Notes
- First load takes
30-60 seconds to download YOLOv8n model (6MB) - WebRTC works best in Chrome/Edge browsers
- Camera permissions required for webcam access
- HTTPS required (automatically provided by HF Spaces)
π€ Contributing
This is an open-source project. Feel free to:
- Report issues
- Suggest features
- Submit pull requests
π License
MIT License - see LICENSE file for details
Built with β€οΈ using Gradio and YOLOv8