google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.5k stars 5.15k forks source link

ImportError: cannot import name 'array_record_module' from 'array_record.python' #4553

Closed mihailpettas closed 1 year ago

mihailpettas commented 1 year ago

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

No

OS Platform and Distribution

Windows 11

Python Version

3.8, 3.10

MediaPipe Model Maker version

Latest

Task name (e.g. Image classification, Gesture recognition etc.)

Object detection

Describe the actual behavior

When i run the example code i get this

Traceback (most recent call last):
  File "c:/Users/froze/Desktop/poutses/kapota.py", line 1, in <module>
    from mediapipe_model_maker import object_detector
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mediapipe_model_maker\__init__.py", line 17, in <module>
    from mediapipe_model_maker.python.vision import image_classifier
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mediapipe_model_maker\python\vision\image_classifier\__init__.py", line 16, in <module>
    from mediapipe_model_maker.python.vision.image_classifier import dataset
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mediapipe_model_maker\python\vision\image_classifier\dataset.py", line 21, in <module>
    import tensorflow_datasets as tfds
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tensorflow_datasets\__init__.py", line 43, in <module>
    import tensorflow_datasets.core.logging as _tfds_logging
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tensorflow_datasets\core\__init__.py", line 22, in <module>
    from tensorflow_datasets.core import community
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tensorflow_datasets\core\community\__init__.py", line 18, in <module>
    from tensorflow_datasets.core.community.huggingface_wrapper import mock_builtin_to_use_gfile
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tensorflow_datasets\core\community\huggingface_wrapper.py", line 31, in <module>
    from tensorflow_datasets.core import dataset_builder
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tensorflow_datasets\core\dataset_builder.py", line 34, in <module>
    from tensorflow_datasets.core import dataset_info
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tensorflow_datasets\core\dataset_info.py", line 47, in <module>
    from tensorflow_datasets.core import file_adapters
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tensorflow_datasets\core\file_adapters.py", line 29, in <module>
    from array_record.python import array_record_module
ImportError: cannot import name 'array_record_module' from 'array_record.python' (C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\array_record\python\__init__.py)

Describe the expected behaviour

Should run without error

Standalone code/steps you may have used to try to get what you need

Tried changing python and dependencies versions error remains

Other info / Complete Logs

No response

mihailpettas commented 1 year ago

Did anyone look into it?

kuaashish commented 1 year ago

@stojanni,

Sorry for the delayed response,

Could you please confirm that Are you still looking for the resolution or the issue has been resolved from your end?

Thank you!

github-actions[bot] commented 1 year ago

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

mihailpettas commented 1 year ago

@stojanni,

Sorry for the delayed response,

Could you please confirm that Are you still looking for the resolution or the issue has been resolved from your end?

Thank you!

Ηello yes the error persists

kuaashish commented 1 year ago

@stojanni,

Could you please use the below command to install the array-record and let us know if this works for you.

pip install array-record

Thank you

mihailpettas commented 1 year ago

@kuaashish

Thank you but i get this:

Traceback (most recent call last):
  File "c:\Users\froze\Desktop\test\untitled3.py", line 3, in <module>
    from mediapipe_model_maker import object_detector
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mediapipe_model_maker\__init__.py", line 17, in <module>
    from mediapipe_model_maker.python.vision import image_classifier
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mediapipe_model_maker\python\vision\image_classifier\__init__.py", line 16, in <module>
    from mediapipe_model_maker.python.vision.image_classifier import dataset
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mediapipe_model_maker\python\vision\image_classifier\dataset.py", line 21, in <module>
    import tensorflow_datasets as tfds
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorflow_datasets\__init__.py", line 43, in <module>
    import tensorflow_datasets.core.logging as _tfds_logging
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorflow_datasets\core\__init__.py", line 22, in <module>
    from tensorflow_datasets.core import community
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorflow_datasets\core\community\__init__.py", line 18, in <module>
    from tensorflow_datasets.core.community.huggingface_wrapper import mock_builtin_to_use_gfile
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorflow_datasets\core\community\huggingface_wrapper.py", line 31, in <module>
    from tensorflow_datasets.core import dataset_builder
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorflow_datasets\core\dataset_builder.py", line 34, in <module>
    from tensorflow_datasets.core import dataset_info
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorflow_datasets\core\dataset_info.py", line 47, in <module>
    from tensorflow_datasets.core import file_adapters
  File "C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorflow_datasets\core\file_adapters.py", line 29, in <module>
    from array_record.python import array_record_module
ImportError: cannot import name 'array_record_module' from 'array_record.python' (C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\array_record\python\__init__.py)
kuaashish commented 1 year ago

Hello @jiuqiant,

Could you please look into this issue. Thank you

mihailpettas commented 1 year ago

@kuaashish @jiuqiant works without issue on collab if that helps

mihailpettas commented 1 year ago

Found the issue, the array_record_module is a .so file that runs only on linux. We need to use a windows compatible module or do the whole thing in linux. Can u please replace it with something that supports windows too?

joezoug commented 1 year ago

Hi @stojanni, this issue seems related to tensorflow-datasets which unfortunately is a necessary dependency in the Model Maker package. It seems like some users found a workaround for now by downgrading tensorflow-datasets to 4.8.3: https://github.com/tensorflow/datasets/issues/4805#issuecomment-1500185132. Can you give that a try?

mihailpettas commented 1 year ago

@joezoug apparently it also needs tensorflow-text thats also for linux

joezoug commented 1 year ago

@stojanni tensorflow-text is also necessary dependency. Although it isn't used in object_detector so you may be able to hack the init.py files to remove any references to text_classifier so that it doesn't get imported when you use object_detector.

mihailpettas commented 1 year ago

@joezoug the problem is i cant install the model maker because it requires tensorflow-text which hasnt wheels for windows

joezoug commented 1 year ago

@stojanni. Unfortunately, there's not much we can do at this moment to add windows support since the issue lies with tensorflow-text. It may be worth contacting the owners of tensorflow-text to see about windows support. Model maker will run fine in the free Colab environment, so I would recommend trying that option out as well.

github-actions[bot] commented 1 year ago

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] commented 1 year ago

This issue was closed due to lack of activity after being marked stale for past 7 days.