GithubHelp home page GithubHelp logo

convert_yolo_weights's Introduction

CONVERT YOLO WEIGHTS

Convert Yolo-v4/v3/v2 .weights model to other models.

YOLO-v4:

  • Keras.
  • Mlmodel.
  • Tensorflow.
  • Pytorch.

YOLO-v3 + YOLO-v2

  • Keras.
  • Mlmodel.
  • Tensorflow.
  • Onnx.
  • Pytorch.
  • Tflite.

convert_yolo_weights's People

Contributors

phanxuanduc1996 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

convert_yolo_weights's Issues

Error when converting Yolov4-Tiny model to Keras: buffer is too small for requested array

Hi,

I'm running the convert_weights_to_keras.py script, with weights trained in darknet and the corresponding cfg.

The conversion fails with error:

Parsing section convolutional_19
conv2d bn leaky (3, 3, 384, 256)
Traceback (most recent call last):
File "convert_weights_to_keras.py", line 320, in
_main(parser.parse_args())
File "convert_weights_to_keras.py", line 157, in _main
conv_weights = np.ndarray(
TypeError: buffer is too small for requested array

It seems the binary is ending before it's expected, it expects to read 3538944 bytes but instead it reads only 2786388 bytes from the weights file.

The input size is not square in the cfg, but 640x480. I'm certain there's no mismatch between the weights and cfg file.

Why could this be happening?

Has anything changed in the binary format the script may need to be adapted to?

Any pointers would be greatly appreciated, thanks.

Error when coverting Yolov4 to mlmodel

Hi,

I trying to convert yolov4 and yolov4-tiny (from https://github.com/AlexeyAB/darknet) but I got the same error for both of them:

python convert_weights_to_mlmodel.py --img_size=416 --config_path=C:/Downloads/yolov4-tiny.cfg --weights_path=C:/Downloads/yolov4-tiny.weights --output_path=yolov4-tiny.mlmodel
Using TensorFlow backend.
Loading weights.
Weights Header: 0 2 5 [32012800]
Parsing Darknet config.
Creating Keras model.
Parsing section net_0
Parsing section convolutional_0
conv2d bn leaky (3, 3, 3, 32)
Traceback (most recent call last):
File "convert_weights_to_mlmodel.py", line 344, in
_main(parser.parse_args())
File "convert_weights_to_mlmodel.py", line 232, in _main
prev_layer = ZeroPadding2D(((1,0),(1,0)))(prev_layer)
File "C:\Miniconda3\envs\tf\lib\site-packages\keras\engine\base_layer.py", line 474, in call
output_shape = self.compute_output_shape(input_shape)
File "C:\Miniconda3\envs\tf\lib\site-packages\keras\layers\convolutional.py", line 2113, in compute_output_shape
output_shape[dim] += sum(padding_all_dims[dim])
TypeError: can only concatenate str (not "int") to str

I'm using tensorflow 1.5 and keras 2.2.4 (as other versions generated warnings of compatibility). It seems to have a type mixup somewhere in the code. Any ideas?

Convert yolov3 to onnx

Hello, @phanxuanduc1996, i successfully convert my darknet weights to pytorch format (YoloV3), but when i'm trying convert to onnx, i've got error:
AttributeError: 'dict' object has no attribute 'state_dict'

In torch init.py method:
def _unique_state_dict(module, keep_vars=False):
# since Parameter.data always creates a new torch.Tensor instance,
# id(v) doesn't work with it. So we always get the Parameter or Buffer
# as values, and deduplicate the params using Parameters and Buffers
state_dict = module.state_dict(keep_vars=True)

What version of torch you using? I'm trying 1.4 and 1.5. OS: Windows 10 (build 2004). Python 3.8

tensorflow to onnx

Hi, @phanxuanduc1996
I am trying to convert ylov3.weights to TensorFlow and from Tensorflow to onnx but I did not find TensorFlow to onnx in this repo
so I tried tf2onnx
but there it's asking inputs and outputs
python -m tf2onnx.convert --checkpoint tensorflow-model-meta-file-path --output model.onnx --inputs input0:0,input1:0 --outputs output0:0
when i ran it its giving error
AssertionError: output0 is not in graph

convert yolov4

Great work!
Would you please convert yolov4 to onnx ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.