2

i'm converting my custom weights file to tflite by using open source from https://github.com/haroonshakeel/tensorflow-yolov4-tflite.

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

lin
  • 23
  • 2
  • 5

1 Answers1

0

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/config.py 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.

brunocrt
  • 720
  • 9
  • 11