-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[tf-core] Cannot pass ImageBitmap to model in worker #5743
Comments
This is not a bug in TFJS, this is how web workers work in general - there is no DOM in a worker, so you cannot rely on any DOM objects. TFJS could print more informative error message, but root cause is the same. What you can do is pass pixel data (as value or actually transfer ownership of an array to worker) such as |
|
@AlexShafir yup, thats the best approach for web workers... |
Thank you @vladmandic @AlexShafir closing this issue as this is not a bug and more support issue. Feel free to @mention to reopen. |
@rthadur if API says that one can enter ImageBitmap, you pass it (in worker context) and it crashes, I expect this behavior is called a bug? |
FEATURE * Allow passing ImageBitmap in worker context * Fix TS type check * Update browser.ts * Add check for OffscreenCanvasRenderingContext2D * Add test for passing ImageBitmap * Strenghten check * Simplify check * Fix test * Remove test * Add test * Improve test description * Make test worker-centric * Improve preconditions, add canvas mock * Add backend import * Relax type check for the mock * Fix code style * Fix typo * Revert mock addition
* Allow passing ImageBitmap in worker context * Fix TS type check * Update browser.ts * Add check for OffscreenCanvasRenderingContext2D * Add test for passing ImageBitmap * Strenghten check * Simplify check * Fix test * Remove test * Add test * Improve test description * Make test worker-centric * Improve preconditions, add canvas mock * Add backend import * Relax type check for the mock * Fix code style * Fix typo * Revert mock addition * Fix test * Fix test * Relax type check * Try error for sanity * Fix typo * Undo sanity error * Fix test * Limit line lengths * Refactoring * Add worker termination * Fix test * Shorten lines * Exclude webgl test * Fix typo * Fix typo Co-authored-by: Ping Yu <4018+pyu10055@users.noreply.github.com>
System information
Model: face-landmarks-detection v. 0.0.4, with wasm-only backend.
Preconditions
Describe the current behavior
ReferenceError: document is not defined
.Describe the expected behavior
ImageBitmap gets processed.
Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/CodePen/any notebook.
https://github.com/AlexShafir/Sensoria/blob/tfjs5743
Message passed here, received here
Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.
Probably related to #4218
The text was updated successfully, but these errors were encountered: