Implementation of YOLO v3 object detector in Tensorflow (TF-Slim)

mystic123, updated 🕥 2022-01-22 15:26:22

tensorflow-yolo-v3

Implementation of YOLO v3 object detector in Tensorflow (TF-Slim). Full tutorial can be found here.

Tested on Python 3.5, Tensorflow 1.11.0 on Ubuntu 16.04.

Todo list:

  • [x] YOLO v3 architecture
  • [x] Basic working demo
  • [x] Weights converter (util for exporting loaded COCO weights as TF checkpoint)
  • [ ] Training pipeline
  • [ ] More backends

How to run the demo:

To run demo type this in the command line:

  1. Download COCO class names file: wget https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names
  2. Download and convert model weights:
    1. Download binary file with desired weights:
      1. Full weights: wget https://pjreddie.com/media/files/yolov3.weights
      2. Tiny weights: wget https://pjreddie.com/media/files/yolov3-tiny.weights
      3. SPP weights: wget https://pjreddie.com/media/files/yolov3-spp.weights
    2. Run python ./convert_weights.py and python ./convert_weights_pb.py
  3. Run python ./demo.py --input_img <path-to-image> --output_img <name-of-output-image> --frozen_model <path-to-frozen-model>

Optional Flags

  1. convert_weights:
    1. --class_names
      1. Path to the class names file
    2. --weights_file
      1. Path to the desired weights file
    3. --data_format
      1. NCHW (gpu only) or NHWC
    4. --tiny
      1. Use yolov3-tiny
    5. --spp
      1. Use yolov3-spp
    6. --ckpt_file
      1. Output checkpoint file
  2. convert_weights_pb.py:
    1. --class_names 1. Path to the class names file
    2. --weights_file
      1. Path to the desired weights file
    3. --data_format
      1. NCHW (gpu only) or NHWC
    4. --tiny
      1. Use yolov3-tiny
    5. --spp
      1. Use yolov3-spp
    6. --output_graph
      1. Location to write the output .pb graph to
  3. demo.py
    1. --class_names
      1. Path to the class names file
    2. --weights_file
      1. Path to the desired weights file
    3. --data_format
      1. NCHW (gpu only) or NHWC
    4. --ckpt_file
      1. Path to the checkpoint file
    5. --frozen_model
      1. Path to the frozen model
    6. --conf_threshold
      1. Desired confidence threshold
    7. --iou_threshold
      1. Desired iou threshold
    8. --gpu_memory_fraction
      1. Fraction of gpu memory to work with

Issues

NotImplementedError: Cannot convert a symbolic Tensor (detector/yolo-v3/meshgrid/Size_1:0) to a numpy array.

opened on 2022-06-27 09:30:31 by Pratyaksha-047

When running this line to convert yolov3 custom model to .pb format: !python convert_weights_pb.py --class_names "classes.txt" --weights_file "yolov3_training_last.weights" --data_format "NHWC"

I am getting the above error. I am running this code in google colab Untitled

Doesn't work with TF 2

opened on 2022-02-16 22:08:18 by lukerbs None

ValueError: cannot reshape array of size 3122147 into shape (1024,512,3,3)

opened on 2021-06-16 06:42:32 by AnnALekhinaE

Hey! I am trying to convert the yolov3 + lstm + spp model in layers, obtained from the alexeyab custom models repository. I run the following command: python convert_weights_pb.py --class_names obj.names --data_format NHWC --weights_file yolo_v3_spp_lstm_final.weights --spp And I get the following error: Снимок экрана от 2021-06-16 13-37-33 The --spp flag does not help in any way in solving this error. How can this problem be solved? I want to prepare a model to work with OpenVINO

yolov4

opened on 2021-03-08 07:48:49 by Viki-researcher

will yolov4 be updated?

Fix a bug in non_max_supression

opened on 2021-01-13 13:31:42 by LucasMahieu

There was a bug in the way the all zero prediction was removed from the image_prediction tensor

This solution is correct, much more simple and clear

Unable to convert model with rectangular shape

opened on 2020-12-16 10:00:24 by kifage

I have a tiny yolo v3 model trained with https://github.com/AlexeyAB/darknet and would like to convert it to Tensorflow and then to Openvino IR format, as it is mentioned on their documentation. My model has an input shape of 352x288x1 and there is no option to set width and height separately with the convert_weights_pb.py script. When still try to run it I get the following error: ValueError: Dimension 1 in both shapes must be equal, but are 18 and 22. Shapes are [?,18,22] and [?,22,18]. for 'detector/yolo-v3-tiny/concat_3' (op: 'ConcatV2') with input shapes: [?,18,22,128], [?,22,18,256], [] and with computed input tensors: input[2] = <3>.

Does anyone know a workaround or is it planned to support rectangular input shapes? Help would be appreciated since I can not change the input shape.

tensorflow yolo tensorflow-yolo detector object-detection yolov3 deep-learning