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

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

我正在使用 https://github.com/haroonshakeel/tensorflow-yolov4-tflite 的开源将我的自定义权重文件转换为 tflite。

当我将 Yolov4.weights 转换为 tflite 时没有错误,但是当我切换到 Yolov4-tiny.weights 时出现这样的错误

 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)

有谁知道如何解决这个问题? 谢谢

我通过 2 次更改解决了这个问题;替换 类 名称并安装特定版本的 tensorflow-cpu (2.3.0)

  1. 在我的例子中,我在包含代码的第 14 行更改了 core/config.py 文件:

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

将coco.names替换为custom.names,就这样

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

然后我在 ./data/classes 目录中创建了这个新文件 custom.names 包含我的新自定义名称 类 而不是默认的 COCO 类.

  1. 我更新了我的 pip3 版本 然后为 cpu:
  2. 安装 tensorflow 版本 2.3.0rc2

pip3 install --upgrade pip

pip3 install tensorflow-cpu==2.3.0rc2

这解决了我的问题。

PS:我使用 gpu (T4) 在 colab 上构建了我的模型,但我是 testing/using 我本地机器上的模型 没有GPU。