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.07k stars 5.11k forks source link

Hair segmentation with mediapipe on tensorflow lite #2312

Closed Arezki93 closed 3 years ago

Arezki93 commented 3 years ago

Hi,

I am trying to use mediapipe's hair segmentation model in script but I am coming across the error of

RuntimeError:`` Encountered unresolved custom op: MaxPoolingWithArgmax2D.Node number 12 (MaxPoolingWithArgmax2D) failed to prepare.

can you please explain how did you created the without custom op version of the mediapipe model ?

sgowroji commented 3 years ago

Hi @Arezki93, Could you please provide the steps to reproduce the above error. Thanks!

Arezki93 commented 3 years ago

Hi @sgowroji, thank you for the answer, here are the steps I followed : 1) I loaded the hair_segmentation.tflite file 2) I did a allocate_tensors() -> it generates an error (Encountered unresolved custom op: MaxPoolingWithArgmax2D.Node number 12 (MaxPoolingWithArgmax2D) failed to prepare)

import tensorflow as tf import numpy as np interpreter = tf.lite.Interpreter('hair_segmentation.tflite') interpreter.allocate_tensors() **--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last)

in 1 model_file = 'hair_segmentation.tflite' 2 interpreter = tf.lite.Interpreter(model_path = model_file) ----> 3 interpreter.allocate_tensors() ~\anaconda3\lib\site-packages\tensorflow\lite\python\interpreter.py in allocate_tensors(self) 406 def allocate_tensors(self): 407 self._ensure_safe() --> 408 return self._interpreter.AllocateTensors() 409 410 def _safe_to_run(self): RuntimeError: Encountered unresolved custom op: MaxPoolingWithArgmax2D.Node number 12 (MaxPoolingWithArgmax2D) failed to prepare.**
google-ml-butler[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

TomerJakobovich commented 3 years ago

I also encountered this issue, @Arezki93 did you find a solution?

Arezki93 commented 3 years ago

unfortunately I did not find a solution !

Le dim. 8 août 2021 à 15:29, TomerJakobovich @.***> a écrit :

I also encountered this issue, @Arezki93 https://github.com/Arezki93 did you find a solution?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/mediapipe/issues/2312#issuecomment-894798054, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOMHEADMGTH2B4SVGH4LA53T32BDHANCNFSM5AT6KHVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

sgowroji commented 3 years ago

Hi @Arezki93, MediaPipe tflite where updated with ops here https://github.com/google/mediapipe/blob/ecb5b5f44ab23ea620ef97a479407c699e424aa7/mediapipe/util/tflite/cpu_op_resolver.cc#:~:text=void%20MediaPipe_RegisterTfLiteOpResolver(tflite,%7D But not sure about it in python.

jiuqiant commented 3 years ago

MediaPipe repo has custom ops for the hair segmentation model. So, using the model with tflite python interpreter directly doesn't work. You need to copy the custom ops to a local TensorFlow repo and rebuild its python package.

Since it's not a MediaPipe Python issue, reassign this back to @sgowroji .

sgowroji commented 3 years ago

Closing this issue w.r.t the above comments, answers your query.

google-ml-butler[bot] commented 3 years ago

Are you satisfied with the resolution of your issue? Yes No