A concise, from-scratch implementation of YOLOv1 for object detection using PyTorch. This repository contains a minimal dataset, training loop, loss, and utilities to experiment and visualize results.
- Educational implementation of YOLOv1 architecture (
Yolov1inmodel.py) - Custom YOLO loss implemented in
loss.py - Lightweight dataset loader and utilities to compute mAP, NMS, and visualize predictions (
data.py,utils.py) - Example training and evaluation script:
train.py
- Python 3.8+
- PyTorch
- torchvision
- numpy, pillow
- tqdm
Install with pip:
pip install torch torchvision numpy pillow tqdm- Check the images and labels in
archive/imagesandarchive/labels(VOC-style text labels). - Edit hyperparameters in
train.py(e.g.,BATCH_SIZE,EPOCHS,LEARNING_RATE). - Run training:
python train.pyThe script will train the model and print the mAP after each epoch; a checkpoint will be saved if performance is high.
Architecture & Loss
| YOLOv1 Architecture | YOLOv1 Loss Function |
|---|---|
![]() |
![]() |
Prediction Examples
| Example 1 | Example 2 |
|---|---|
![]() |
![]() |
Note: Replace
LOAD_MODEL_FILEintrain.pyto visualize saved checkpoints or setLOAD_MODEL = Falseto train from scratch.
- This project targets clarity and learning rather than production performance.
- Feel free to extend the dataset, add augmentations, and tune the loss/architecture.



