Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
106 Views

Convert yolov2 model to OpenVino

Hi,

I have trained yolov2 darknet model on custom dataset with 2 classes. I want to convert that into OpenVino.

So I am following this link -

https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_...

First I am trying to convert into tensorflow using this command

python3 ./flow --model <path_to_model>/<model_name>.cfg --load <path_to_model>/<model_name>.weights --savepb

But I am getting this error -

Parsing yolov2.cfg
Loading yolov2.weights ...
Traceback (most recent call last):
  File "./flow", line 6, in <module>
    cliHandler(sys.argv)
  File "darkflow/darkflow/cli.py", line 26, in cliHandler
    tfnet = TFNet(FLAGS)
  File "darkflow/darkflow/net/build.py", line 58, in __init__
    darknet = Darknet(FLAGS)
  File "darkflow/darkflow/dark/darknet.py", line 27, in __init__
    self.load_weights()
  File "darkflow/darkflow/dark/darknet.py", line 82, in load_weights
    wgts_loader = loader.create_loader(*args)
  File "darkflow/darkflow/utils/loader.py", line 105, in create_loader
    return load_type(path, cfg)
  File "darkflow/darkflow/utils/loader.py", line 19, in __init__
    self.load(*args)
  File "darkflow/darkflow/utils/loader.py", line 77, in load
    walker.offset, walker.size)
AssertionError: expect 202335260 bytes, found 202335264

Any help will be appreciated

Regards

Ashish

0 Kudos
7 Replies
Highlighted
Employee
106 Views

Dearest verma, Ashish,

Are you using the latest OpenVino Release 2019R1.1 ? Also I'm curious. Why do you want to use yolo2 when yolo3 is clearly improved (better, faster) ? yolo2 should really only be used for backward compatibility purposes but any new development should use yolo3.

Thanks,

Shubha

0 Kudos
Highlighted
Beginner
106 Views

Dear Shubha,

I am just testing different yolo version for a requirement with less number of classes. I am already able to run yolov3-openvino version but It's taking more time then expected, so I am just curious to know how yolov2 performs with the same number of classes.

Although I am able to convert original yolov2 model to OpenVino but not my custom trained model, I just reduced the number of classes and change the filters in yolov2.cfg file.

I am using 2018 R5.1 version and I have also read somewhere that yolov3 is accurate but not faster due to more number of layers.

I have one more doubt currently for Yolov3 I am able to convert in OpenVino with input size = 416 , Can I do the same with input size = 320.

Thanks in advance

Regards

Ashish

0 Kudos
Highlighted
Employee
106 Views

Dear verma, Ashish,

Wow 2018 R5.1 is ancient. We are on 2019R1.1 right now so I strongly recommend that you upgrade. Tiny YoloV3 is supposed to be a lightweight version of YoloV3 (far fewer layers), but unfortunately Tiny YoloV3 is broken on OpenVino 2019R1.1, see github issue 151 . Non-Tiny YoloV3 definitely works though.

Unfortunately we don't have any YoloV2 samples but we do have both Python and C++ versions of yoloV3 samples.

According to this darknet issue it is possible to use other input sizes besides 416.

Though we don't have a yoloV2 sample, yolov2 is definitely supported. 

What you are trying to do definitely is supported by OpenVino. I encourage you to upgrade to OpenVino 2019R1.1 and try again. Please report your results here,

Much thanks,

Shubha

0 Kudos
Highlighted
Beginner
106 Views

Dear Shubha,

I don't think OpenVino version is an issue because I am not able to convert the darknet model to tensorflow, using the mentioned steps, to convert it into .xml and .bin is stage 2. I will definitely upgrade my version to 2019R1.1 once I am able to get model.pb file. I need help in that.

Thanks for your quick response

Regards

Ashish

0 Kudos
Highlighted
Employee
106 Views

Dear verma, Ashish,

Many fixes and improvements are always put into our new releases. But I see what you mean, 

python3 ./flow --model <path_to_model>/<model_name>.cfg --load <path_to_model>/<model_name>.weights --savepb

 

Has absolutely nothing to do with OpenVino.

But I found some hits on the web regarding your issue (it's not an OpenVino issue):

https://github.com/thtrieu/darkflow/issues/223

https://github.com/thtrieu/darkflow/issues/802

Hope it helps,

Thanks,

Shubha

0 Kudos
Highlighted
Beginner
106 Views

Dear Shubha,

Thanks for the links. I am able to resolve the issue, by following this -

Hey @conjuringjha , I had the same issue but I solved it by just substracting the found value (in your case 180357512) to the expected value (in your case 64701556). Let Assume the result is "X".
Now open your file ./darkflow/utils/loader.py and find the line 121. Then you will see a variable "self.offset" with a certain value assigned (16 or 20). Let suppose that value equals "Y".
Upadte the value of self.offset=Y+X

Regards

Ashish

0 Kudos
Highlighted
Employee
106 Views

Dear Ashish,

Glad it worked out for you and thanks for reporting your success back to the community !

Shubha

0 Kudos