A computer vision project that uses YOLOv10 (You Only Look Once) to detect bicycles in images and videos. This project includes both pre-trained YOLOv10 models and custom-trained models specifically optimized for bicycle detection.
This project implements bicycle detection using state-of-the-art YOLOv10 object detection models. It can:
- Detect bicycles in single images
- Process multiple images in batch
- Analyze videos for bicycle detection
- Train custom models on bicycle datasets
- Compare performance between pre-trained and custom models
- Image Detection: Detect bicycles in single images with bounding boxes
- Batch Processing: Process multiple images from a folder
- Video Analysis: Detect bicycles in video files with real-time processing
- Custom Training: Train YOLOv10 models from scratch on bicycle datasets
- Model Comparison: Compare pre-trained YOLOv10 vs custom-trained models
- GPU Support: CUDA-enabled for faster inference and training
- Python 3.8+
- PyTorch
- Ultralytics
- CUDA-compatible GPU (recommended for training)
- Clone this repository:
git clone <repository-url>
cd PythonProject
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Linux/Mac
# or
.venv\Scripts\activate # On Windows
- Install required packages:
pip install torch ultralytics
# Using pre-trained YOLOv10
predict_single_yolo("path/to/image.jpg")
# Using custom-trained model
predict_single_my_model("path/to/image.jpg")
# Process all images in a folder
predict(input_folder="datasets/bicycles/test", output_folder="./results")
# Detect bicycles in a video file
detect_video("path/to/video.mp4")
# Train a custom model from scratch
train()
PythonProject/
├── yolo.py # Main script with all functions
├── yolov10n.pt # Pre-trained YOLOv10 weights
├── yolo11n.pt # Alternative YOLOv11 weights
├── datasets/
│ ├── bicycles-2000/ # Custom bicycle dataset
│ │ ├── train/ # Training images
│ │ ├── valid/ # Validation images
│ │ ├── test/ # Test images
│ │ └── data.yaml # Dataset configuration
│ └── bicycles/ # Additional bicycle dataset
├── results/ # Output folder for image processing
├── video_results/ # Output folder for video processing
├── ultralytics/ # Ultralytics framework files
└── .venv/ # Virtual environment
The project uses a custom bicycle dataset with:
- Training set: 2000+ bicycle images
- Validation set: For model evaluation
- Test set: For inference testing
- Classes: 1 (Bicycle)
- Source: Roboflow dataset
- Epochs: 100
- Image Size: 320x320
- Batch Size: 8
- Model: YOLOv10n (nano version)
- Custom Model:
ultralytics/runs/detect/my_custom_model_2000/weights/best.pt
- Pre-trained:
yolov10n.pt
The project includes both pre-trained YOLOv10 models and custom-trained models specifically optimized for bicycle detection. Custom models are trained from scratch on bicycle datasets for improved accuracy in bicycle detection scenarios.
- Minimum: CPU with 8GB RAM
- Recommended: NVIDIA GPU with 8GB+ VRAM
- Storage: 10GB+ free space for datasets and models
- Check GPU availability:
python yolo.py
- Run video detection (default):
# The script runs detect_video("bike.mp4") by default
python yolo.py
- Train custom model:
# Uncomment train() in main section
python yolo.py
The project includes several example images for testing:
bicycle.jpg
- Single bicyclebicycle_wbg.jpg
- Bicycle with backgroundbicycle_with_girl.jpg
- Bicycle with personimg.png
,img_1.png
,img_2.png
- Various test images
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project uses the CC BY 4.0 license for the dataset and is open source.
- Ultralytics for YOLOv10 implementation
- Roboflow for the bicycle dataset
- PyTorch team for the deep learning framework
For questions or issues, please open an issue on the project repository.
Note: This project is designed for research and educational purposes. Ensure you have proper permissions for any images or videos you process.