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'
环境:
转换代码:
报错信息:
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'