TLLiteConverter 无法读取 h5 文件的数据类型

时间:2021-07-29 04:55:46

标签: tensorflow keras

我正在尝试通过参考链接 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/g3doc/r1/convert/python_api.md 将 h5 文件转换为 tflite 模型。

目的是优化h5文件。

这是我的点子列表

Package                   Version
------------------------- -------------------
absl-py                   0.11.0
altgraph                  0.17  
astor                     0.8.1 
attrs                     20.3.0
brotlipy                  0.7.0
certifi                   2021.5.30
cffi                      1.14.4
chardet                   4.0.0
click                     8.0.1
cryptography              3.3.1
Cython                    0.29.24
Flask                     1.1.2
gast                      0.2.2
google-auth-oauthlib      0.4.4
google-pasta              0.2.0
grpcio                    1.35.0
h5py                      2.10.0
idna                      2.10
importlib-metadata        3.4.0
itsdangerous              2.0.1
Jinja2                    2.11.3
Keras                     2.3.1
Keras-Applications        1.0.8
Keras-Preprocessing       1.1.2
keras-resnet              0.2.0
Markdown                  3.3.3
MarkupSafe                2.0.1
numpy                     1.19.5
oauthlib                  3.1.1
olefile                   0.46
opencv-python             4.5.3.56
opt-einsum                3.3.0
Pillow                    8.1.0
pip                       21.1.3
protobuf                  3.14.0
pyasn1                    0.4.8
pyasn1-modules            0.2.8
pycparser                 2.20
pyinstaller               4.4
pyinstaller-hooks-contrib 2021.2
PyJWT                     2.1.0
pyOpenSSL                 20.0.1
PySocks                   1.7.1
pyspnego                  0.1.6
PyYAML                    5.4.1
requests                  2.25.1
requests-oauthlib         1.3.0
rsa                       4.7.2
scipy                     1.5.2
setuptools                52.0.0.post20210125
six                       1.16.0
smbprotocol               1.5.1
tensorboard               1.15.0
tensorboard-plugin-wit    1.6.0
tensorflow                1.15.0
tensorflow-estimator      1.15.1
termcolor                 1.1.0
typing-extensions         3.10.0.0
urllib3                   1.26.6
webencodings              0.5.1
Werkzeug                  0.16.1
wheel                     0.36.2
wrapt                     1.12.1
yarl                      1.6.3
zipp                      3.5.0

这是我的来源。

import logging
logging.getLogger("tensorflow").setLevel(logging.DEBUG)
import tensorflow as tf
from tensorflow import keras
import numpy as np
import pathlib
from keras_retinanet import models

converter = tf.compat.v1.lite.TFLiteConverter.from_keras_model_file(
    './model/retinanet50_NP.h5', 
    custom_objects=models.backbone('resnet50').custom_objects)

keras_retinanet 模块从 https://github.com/fizyr/keras-retinanet 下载并使用。

错误内容为TypeError: Cannot interpret 'tf.float32' as a data type.

注意,我没有学习源,我只有h5文件。

我该如何解决这个问题?

0 个答案:

没有答案