This is an interactive web application built with Streamlit that performs real-time AI analysis on images, videos, and live webcam feeds. It integrates multiple state-of-the-art AI models to provide a comprehensive analysis tool.
- Multiple Input Sources:
- Upload an image file (
.jpg,.png). - Upload a video file (
.mp4,.mov,.avi). - Use a live webcam feed.
- Upload an image file (
- Multiple Analysis Models:
- Gemini: A powerful, cloud-based multimodal model from Google for general object, emotion, and activity detection.
- YOLO (v8, v9, v10, v11, v12): State-of-the-art, real-time models that run locally for high performance. Supports multiple tasks:
- Detect: Object Detection
- Segment: Instance Segmentation
- Classify: Image Classification
- Pose: Pose Estimation
- OBB: Oriented Bounding Box Detection
- DeepFace: A facial attribute analysis model that detects faces and analyzes age, gender, and ethnicity.
- Interactive UI:
- Sidebar for easy configuration of models and parameters.
- Real-time display of analysis results, including bounding boxes and JSON data.
- Secure API key management using a
.envfile.
The project includes a convenient runner script that sets up a virtual environment and installs all necessary dependencies.
-
Clone the repository:
git clone <repository-url> cd LiveObjectDetect
-
Run the setup script: This will create a virtual environment in a
.venvdirectory, install the required packages fromrequirements.txt, and start the Streamlit application.python runner.py
-
(Optional) Manual Setup: If you prefer to manage your own environment:
# Create and activate a virtual environment python -m venv .venv source .venv/bin/activate # On Windows, use `.venv\Scripts\activate` # Install dependencies pip install -r requirements.txt # Run the app streamlit run app.py
The application can be run in several modes, providing different user interfaces.
This is the default mode, providing a rich, interactive user interface in your browser.
python runner.pyOnce running, open the provided URL in your web browser.
- Select a Model: Use the dropdown in the sidebar to choose between Gemini, YOLO, and DeepFace.
- Configure the Model:
- For Gemini, enter your API key. You can get one from Google AI Studio. For convenience, you can also create a
.envfile in the project root and addGEMINI_API_KEY="YOUR_API_KEY". - For YOLO, select the Task (Detect, Segment, Classify, Pose, OBB), Version, and Model Size. The appropriate model weights will be downloaded automatically on the first run. Adjust the confidence threshold to control detection sensitivity.
- For DeepFace, no special configuration is required.
- For Gemini, enter your API key. You can get one from Google AI Studio. For convenience, you can also create a
- Select an Input Source: Choose to upload an image, a video, or use the live webcam feed.
- Control Processing: Use the "Start", "Pause", and "Stop" buttons to control the analysis.
A native desktop application built with Python's standard Tkinter GUI toolkit. It offers a more traditional desktop experience compared to the web app and provides full control over all model parameters through the UI.
python runner.py tkinterThe Tkinter app also accepts the same command-line arguments as the standalone app for pre-configuring the model and video source (e.g., python runner.py tkinter -v /path/to/video.mp4).
This mode runs a high-performance window using OpenCV, showing the live feed and the processed feed side-by-side. It is ideal for performance testing as it has minimal UI overhead, with controls available via mouse clicks and keyboard shortcuts.
# Example with YOLOv8n (default) on webcam
python runner.py standalone
# Example with a larger YOLOv10 model on a video file
python runner.py standalone -m YOLO --yolo-version v10 --yolo-size l -v /path/to/your/video.mp4
# Example with YOLO-Pose on webcam using the --yolo-task flag
python runner.py standalone -m YOLO --yolo-task pose --yolo-version v8 --yolo-size s
# Example with DeepFace
python runner.py standalone -m DeepFace
# Example with Gemini (API key must be set in .env or via --api-key)
python runner.py standalone -m GeminiControls:
- Press
pto pause/resume processing. - Press
qto quit the application.
A utility to check if all dependencies (OpenCV, TensorFlow, Ultralytics, etc.) are installed correctly and to test the download and loading of YOLO models. This is useful for troubleshooting setup issues.
python runner.py testThis project is licensed under the Apache License 2.0. See the LICENSE file for details. Please ensure you also comply with the licenses of the models and libraries used (e.g., YOLO, DeepFace, Streamlit).