Entry Points for Yolov3

Entry Points for Yolov3


Hi,

I downloaded the Yolov3 Keras implementation from the following repo -> https://github.com/qqwweee/keras-yolo3

Trained a a sample model, saved .h5 file, and then converted to .pb via the following script:

 

import tensorflow as tf
import os
from keras import backend as K
from keras.models import load_model
from keras.layers import Input, Lambda
from tensorflow.python.framework import graph_util
from tensorflow.python.framework import graph_io

from yolo3.model import yolo_head, yolo_body


def _main():

    tf.keras.backend.set_learning_phase(0)

    model = yolo_body(Input(shape=(None, None, 3)), 3, 2)
    model.load_weights('model_data/testModel.h5', {'yolo_head': yolo_head})

    converted_output_node_names = [node.op.name for node in model.outputs]
    print(converted_output_node_names)


    sess = K.get_session()


    constant_graph = graph_util.convert_variables_to_constants(
            sess,
            sess.graph.as_graph_def(),
            converted_output_node_names)


    graph_io.write_graph(constant_graph, '.', 'testModel.pb',
                         as_text=True)

 

Next I tried to convert the model OpenVino Intermediate representation, but I got the following error: 

 

[ ERROR ]  TensorFlow YOLO V3 conversion mechanism was enabled. Entry points "detector/yolo-v3/Reshape, detector/yolo-v3/Reshape_4, detector/yolo-v3/Reshape_8" were provided in the configuration file. Entry points are nodes that feed YOLO Region layers. Node with name detector/yolo-v3/Reshape doesn't exist in the graph. Refer to documentation about converting YOLO models for more information.
Exception occurred during running replacer "TFYOLOV3" (<class 'extensions.front.tf.YOLO.YoloV3RegionAddon'>): TensorFlow YOLO V3 conversion mechanism was enabled. Entry points "detector/yolo-v3/Reshape, detector/yolo-v3/Reshape_4, detector/yolo-v3/Reshape_8" were provided in the configuration file. Entry points are nodes that feed YOLO Region layers. Node with name detector/yolo-v3/Reshape doesn't exist in the graph. Refer to documentation about converting YOLO models for more information.

 

which totally makes sense since I do not have those nodes in my frozen graph. However, on the other hand, I could not also figure out the correct node names for the entry points for my model.

I am terribly sorry for asking such a question but I was wondering if someone could help me out. It is been quite some time and I still could not solve it. I am kind of stuck so I would really appreciate any help.

I uploaded both h5 and pb files to gDrive -> https://drive.google.com/open?id=1lm6FGUNlJ0I_ChyhbED8bMcUhX4YZcJu

 

Kind Regards,
Frank

6 posts / 0 new

Hi Frank,

I can look into this for you. I'll run your model on my end to see if I'm getting the same errors. 

What command did you use to convert your model to IR? What version of OpenVINO are you using?

Best Regards,

Sahira 


Hi Sahira,

I really appreciate your help, thank you so much!

 

I am using the version 2019.3.379 (v2019_R3) and trying to convert the model with the following command:
 

python mo_tf.py --input_model testModel.pb --tensorflow_use_custom_operations_config "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\extensions\front\tf\yolo_v3.json" --model_name testModel --batch 1 --scale 255 --reverse_input_channels

 

and, this is the yolo_v3.json file

 

[
  {
    "id": "TFYOLOV3",
    "match_kind": "general",
    "custom_attributes": {
      "classes": 2,
      "anchors": [10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326],
      "coords": 4,
      "num": 9,
      "masks":[[6, 7, 8], [3, 4, 5], [0, 1, 2]],
      "entry_points": ["detector/yolo-v3/Reshape", "detector/yolo-v3/Reshape_4", "detector/yolo-v3/Reshape_8"]
    }
  }
]

 


Hi Frank,

I am looking into this and will get back to you when I have more information - thank you for your patience!

Best,

Sahira 


Hi Frank,

Just an update for you - Since the file with all the operations and layers was not provided in the repo, we have to find out the names of the entry points another way. 

I will let you know when we have more information.

Best,
Sahira 


Really appreciate it Sahira, thank you.

 

Kind regards,
Frank

Leave a Comment

Please sign in to add a comment. Not a member? Join today