Skip to content

This project is a from-scratch implementation of YOLOv1 in PyTorch, based directly on the original paper. It provides a clean, modular framework for training, evaluating, and testing object detection models on the Pascal VOC 2007/2012 dataset, with robust metrics and unit tests to ensure reliability.

Notifications You must be signed in to change notification settings

AdamNgazzou/YOLOv1-from-Scratch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦾 YOLOv1 Object Detection

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.


🚀 Features

  • 🖼️ 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

🛠️ Tech Stack

  • Model: PyTorch (YOLOv1)
  • Data: Pandas, PIL
  • Training: tqdm, torchvision
  • Testing: unittest

⚙️ Getting Started

✅ Prerequisites

  • Python 3.10+
  • pip
  • PyTorch

🔧 Setup

# 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

🏃‍♂️ Training

python train.py

🧪 Running Tests

python run_tests.py

All tests are located in the tests/ directory and cover core functionality (IoU, NMS, loss).


📂 Project Structure

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

📡 Usage

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.

(i will be adding a checkpoint later. i am still training my model)

📝 Notes

  • 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.

📚 References


🤝 Contributing

Pull requests and issues are welcome!
Please open an issue for bugs, feature

About

This project is a from-scratch implementation of YOLOv1 in PyTorch, based directly on the original paper. It provides a clean, modular framework for training, evaluating, and testing object detection models on the Pascal VOC 2007/2012 dataset, with robust metrics and unit tests to ensure reliability.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published