Skip to content

chenggaol/Yolov1-from-scratch

Repository files navigation

Yolov1-from-scratch

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.


Features

  • Educational implementation of YOLOv1 architecture (Yolov1 in model.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

Requirements

  • Python 3.8+
  • PyTorch
  • torchvision
  • numpy, pillow
  • tqdm

Install with pip:

pip install torch torchvision numpy pillow tqdm

Quick start

  1. Check the images and labels in archive/images and archive/labels (VOC-style text labels).
  2. Edit hyperparameters in train.py (e.g., BATCH_SIZE, EPOCHS, LEARNING_RATE).
  3. Run training:
python train.py

The script will train the model and print the mAP after each epoch; a checkpoint will be saved if performance is high.


Visualizations

Architecture & Loss

YOLOv1 Architecture YOLOv1 Loss Function
YOLO architecture YOLO loss

Prediction Examples

Example 1 Example 2
Result 1 Result 2

Note: Replace LOAD_MODEL_FILE in train.py to visualize saved checkpoints or set LOAD_MODEL = False to train from scratch.


Notes

  • This project targets clarity and learning rather than production performance.
  • Feel free to extend the dataset, add augmentations, and tune the loss/architecture.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages