phanxuanduc1996 / convert_yolo_weights Goto Github PK
View Code? Open in Web Editor NEWSummary of methods to convert models in Yolo-v4-v3-v2
Summary of methods to convert models in Yolo-v4-v3-v2
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
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.
hello,i want to konwn how to convert ckpt 2 weights? thx
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?
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
Great work!
Would you please convert yolov4 to onnx ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.