question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How convert darknet model to onnx?

See original GitHub issue

Hi,

Can someone give me instructions how convert my custom darknet model (yolov2-tiny) to ONNX? I know I should convert my darknet model to tensorflow, then to onnx, but I struggle with this for several days.

What I’ve tried: Convert darknet model (weights + cfg) to tensorflow using darkflow -> I got .pb file (SUCCESS)

Then I wanted to convert pb file to onnx:

  1. Tried to convert pb file to onnx using mmconvert: mmconvert -sf tensorflow -iw path_to_my_pb_file -df onnx -om yolotfonnx --inNodeName input --dstNodeName output error: TypeError: can only concatenate list (not "NoneType") to list
  2. Tried to convert using tf2onnx: python3 -m tf2onnx.convert --graphdef path_to_my_pb_file --output yolov2-tiny.onnx --inputs input:0 --outputs output:0 error: AssertionError: output is not in graph

this also doesn’t work: python3 -m tf2onnx.convert --saved-model path_to_my_pb_file --output yolov2-tiny.onnx error:

RuntimeError: MetaGraphDef associated with tags 'serve' could not be found in SavedModel. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: `saved_model_cli`
available_tags: []
  1. Tried to convert using onnx-tf: onnx-tf convert -i path_to_my_pb_file -o path_for_output_onnx_file error: ValidationError: The model does not have an ir_version set properly.

I think darkflow can be not compatible with yolov2-tiny. I also tried to convert original darknet yolov2 model and have same problems after conversion with darkflow.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jjeongmin0308commented, Sep 2, 2022

Hello, I’m having a hard time converting the darknet yolov2 model to onnx. It has been converted but does not detect anything when running Barracuda. I want to know in detail how you did it, is it possible?

https://github.com/derenlei/Unity_Detection2AR/issues/39

Here’s what I tried.

2reactions
BeiieBcommented, Feb 27, 2021

Hi,

I tried your ‘yolov2-tiny_freeze’ model and I think it works well. Set the INPUT_NAME to yolov2-tiny/net1 and OUTPUT_NAME to yolov2-tiny/convolutional9/BiasAdd. Also, we use different scripts for yolov2 and v3 so make sure the Selected_detector under Camera Image is yolo 2_tiny. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Darknet model to onnx
I am currently working with Darknet on Yolov4, with 1 class. I need to export those weights to onnx format, for tensorRT inference....
Read more >
How to convert Darknet Yolo v3 tiny weights to ONNX?
I can't find a straight answer on how to convert Darknet Yolo v3-tiny weights to ONNX format anywhere, does anyone know how to...
Read more >
Part 2: Convert Darknet to yolov3.onnx
This article describe how you can convert a model trained with Darknet using this repo to onnx format. Once you have converted the...
Read more >
Yolv3 to onnx format
This article describe how you can convert a model trained with Darknet using this repo to onnx format. Once you have converted the...
Read more >
Can't fine source convert darknet image classification to ...
Hello, I build darknet framework on Jetson Nano and test with image It's working. One thing that I really one is build to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found