This repository contains an object detection project using PyTorch, Torchvision, and OpenCV (cv2). The project demonstrates how to implement and fine-tune state-of-the-art detection models for identifying and classifying objects in images.
- Python 3.8+
- PyTorch 1.10+
- Torchvision 0.11+
- OpenCV 4.5+
- NumPy
- Matplotlib
This repository contains a comprehensive object detection pipeline built using PyTorch, Torchvision, and OpenCV. The project focuses on leveraging pre-trained models for object detection, customizing them for specific use cases, and providing an end-to-end solution for training, evaluation, and inference. The repository is designed to be flexible and extendable for various object detection tasks.
- Pre-trained Models: Utilizes state-of-the-art pre-trained models from Torchvision, including Faster R-CNN, SSD, and RetinaNet.
- Custom Training: Offers support for training on custom datasets with configurable hyperparameters.
- Evaluation Metrics: Implements evaluation metrics like mean Average Precision (mAP) for model performance assessment.
- Real-time Inference: Provides scripts for real-time object detection on images, videos, and webcam feeds.
- Modular Design: Structured in a modular way, allowing easy customization and extension of the pipeline.
To get started, clone this repository and install the required dependencies:
git clone https://github.com/pratham-asthana/object-detection.git
cd object-detection
pip install -r requirements.txtTo train the model on your custom dataset, organize your data in the following structure:
dataset/ │ ├── train/ │ ├── images/ │ └── annotations/ ├── val/ │ ├── images/ │ └── annotations/ └── test/ ├── images/ └── annotations/
Ensure that annotations are in a compatible format, such as COCO or Pascal VOC. You can modify the dataset loading script in datasets.py to accommodate different formats.
Customize the config.yaml file to specify your dataset path, model type, learning rate, and other hyperparameters. Then, start the training process with the following command:
python train.py --config config.yamlThe model's performance has been evaluated on various test cases. Below are some sample results showcasing the model's ability to detect and classify objects accurately:
Description: Detected objects in Example 1 with bounding boxes, labels, and confidence scores.
Description: Detected objects in Example 2 demonstrating the model's performance on different object types and scenes.
Sample of a video for the same is uploaded in the repository itself! Any queries are accepted.
We welcome contributions to improve this project. If you have ideas for new features, bug fixes, or improvements, please follow the guidelines below:
-
Fork the Repository: Click the "Fork" button at the top right of this repository page to create a copy of the project under your GitHub account.
-
Create a New Branch:
git checkout -b feature-branch-name