A PyTorch-based object detection framework implementing the YOLOv1 (You Only Look Once) algorithm from scratch, based directly on the original paper.
This project provides a modular solution for training, evaluating, and testing YOLOv1 on the Pascal VOC 2007/2012 dataset, with robust metrics and unit tests for reliability.
- 🖼️ Full support for the Pascal VOC 2007/2012 dataset (CSV splits, images, labels)
- 🧮 YOLOv1 architecture with BatchNorm, implemented from scratch
- 📊 Core metrics: Intersection over Union (IoU), Non-Max Suppression (NMS), mean Average Precision (mAP)
- 🧪 Production-ready unit tests for loss, IoU, and NMS
- 🏗️ Training and evaluation scripts included
- 📦 Clean, modular codebase for easy extension
- Model: PyTorch (YOLOv1)
- Data: Pandas, PIL
- Training: tqdm, torchvision
- Testing: unittest
- Python 3.10+
- pip
- PyTorch
# Clone the repository
git clone https://github.com/yourusername/yolov1-object-detection.git
cd yolov1-object-detection/YOLOV1
# Install dependencies
pip install -r requirements.txt
python train.py
python run_tests.py
All tests are located in the tests/
directory and cover core functionality (IoU, NMS, loss).
YOLOV1/
model.py # YOLOv1 architecture (from scratch)
loss.py # Custom YOLO loss function
dataset.py # Pascal VOC dataset loader
utils.py # Utility functions (IoU, NMS, mAP, etc.)
train.py # Training script
run_tests.py # Test runner
tests/
__init__.py
test_iou.py
test_nms.py
test_loss.py
data/
images/ # (gitignored) Training images
labels/ # (gitignored) Label files
train.csv # (gitignored) Train split
test.csv # (gitignored) Test split
generate_csv.py # Script to generate CSV splits
get_data # Bash script to download and organize VOC data
This repository is focused on model training and evaluation.
For inference, use the trained model and utility functions in utils.py
to process new images and obtain bounding box predictions.
- All images, labels, and CSV files are gitignored for privacy and storage reasons.
- The code is designed to be run on CPU or GPU (GPU recommended for training).
- Unit tests ensure reliability and correctness of core components.
Pull requests and issues are welcome!
Please open an issue for bugs, feature