/YOLOV3.Pytorch

yolov3.pytorch 实现目标检测

Primary LanguagePython

PyTorch-YOLOv3

A minimal PyTorch implementation of YOLOv3, with support for training, inference and evaluation. Refer to https://github.com/eriklindernoren/PyTorch-YOLOv3

Installation

install requirements
$ sudo pip3 install -r requirements.txt

Train on Custom Dataset

Custom model

Run the commands below to create a custom model definition, replacing <num-classes> with the number of classes in your dataset.

$ cd config/                                # Navigate to config dir
$ sh create_custom_model.sh <num-classes> # Will create custom model 'yolov3-custom.cfg'

Classes

Add class names to data/custom/classes.names. This file should have one row per class name.

Image Folder

Move the images of your dataset to data/custom/images/. Move the xmls of your labels_voc to data/custom/labels_voc/

$ cd data/custom
$ python pascalVOC2yolov3.py    # you will get some txt_files in labels, train.txt and valid.txt.

Annotation Folder

The dataloader expects that the annotation file corresponding to the image data/custom/images/train.jpg has the path data/custom/labels/train.txt. Each row in the annotation file should define one bounding box, using the syntax label_idx x_center y_center width height. The coordinates should be scaled [0, 1], and the label_idx should be zero-indexed and correspond to the row number of the class name in data/custom/classes.names.

Define Train and Validation Sets

In data/custom/train.txt and data/custom/valid.txt, add paths to images that will be used as train and validation data respectively.

Train

To train on the custom dataset run:

$ python train.py --pretrained_weights weights/darknet53.conv.74
$ python detect.py # you will test some images and the result saved in ./output.

OK! you success!

YOLOv3: An Incremental Improvement

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