2023-05-24 00:49:01.568880: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll E:\ProgramFile\Anaconda\anaconda3\envs\python39\lib\site-packages\scipy\__init__.py:173: UserWarning: A NumPy version >=1.19.5 and <1.27.0 is required for this version of SciPy (detected version 1.19.3) warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}" Traceback (most recent call last): File "D:\23101\yolov5-master\jjjjjj.py", line 2, in <module> converter = tf.lite.TFLiteConverter.from_onnx('best.onnx') AttributeError: type object 'TFLiteConverterV2' has no attribute 'from_onnx'
时间: 2023-10-06 13:10:05 浏览: 183
常见的tensorflow-gpu2.x缺失dll(cublas64-11.dll&cublasLt64-11.dll等)
根据报错信息,您使用的是 TensorFlow 2.x 版本,但是 `TFLiteConverterV2` 类并没有 `from_onnx` 方法。可能是因为该方法是在 TensorFlow 1.x 版本中添加的,而在 TensorFlow 2.x 版本中已被移除。您可以尝试使用 `TFLiteConverter` 类来转换 ONNX 模型。例如:
```python
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model('saved_model')
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)
```
其中 `from_saved_model()` 方法用于从 TensorFlow SavedModel 格式加载模型,你也可以使用 `from_keras_model()` 方法从 Keras 模型加载模型。
阅读全文