Error running mediapipe model maker

Hello, im trying to run this code: from mediapipe_model_maker import object_detectorimport jsonimport tensorflo - Pastebin.com

Initially i was getting this error:

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)

so i did this pip install tensorflow-datasets==4.8.3 and now im getting this:

  warnings.warn(
Traceback (most recent call last):
  File "c:\Users\froze\Desktop\poutses\kapota.py", line 1, in <module>
    from mediapipe_model_maker import object_detector
ImportError: cannot import name 'object_detector' from 'mediapipe_model_maker' (C:\Users\froze\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mediapipe_model_maker\__init__.py)

im on python 3.10 also tested with 3.8. It seems to be working on google colab tho

install mediapipe-model-maker like this
!pip install mediapipe-model-maker --user
it will work for me

unfortunately error remains on local env

use this it will work
!python 3.8.10
!pip install --upgrade pip
!pip install mediapipe-model-maker
or
!python 3.0.0
!pip install --upgrade pip
!pip install mediapipe-model-maker --user

@Mihail,

Could you please try the following combination and let us know?

mediapipe-model-maker==0.2.0
tensorflow==2.11.1
tensorflow-datasets==4.9.0
python==3.10.12

Thank you!

@chunduriv doesnt seem to work either. heres my terminal PS C:\Users\froze\Desktop\poutses> pip install mediapipe-model-maker==0.2.0 - Pastebin.com now the model maker cant be imported

@Mihail,

It seems like a bug, please create an issue on github for the fix.

Thank you!

1 Like

@chunduriv i did thanks. one last thing. in the object detection example do the images need to be at a specific size? can i put the bounding box coordinates in 0-1 range instead of pixels?

@Mihail,

in the object detection example do the images need to be at a specific size?

No, the object detector task automatically resizes, pads and normalizes the input image to match the input requirements of its model.

can i put the bounding box coordinates in 0-1 range instead of pixels?

I don’t think normalising the bounding box coordinates in the range of 0-1 as they are dependent on pixel locations.

Thank you!

1 Like

hey @chunduriv i have a question. when running this example https://developers.google.com/mediapipe/solutions/vision/object_detector/customize
to train the model on a new label, how many frames should i feed in? I did 100 frames of a mouse but it didnt work at all

@Mihail,

There is no standard number for using samples. Ideally the sample should be evenly distributed across all the classes for the model to learn without bias to the particular class.

Thank you!

@chunduriv i read a few thousands are the minimum. thats disappointing, i hoped it to be less

could you send the link of your issue, I would like to follow up.