TensorFlow Lite model maker import errors

Hi guys I would like to train a custom object detection model on ubuntu.
I’m using miniconda with python 3.8.12 (also tried with 3.9.2). I installed numpy 1.24.2 and I installed tflite model maker with pip and I also installed tensorflow lite runtime (import tflite_runtime works fine)

I use the VM VirtualBox by oracle

I am facing a problem when I would like to import tflite_model_maker it throws these errors:

/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflowjs/read_weights.py:28: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.
  np.uint8, np.uint16, np.object, np.bool]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tflite_model_maker/__init__.py", line 44, in <module>
    from tflite_model_maker import audio_classifier
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tflite_model_maker/audio_classifier/__init__.py", line 24, in <module>
    from tensorflow_examples.lite.model_maker.core.data_util.audio_dataloader import DataLoader
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflow_examples/lite/model_maker/core/data_util/audio_dataloader.py", line 27, in <module>
    from tensorflow_examples.lite.model_maker.core.task.model_spec import audio_spec
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflow_examples/lite/model_maker/core/task/model_spec/__init__.py", line 20, in <module>
    from tensorflow_examples.lite.model_maker.core.task.model_spec import audio_spec
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflow_examples/lite/model_maker/core/task/model_spec/audio_spec.py", line 30, in <module>
    from tensorflow_examples.lite.model_maker.core.task import model_util
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflow_examples/lite/model_maker/core/task/model_util.py", line 28, in <module>
    from tensorflowjs.converters import converter as tfjs_converter
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflowjs/__init__.py", line 21, in <module>
    from tensorflowjs import converters
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflowjs/converters/__init__.py", line 21, in <module>
    from tensorflowjs.converters.converter import convert
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflowjs/converters/converter.py", line 35, in <module>
    from tensorflowjs.converters import keras_h5_conversion as conversion
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflowjs/converters/keras_h5_conversion.py", line 33, in <module>
    from tensorflowjs import write_weights  # pylint: disable=import-error
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflowjs/write_weights.py", line 25, in <module>
    from tensorflowjs import read_weights
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/tensorflowjs/read_weights.py", line 28, in <module>
    np.uint8, np.uint16, np.object, np.bool]
  File "/home/miscope/miniconda3/envs/py38/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'object'.
`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

I hope you guys can help me, thanks
you can also find this question on stackoverflow:

Hi @coconutguy, Thank you for bringing this into our notice. while replicating even i have observed the same. As it is a bug could you please post this in the tensorflow github repo or we can raise a bug in the github on your behalf. Thank You.

try this: pip install numpy==1.23.4
I heard that np.object is deprecated since 1.24

1 Like

This actually worked for me. This may work for you too guys. Thank you a lot for sharing this. I am very grateful. I was really suffering with some code and I really needed this!