bubbliiiing / mobilenet-yolov4-pytorch

这是一个mobilenet-yolov4的库,把yolov4主干网络修改成了mobilenet,修改了Panet的卷积组成,使参数量大幅度缩小。
MIT License
369 stars 104 forks source link

博主我在训练完成后,使用下面代码将权重文件转化成tflite模型出现错误 #50

Closed RMsu233 closed 1 year ago

RMsu233 commented 1 year ago

环境:

numpy==1.18.4
matplotlib==3.2.1
opencv_python==4.2.0.34
tensorflow_gpu==2.2.0
tqdm==4.46.1
Pillow==8.2.0
h5py==2.10.0

转换代码:

import tensorflow as tf

#加载模型
model = tf.keras.models.load_model('best_epoch_weights.h5')

#转换为TFLite模型
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.allow_custom_ops = True  # 允许自定义操作
tflite_model = converter.convert()

保存TFLite模型
with open('yolov4.tflite', 'wb') as f:
    f.write(tflite_model)

报错信息:

Traceback (most recent call last): File "h5py/h5t.pxd", line 14, in init h5py._conv File "h5py/h5t.pyx", line 293, in init h5py.h5t File "/home/rmsu233/anaconda3/envs/Tensorflow/lib/python3.8/site-packages/numpy/init.py", line 320, in getattr raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'typeDict'