Skip to content

Pytorch implements yolov3.Good performance, easy to use, fast speed.

License

Notifications You must be signed in to change notification settings

Lornatang/YOLOv3-PyTorch

Repository files navigation

YOLOv3-PyTorch

Contents

Introduction

This repository contains an op-for-op PyTorch reimplementation of YOLOv3: An Incremental Improvement.

Getting Started

Requirements

  • Python 3.10+
  • PyTorch 2.0.0+
  • CUDA 11.8+
  • Ubuntu 22.04+

From PyPI

pip install yolov3_pytorch -i https://pypi.org/simple

Local Install

git clone https://github.com/Lornatang/YOLOv3-PyTorch.git
cd YOLOv3-PyTorch
pip install -r requirements.txt
pip install -e .

All pretrained model weights

Inference

# Download pretrained model weights to `./results/pretrained_models`
wget https://github.com/Lornatang/YOLOv3-PyTorch/releases/download/0.1.5/YOLOv3_Tiny-COCO-20231107.pth.tar -O ./results/pretrained_models/YOLOv3_Tiny-COCO-20231107.pth.tar
python ./tools/inference.py ./data/examples/dog.jpg
# Loaded `./results/pretrained_models/YOLOv3_Tiny-COCO-20231107.pth.tar` models weights successfully.
# image 1/1 ./data/examples/dog.jpg: 320x416 1 bicycle, 2 car, 1 dog,
# See ./results/inference/dog.jpg for visualization.

Test

# Download dataset to `./data`
cd ./scripts
bash ./process_voc0712_dataset.sh
cd ..
# Download pretrained model weights to `./results/pretrained_models`
wget https://github.com/Lornatang/YOLOv3-PyTorch/releases/download/0.1.5/YOLOv3_Tiny-VOC-20231107.pth.tar -O ./results/pretrained_models/YOLOv3_Tiny-VOC-20231107.pth.tar
python ./tools/eval.py ./configs/VOC-Detection/yolov3_tiny.yaml

Results

COCO Object Detection

Name Size mAPval
0.5:0.95
FLOPs(G) Parameters(M) Memory(MB) download
yolov3_tiny 416 18.7 5.6 0.71 8.9 model
yolov3_tiny_prn 416 11.1 3.5 0.66 4.9 model
yolov3 416 66.7 66.2 0.88 61.9 model
yolov3_spp 416 66.7 66.5 0.88 63.0 model

VOC Object Detection

Model Size mAPval
0.5:0.95
FLOPs(B) Memory(MB) Parameters(M) download
yolov3_tiny 416 58.8 5.5 0.27 8.7 model
yolov3_tiny_prn 416 47.9 3.5 0.27 4.9 model
yolov3 416 82.9 65.7 0.61 61.6 model
yolov3_spp 416 83.2 66.1 0.88 62.7 model
yolov3_mobilenetv1 416 65.6 6.6 0.69 6.2 model
yolov3_mobilenetv2 416 68.2 3.5 0.49 4.3 model
yolov3_vgg16 416 74.1 122.8 0.74 35.5 model

Train

VOC

# Download dataset to `./data`
cd ./scripts
bash ./process_voc0712_dataset.sh
cd ..
# Download pretrained model weights to `./results/pretrained_models`
wget https://github.com/Lornatang/YOLOv3-PyTorch/releases/download/0.1.5/YOLOv3_Tiny-VOC-20231107.pth.tar -O ./results/pretrained_models/YOLOv3_Tiny-VOC-20231107.pth.tar
# change WEIGHTS_PATH in ./configs/VOC-Detection/yolov3_tiny.yaml
python ./tools/train.py ./configs/VOC-Detection/yolov3_tiny.yaml

COCO

# COCO2014
# Download dataset to `./data`
cd ./scripts
bash ./process_coco2014_dataset.sh
cd ..
# Download pretrained model weights to `./results/pretrained_models`
wget https://github.com/Lornatang/YOLOv3-PyTorch/releases/download/0.1.5/YOLOv3_Tiny-COCO-20231107.pth.tar -O ./results/pretrained_models/YOLOv3_Tiny-COCO-20231107.pth.tar
# change WEIGHTS_PATH in ./configs/COCO-Detection/yolov3_tiny.yaml
python ./tools/train.py ./configs/COCO-Detection/yolov3_tiny.yaml

Custom dataset

Details see CustomDataset.md.

Contributing

If you find a bug, create a GitHub issue, or even better, submit a pull request. Similarly, if you have questions, simply post them as GitHub issues.

I look forward to seeing what the community does with these models!

Credit

YOLOv3: An Incremental Improvement

Joseph Redmon, Ali Farhadi

Abstract
We present some updates to YOLO! We made a bunch of little design changes to make it better. We also trained this new network that’s pretty swell. It’s a little bigger than last time but more accurate. It’s still fast though, don’t worry. At 320 × 320 YOLOv3 runs in 22 ms at 28.2 mAP, as accurate as SSD but three times faster. When we look at the old .5 IOU mAP detection metric YOLOv3 is quite good. It achieves 57.9 AP50 in 51 ms on a Titan X, compared to 57.5 AP50 in 198 ms by RetinaNet, similar performance but 3.8× faster. As always, all the code is online at https://pjreddie.com/yolo/.

[Paper] [Project Webpage] [Authors' Implementation]

@article{yolov3,
  title={YOLOv3: An Incremental Improvement},
  author={Redmon, Joseph and Farhadi, Ali},
  journal = {arXiv},
  year={2018}
}