generic_type: type "InterpreterWrapper" is already registered!
原因:tensorflow2.5.0rc0版本太高,
1.降低版本:
pip install tensorflow==2.3
2.搜索整个代码库查找其他尝试注册"InterpreterWrapper"的地方,注释掉
3.可以尝试使用 clear_extension 函数删除注册表中的该类型
from google.protobuf.descriptor import FieldDescriptor from tensorflow.lite.python.schema_py_generated import _TENSORFLOW_LITE_WRAPPERS_PROTOBUF_WRAPPER_DESCRIPTOR as descriptor # Clear the extension registry for InterpreterWrapper if 'InterpreterWrapper' in descriptor.extensions_by_name: FieldDescriptor._extensions_by_name.pop('InterpreterWrapper', None)
4.改用tf.lite
import tensorflow as tf self.model = tf.lite.Interpreter(self.model_path + "/model.tflite") self.model.allocate_tensors() self.model_input = self.model.get_input_details() self.model_output = self.model.get_output_details() gpu_devices = tf.config.experimental.list_physical_devices('GPU') if gpu_devices: # your_input_data 为输入数据 self.model.set_tensor(self.model_input[0]['index'], your_input_data) self.model.invoke() output_tensor = self.model.get_tensor(self.model_output[0]['index'])
ValueErron: "batch_size" needs to be set for models with batch normalization layers.
模型搭建直接引用keras,前面去掉tensorflow
ImportError: cannot import name 'ParamSpec' from 'typing_extensions'
pip install typing-extensions==4.3.0
或
pip install Twisted==22.4.0
cannot import name 'get_config' from 'tensorflow.python.eager.context'
keras版本太高
pip install keras==2.2.5
或者将keras都改成tensorflow.keras
浙公网安备 33010602011771号