• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

基于TensorFlow2.x实现的YOLOv3,支持在自定义数据集上训练,支持保存为TFLite模型。A tensorflow2 implementation of YOLO_V3(Supports training on custom dataset and saving as tflite models.).

YOLOv3_TensorFlow2

A tensorflow2 implementation of YOLO_V3.

Requirements:

  • Python == 3.7
  • TensorFlow == 2.1.0
  • numpy == 1.17.0
  • opencv-python == 4.1.0

Usage

Train on PASCAL VOC 2012

  1. Download the PASCAL VOC 2012 dataset.
  2. Unzip the file and place it in the 'dataset' folder, make sure the directory is like this :
|——dataset
    |——VOCdevkit
        |——VOC2012
            |——Annotations
            |——ImageSets
            |——JPEGImages
            |——SegmentationClass
            |——SegmentationObject
  1. Change the parameters in configuration.py according to the specific situation. Specially, you can set "load_weights_before_training" to True if you would like to restore training from saved weights. You can also set "test_images_during_training" to True, so that the detect results will be show after each epoch.
  2. Run write_voc_to_txt.py to generate data.txt, and then run train_from_scratch.py to start training.

Train on COCO2017

  1. Download the COCO2017 dataset.
  2. Unzip the train2017.zip, annotations_trainval2017.zip and place them in the 'dataset' folder, make sure the directory is like this :
|——dataset
    |——COCO
        |——2017
            |——annotations
            |——train2017
  1. Change the parameters in configuration.py according to the specific situation. Specially, you can set "load_weights_before_training" to True if you would like to restore training from saved weights. You can also set "test_images_during_training" to True, so that the detect results will be show after each epoch.
  2. Run write_coco_to_txt.py to generate data.txt, and then run train_from_scratch.py to start training.

Train on custom dataset

  1. Turn your custom dataset's labels into this form: xxx.jpg 100 200 300 400 1 300 600 500 800 2. The first position is the image name, and the next 5 elements are [xmin, ymin, xmax, ymax, class_id]. If there are multiple boxes, continue to add elements later.
    Considering that the image will be resized before it is entered into the network, the values of xmin, ymin, xmax, and ymax will also change accordingly.
    The example of original picture(from PASCAL VOC 2012 dataset) and resized picture:
    original picture resized picture
    Create a new file data.txt in the data_process directory and write the label of each picture into it, each line is a label for an image.
  2. Change the parameters CATEGORY_NUM, use_dataset, custom_dataset_dir, custom_dataset_classes in configuration.py.
  3. Run write_to_txt.py to generate data.txt, and then run train_from_scratch.py to start training.

Test

  1. Change "test_picture_dir" in configuration.py according to the specific situation.
  2. Run test_on_single_image.py to test single picture.

Convert model to TensorFlow Lite format

  1. Change the "TFLite_model_dir" in configuration.py according to the specific situation.
  2. Run convert_to_tflite.py to generate TensorFlow Lite model.

References

  1. YOLO_v3 paper: https://pjreddie.com/media/files/papers/YOLOv3.pdf or https://arxiv.org/abs/1804.02767
  2. Keras implementation of YOLOV3: https://github.com/qqwweee/keras-yolo3
  3. blog 1, blog 2, blog 3, blog 4, blog 5, blog 6, blog 7
  4. 李金洪. 深度学习之TensorFlow工程化项目实战[M]. 北京: 电子工业出版社, 2019: 343-375
  5. https://zhuanlan.zhihu.com/p/49556105

More Repositories

1

Basic_CNNs_TensorFlow2

A tensorflow2 implementation of some basic CNNs(MobileNetV1/V2/V3, EfficientNet, ResNeXt, InceptionV4, InceptionResNetV1/V2, SENet, SqueezeNet, DenseNet, ShuffleNetV2, ResNet).
Python
515
star
2

TensorFlow2.0_ResNet

A ResNet(ResNet18, ResNet34, ResNet50, ResNet101, ResNet152) implementation using TensorFlow-2.0.
Python
291
star
3

TensorFlow2.0_SSD

A tensorflow_2.0 implementation of SSD (Single Shot MultiBox Detector) .
Python
82
star
4

TensorFlow2.0_Image_Classification

A TensorFlow_2.0 implementation of AlexNet and VGGNet.
Python
39
star
5

MobileNetV3_TensorFlow2

A tensorflow2 implementation of MobileNet-V3.
Python
37
star
6

EfficientNet_TensorFlow2

A tensorflow2 implementation of EfficientNet.
Python
30
star
7

TensorFlow2.0_InceptionV3

A TensorFlow_2.0 implementation of InceptionV3.
Python
30
star
8

CenterNet_TensorFlow2

A tensorflow2.x implementation of CenterNet.
Python
21
star
9

ResNeXt_TensorFlow2

A tensorflow2 implementation of ResNeXt(ResNeXt50, ResNeXt101).
Python
17
star
10

InceptionV4_TensorFlow2

A tensorflow2 implementation of Inception_V4, Inception_ResNet_V1 and Inception_ResNet_V2.
Python
17
star
11

HRNet_Pose_Estimation_TensorFlow2

A tensorflow2 implementation of HRNet for human pose estimation.
Python
13
star
12

EfficientDet_TensorFlow2

A tensorflow2.x implementation of EfficientDet: Scalable and Efficient Object Detection.
Python
11
star
13

ComputerVision.pytorch

计算机视觉
Python
8
star
14

YOLOv4_PyTorch

A PyTorch implementation of YOLOv4.
Python
7
star
15

CRNN_TensorFlow2

A tensorflow2 implementation of CRNN(Convolutional Recurrent Neural Network).
Python
6
star
16

DenseNet_TensorFlow2

A tensorflow2 implementation of DenseNet (including DenseNet121, DenseNet169, DenseNet201, DenseNet269).
Python
6
star
17

DeepLearning.pytorch

深度学习算法
Python
6
star
18

PyTorch_Object_Detection

SkeNetch is a deep learning tool based on PyTorch.
Python
5
star
19

My_Leetcode_Solutions

LeetCode solutions in Python, JavaScript and so on.
Java
1
star
20

Segmentation.pytorch

Python
1
star