YOLOv4 Tensorflow Save Abandoned

implement yolov4 with pure tensorflow (tf1) and you can training net on your own dataset. YOLOv4的纯tensorflow实现,可训练自己的模型.

Project README

YOLOv4_tensorflow | 中文说明

introductions

  • run the following command.
python val_voc.py
  • if have no error, it's ok

converts yolov4.weights to fitting our code

  • refer to this weights convert file, I'm already converted yolov4.weights to this project.
  • you can download yolov4.weights from baidu cloud Extraction code: wm1j
  • puting yolov4.weights into the "yolo_weights" folder, and run the command.
python convert_weight.py
python test_yolo_weights.py
  • the ckpt weights file wound exits in the 'yolo_weights' folder(exists in the baidu cloud)
  • and you'll see some images like this, it seems perfect

image * image * image *

  • the weights_name.txt contains all layer's name of the network

training on VOC2007 and VOC2012

  • open config.py and modify the voc_root_dir to the root path of your VOC dataset
  • just like this
path_to_voc_root_dir
        voc_dir_ls[0] (VOC_2007)
        |       |Annotations
        |       |JPEGImages
        |       |...
        voc_dir_ls[1] (VOC_2012)
        |        |Annotations
        |        |JPEGImages
        |        |...
        others_folder_name
  • run the command
python train_voc.py
  • put test images into voc_test_pic folder, and run the following command after the model training finished.
python val_voc.py
  • it's the result of our code training(input_size:416*416, batch_size:2, lr:2e-4, optimizer:momentum) for a day(364999 steps), not bad

image * image *

  • all configuration parameters are in the config.py, you can modify them according to your actual situation
  • it's the image of loss value, and seems that the lr is too lower(2e-4), we should set it larger.
python show_loss.py 20 300

image

training on VOC2007 and VOC2012 with tf.data pipline

  • just same with training on VOC2007 and VOC2012 but run training file
train_voc_tf_data.py

training on own dataset

  • On January 5, 2021, the related code of training own dataset was deleted, and if you want to training your own dataset, following src/Data_voc.py and just modify the __init_args function, it will be working great

converts ckpt model to pb model

  • open ckpt2pb.py , and modify 'ckpt_file_dir', 'class_num', 'anchors'. run.
python ckpt2pb.py
  • you will see a pb model named 'model.pb' in 'ckpt_file_dir'
  • if you want to use pb model, you will learn more from 'val_pb.py'
  • run python file
python val_pb.py
  • you will see the detection results with pb model
  • you can download pb model from baidu cloud Extraction code: wm1j

some tips about config.py and training the model

  1. the parameters of width and height in config.py should be 608, but i have not a powerful GPU, that is why i set them as 416
  2. actually, you can replace mish activation with leaky_relu to save GPU memory, and then you can set batch_size from 2 to 4
  3. learning rate do not set too large
  4. when the loss value is Nan, please lower your learning rate.

my device

GPU : 1660ti (ASUS) 6G CPU : i5 9400f mem : 16GB os : ubuntu 18.04 cuda: 10.2 cudnn : 7 python : 3.6.9 tensorflow-gpu:1.14.0 numpy : 1.18.1 opencv-python : 4.1.2.30

Open Source Agenda is not affiliated with "YOLOv4 Tensorflow" Project. README Source: rrddcc/YOLOv4_tensorflow
Stars
212
Open Issues
31
Last Commit
3 years ago

Open Source Agenda Badge

Open Source Agenda Rating