Converting Yolov4 Tiny to tflite. error:cannot reshape array of size 372388 into shape (256,256,3,3)


i’m converting my custom weights file to tflite by using open source from

there is no error when i convert Yolov4.weights to tflite but when i switch to Yolov4-tiny.weights i got an error like this

 conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0])

ValueError: cannot reshape array of size 372388 into shape (256,256,3,3)

does anyone knows how to fix this problem?
Thank you


I solved it doing 2 changes; replacing classes names and installing specific version of tensorflow-cpu (2.3.0)

  1. In my case I changed the core/ file at the line 14 containing the code:

__C.YOLO.CLASSES = "./data/classes/coco.names"

replacing coco.names to custom.names, like that

__C.YOLO.CLASSES = "./data/classes/custom.names"

and then I created this new file custom.names at ./data/classes directory
containing the names of my new custom classes instead of the default COCO classes.

  1. I updated my pip3 version
    and then installed tensorflow version 2.3.0rc2 for cpu:

pip3 install --upgrade pip

pip3 install tensorflow-cpu==2.3.0rc2

that solved the issue for me.

PS: I built my model on colab using gpu (T4) but I was testing/using the model on my local machine
without gpu.

Answered By – brunocrt

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published