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.

Reshape error when running save_model.py

See original GitHub issue
Traceback (most recent call last):
  File "save_model.py", line 55, in <module>
    app.run(main)
  File "/home/ubuntu/.virtualenvs/tyt/lib/python3.6/site-packages/absl/app.py", line 299, in run
    _run_main(main, args)
  File "/home/ubuntu/.virtualenvs/tyt/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "save_model.py", line 51, in main
    save_tf()
  File "save_model.py", line 41, in save_tf
    utils.load_weights(model, FLAGS.weights)
  File "/home/ubuntu/tyt/core/utils.py", line 114, in load_weights
    conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0])
ValueError: cannot reshape array of size 4619172 into shape (1024,512,3,3)

I am experiencing this issue when attempting to convert a Yolov4 model trained on custom classes to tf using save_model

Yolov3 works fine, however the Yolov4 model is more accurate.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
alphapibetacommented, Jul 12, 2020

@ejri You need to go to

path/tensorflow-yolov4-tflite/data/classes/coco.names  

and change the classes according to your model for example: if you have only two classes

person
tv

and the other way is to change the line to your classes.names

0reactions
cyberjamcommented, Sep 12, 2020

@ejri 당신은 가야합니다

path/tensorflow-yolov4-tflite/data/classes/coco.names  

예를 들어 모델에 따라 클래스를 변경하십시오. 클래스 가 두 개 뿐인 경우

person
tv

다른 방법은 라인을 클래스 로 변경 하는 것입니다.

Thx!!! so much! I owe u one!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I solve reshape ValueError when convert yolov4 ...
Basically, you are cloning the root repo to run this file while having the paths in core/config.py unchanged.
Read more >
ValueError: cannot reshape array of size 2048 into shape (18 ...
Hi, I am trying to convert my custom YOLOv4 weights to TF using below command- python save_model.py --weights ./data/yolo-obj_best.weights ...
Read more >
tf.reshape | TensorFlow v2.11.0
Using -1 to infer the shape -- # Here -1 is inferred to be 9: tf.reshape(t, [2, -1]) <tf.Tensor: shape=(2, 9), dtype=int32, numpy=...
Read more >
(optional) Exporting a Model from PyTorch to ONNX and ...
In this tutorial, we describe how to convert a model defined in PyTorch into the ONNX format and then run it with ONNX...
Read more >
How to Save and Load Your Keras Deep Learning Model
Keras is a simple and powerful Python library for deep learning. ... How to save model weights and model architecture in separate files ......
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