- Overview
- Features
- Demo
- Installation
- Usage
- Metrics Handling
- Project Structure
- Troubleshooting
- Contributing
- License
- Contact
The YOLO Dog Breed Detection Web App is a powerful and user-friendly tool designed to detect and classify dog breeds within uploaded images using the YOLO (You Only Look Once) object detection framework. Leveraging a pre-trained YOLO model with 120 dog breed classes, this web application provides real-time detection results, including bounding boxes, confidence scores, and comprehensive validation metrics.
- Real-Time Detection: Upload an image and receive instant detection results with bounding boxes and confidence scores.
- Comprehensive Metrics: View both overall and per-class validation metrics to assess model performance.
- User-Friendly Interface: Built with Gradio for an intuitive and interactive user experience.
- Scalable Architecture: Designed to handle a large number of classes efficiently.
- High Accuracy: Utilizes a robust YOLO model trained on a diverse dog breed dataset.
https://universe.roboflow.com/iliescu-mihail-doirn/stanford-dogs-dataset-dog-breed/dataset/1
Screenshot demonstrating the YOLO Dog Breed Detection Web App in action.
- Python 3.10.12 or higher
- CUDA 12.1 (for GPU acceleration) (Optional but recommended for faster inference)
- Git (to clone the repository)
git clone https://github.com/yourusername/your-repo-name.git
cd your-repo-name
It's recommended to use a virtual environment to manage dependencies.
python -m venv venv
-
Windows:
venv\Scripts\activate
-
macOS and Linux:
source venv/bin/activate
Ensure you have pip
updated to the latest version:
pip install --upgrade pip
Install the required Python packages using the provided requirements.txt
:
pip install -r requirements.txt
Note: The torch
package specified in requirements.txt
is built with CUDA 12.1 support. If your system has a different CUDA version or if you're using a CPU-only setup, adjust the PyTorch installation accordingly. Visit the PyTorch Official Installation Page for the appropriate command.
For example, for CPU-only support:
pip install torch==2.5.1 torchvision==0.15.2 torchaudio==2.5.1
Ensure that the best.pt
YOLO model file and the data.yaml
configuration file are present in the project directory.
Execute the Python script to launch the web application:
python app.py
Replace app.py
with the actual filename if different.
-
Access the Web Interface:
After running the script, Gradio will provide a local URL (e.g.,
http://127.0.0.1:7860/
). Open this URL in your web browser. -
Upload an Image:
- Click on the "Upload Image" button.
- Select an image of a dog from your local machine.
-
Run Inference:
- Click the "Run Inference" button.
- The application will process the image, detect dog breeds, and display the results.
-
View Results:
- Annotated Image: Displays the uploaded image with bounding boxes and labels indicating detected breeds and confidence scores.
- Detection Results: A table listing detected classes with their confidence scores and bounding box coordinates.
- Validation Metrics: A table showing overall and per-class metrics to evaluate model performance.
The application displays both overall and per-class metrics to provide a comprehensive view of the model's performance.
-
Overall Metrics:
- Precision: The ratio of true positive detections to the total predicted positives.
- Recall: The ratio of true positive detections to the actual positives.
- mAP50: Mean Average Precision at 50% IoU threshold.
- mAP50-95: Mean Average Precision across IoU thresholds from 50% to 95%.
-
Per-Class Metrics:
- Detailed metrics for each of the 120 dog breed classes, including Precision, Recall, mAP50, and mAP50-95.
Note: Metrics are precomputed and hardcoded into the application for demonstration purposes. For real-world applications, consider implementing dynamic metric computation.
your-repo-name/
│
├── app.py # Main application script
├── best.pt # Pre-trained YOLO model
├── data.yaml # YOLO data configuration file
├── requirements.txt # Python dependencies
├── README.md # Project documentation
-
Model File Not Found:
Ensure that
best.pt
is located in the project directory or update themodel_path
variable inapp.py
to the correct location. -
CUDA Errors:
If you encounter CUDA-related errors, verify that your system has the appropriate CUDA version installed. If not using a GPU, adjust the PyTorch installation to CPU-only as mentioned in the Installation section.
-
Dependencies Issues:
Ensure all dependencies are installed correctly. You can reinstall them using:
pip install --force-reinstall -r requirements.txt
-
Gradio Not Launching:
Check if the required ports are free and not blocked by firewalls. You can specify a different port by modifying the
demo.launch()
line:demo.launch(server_port=7861)
This project is licensed under the MIT License.
For any questions or suggestions, please contact:
- Name: Partha Pratim Ray
- Email: [email protected]
https://huggingface.co/spaces/csepartha/yolo11_stanford_dog_detection Happy Detecting! 🐶🔍