这是indexloc提供的服务,不要输入任何密码
Skip to content

🔥 pure tensorflow Implement of YOLOv3 with support to train your own dataset

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.fuck
Notifications You must be signed in to change notification settings

karsil/tensorflow-yolov3

 
 

Repository files navigation

YOLOv3 Implementation with TF1

Part 1. Introduction

Implementation of YOLO v3 object detector in Tensorflow. The full details are in this paper. In this project we cover several segments as follows:

YOLO paper is quick hard to understand, along side that paper. This repo enables you to have a quick understanding of YOLO Algorithmn.

Part 2. Quick start

  1. Clone this file
$ git clone https://github.com/karsil/tensorflow-yolov3.git
  1. You are supposed to install some dependencies before getting out hands with these codes.
$ cd tensorflow-yolov3
$ pip install -r ./docs/requirements.txt
  1. Exporting loaded COCO weights as TF checkpoint(yolov3_coco.ckpt)
$ cd checkpoint
$ wget https://github.com/YunYang1994/tensorflow-yolov3/releases/download/v1.0/yolov3_coco.tar.gz
$ tar -xvf yolov3_coco.tar.gz
$ cd ..
$ python convert_weight.py
$ python freeze_graph.py
  1. Then you will get some .pb files in the root path., and run the demo script
$ python image_demo.py
$ python video_demo.py # if use camera, set video_path = 0

Part 3. Train your own dataset

Two files are required as follows:

xxx/xxx.jpg 18.19,6.32,424.13,421.83,20 323.86,2.65,640.0,421.94,20 
xxx/xxx.jpg 48,240,195,371,11 8,12,352,498,14
# image_path x_min, y_min, x_max, y_max, class_id  x_min, y_min ,..., class_id 
# make sure that x_max < width and y_max < height
person
bicycle
car
...
toothbrush

Then edit your ./core/config.py to make some necessary configurations

__C.YOLO.CLASSES                = "./data/classes/dataset.names"
__C.TRAIN.ANNOT_PATH            = "./data/dataset/train_dataset.txt"
__C.TEST.ANNOT_PATH             = "./data/dataset/test_dataset.txt"

Here are two kinds of training method:

(1) train from scratch:
$ python train.py
$ tensorboard --logdir ./data
(2) train from COCO weights(recommended):
$ cd checkpoint
$ wget https://github.com/YunYang1994/tensorflow-yolov3/releases/download/v1.0/yolov3_coco.tar.gz
$ tar -xvf yolov3_coco.tar.gz
$ cd ..
$ python convert_weight.py --train_from_coco
$ python train.py

how to test and evaluate it ?

$ python evaluate.py
$ cd mAP
$ python main.py -na
(3) Inference with trained model

All scripts inside the root folder beginning with process_ are meant for inference which are currently:

1. process_image.py
2. process_image_folder.py
3. process_video.py
4. process_video_to_images.py

To improve performance during inference, all of those scripts require a frozen graph of the checkpoint. To to this, change the paths in freeze_graph.py like in the following to your own needs:

pb_file = "./yolov3_weights.pb"
ckpt_file = "./checkpoint/yolov3_test_loss=0.8979.ckpt-30"

Afterwards run it:

python freeze_graph.py

Then make sure that the desired process_ script has the correct parameters and the previous freezed graph path is correct:

pb_file         = "./yolov3_weights.pb"
num_classes     = 4
input_size      = 416
score_threshold = 0.3

When calling the script, check for required parameters, e.g.:

python process_image_folder.py ./imagepaths.txt

About

🔥 pure tensorflow Implement of YOLOv3 with support to train your own dataset

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.fuck

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.8%
  • Shell 0.2%