Open glenn-jocher opened 1 year ago
May you try screening if StatusCode is used in any of your code and if you can use a different namespace for it?
@lu-wang-g the ultralytics
package doesn't use any type called 'StatusCode', but checking other dependencies like onnx
and tensorflow
I see that it is a pretty common name.
But this seems unrelated to ultralytics
as everything works correctly with tensorflow==2.13.1
, this error only appears in tflite_support
when used with tensorflow==2.14.0
.
@lu-wang-g I think this is due to the usage of the pybind11_abseil/status_casters.h
. I think this is somehow due to the the usage of pybind11::google::ImportStatusModule()
in this project as well as in TensorFlow and they are conflicting with each other.
The pybind side of issue that may be related is https://github.com/pybind/pybind11/issues/439.
I am not entirely sure how to address this as I am less experience with C++..
@lu-wang-g @ethanluoyc I just realized this error is very easily reproducible directly in Google Colab just by installing and attempting to import the package. If this package is not even usable in Google Colab this must raise some pretty serious red flags here no?
Are there any plans to resolve this and update the package?
!pip install tflite_support
import tflite_support
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
[<ipython-input-2-10ee15e7e9a8>](https://localhost:8080/#) in <cell line: 1>()
----> 1 import tflite_support
4 frames
[/usr/local/lib/python3.10/dist-packages/tensorflow_lite_support/python/task/vision/core/tensor_image.py](https://localhost:8080/#) in <module>
17
18 from tensorflow_lite_support.python.task.vision.core import color_space_type
---> 19 from tensorflow_lite_support.python.task.vision.core.pybinds import image_utils
20
21
ImportError: generic_type: cannot initialize type "StatusCode": an object with that name is already defined
A temporary workaround could be to skip the import statement that causing the issue, and import the metadata_writer that you're using directly. We're looking into fixing the root cause.
import flatbuffers
import platform
from tensorflow_lite_support.metadata import metadata_schema_py_generated
from tensorflow_lite_support.metadata import schema_py_generated
from tensorflow_lite_support.metadata.python import metadata
from tensorflow_lite_support.metadata.python import metadata_writers
@khanhlvg we've implemented your solution, it works, and we have now successfully updated to the latest version of TF 2.16 for Ultralytics exports in https://github.com/ultralytics/ultralytics/pull/13176
Thank you for the help!
YOLOv8 TFLite export is failing with the latest release of
tensorflow==2.14.0
but works withtensorflow==2.13.1
, the prior release.The error originates from the
tflite_support
package.Reproduce
Run in Google Colab: https://colab.research.google.com/github/ultralytics/ultralytics/blob/main/examples/tutorial.ipynb
Additional
Tracked in https://github.com/ultralytics/ultralytics/issues/5161