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

[Bug] Tensor.fromImage() in webworker #22152

Closed
reinhrst opened this issue Sep 19, 2024 · 2 comments · Fixed by #22153
Closed

[Bug] Tensor.fromImage() in webworker #22152

reinhrst opened this issue Sep 19, 2024 · 2 comments · Fixed by #22153

Comments

@reinhrst
Copy link
Contributor

The offending line is

if (canvas instanceof HTMLCanvasElement) {

instanceof HTMLCanvasElement fails because HTMLCanvasElement does not exist in a worker.

Adding some typeof HTMLCanvasElement !== undefined && in the if statement, should fix it

@reinhrst
Copy link
Contributor Author

As long as the patch is not yet merged, a quick solution is to add the following line to your code:

globalThis.HTMLCanvasElement = OffscreenCanvas

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

Successfully merging a pull request may close this issue.

2 participants
@reinhrst and others