Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn build:tflite fails #65

Open
edamlmmv opened this issue Apr 6, 2024 · 8 comments
Open

yarn build:tflite fails #65

edamlmmv opened this issue Apr 6, 2024 · 8 comments

Comments

@edamlmmv
Copy link

edamlmmv commented Apr 6, 2024

I need to update the size of modelBuffer to use a bigger model of MediaPipe (MultiSegmentation).

I'm executing yarn build:tflite but it fails with the following error:

invalid registered toolchain '@local_config_python//:py_toolchain': error loading package '@local_config_python//': Unable to find package for @python//:defs.bzl: The repository '@python' could not be resolved: Repository '@python' is not defined.

Do you have an idea what could cause the issue?

@Volcomix
Copy link
Owner

Volcomix commented Apr 7, 2024

I'm currently trying to fix the build. I managed to pass the Python error but now there are other errors popping related XNNPACK.
You can find some updates in the branch fix-tflite-build-python. And you can see the latest logs here.

This is a tedious investigation and I won't have a lot of time to spend on it. So perhaps could you also experiment on a fork on your own.

Also now that there are other builds of tflite in tfjs and mediapipe repositories (see #38), have you considered trying to switch to them?

@edamlmmv
Copy link
Author

edamlmmv commented Apr 8, 2024

I followed the most recent implementation of MediaPipe's image segmenter using the multi-segment model as it is the most accurate. However, the ImageSegmenter uses RequestAnimationFrame which freeze the stream transferred over WebRTC when changing tab so I need to do my own implementation similar to this repository which uses WebWorker and setTimeout.

I'll try to fix the XNNPACK issue. I'll report back if I find anything.

Thank you for taking time answering

@saghul
Copy link

saghul commented Apr 8, 2024

@edamlmmv
Copy link
Author

edamlmmv commented Apr 8, 2024

  1. I am not using (tflite.js | tflite.wasm | tflite-simd.js | tflite-simd.wasm) from this repository but instead vision_wasm_internal.
    (If you look into "@mediapipe/tasks-vision/wasm/" you'll find the files I'm talking about)

Inside of vision_wasm_internal, requestAnimationFrame is used. I don't think MediaPipe provide the C++ files from which vision_wasm_internal was compiled.

  1. However, you've pointed out something I didn't realize. In my implementation I AM using requestVideoFrameCallback. requestVideoFrameCallback freezes as well when changing tabs

Therefore I may be able to make it work with my implementation if I try using a web worker + setTimeout similar to this demo. I thought I was done for because requestAnimationFrame was inside of vision_wasm_internal but I may have been looking at the wrong place.

I'll try and report back if I find anything

@edamlmmv
Copy link
Author

edamlmmv commented Apr 9, 2024

I replaced requestVideoFrameCallback by setTimeout, added timerWorker.ts, added timerHelper and it worked! Thanks again for pointing that out saghul and for your time Volcomix.

-- videoFrameCallbackHandle = video.requestVideoFrameCallback(render);
++ timerWorker.setTimeout(render, 1000/30); // 30fps

If anybody is interested I could do a fork / branch where I implement vision_wasm_internal and MultiSegment model with ImageSegmenter into this demo.

@edamlmmv edamlmmv closed this as completed Apr 9, 2024
@edamlmmv
Copy link
Author

edamlmmv commented Apr 9, 2024

Err, should I re-open the issue since it is related to yarn build:tflite though?

@edamlmmv edamlmmv reopened this Apr 9, 2024
@oGKarlin
Copy link

oGKarlin commented May 2, 2024

I replaced requestVideoFrameCallback by setTimeout, added timerWorker.ts, added timerHelper and it worked! Thanks again for pointing that out saghul and for your time Volcomix.

-- videoFrameCallbackHandle = video.requestVideoFrameCallback(render); ++ timerWorker.setTimeout(render, 1000/30); // 30fps

If anybody is interested I could do a fork / branch where I implement vision_wasm_internal and MultiSegment model with ImageSegmenter into this demo.

I would be interested in having that fork :)

@edamlmmv
Copy link
Author

Kk I will work on it this weekend and report back. May take 2 weeks though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants