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

[Fix] Support fetching images when using worker engine #574

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

dstoc
Copy link
Contributor

@dstoc dstoc commented Sep 25, 2024

The previous implementation relied on the HTMLImageElement constuctor which is not available in worker contexts.

The previous implementation relied on the HTMLImageElement constuctor
which is not available in worker contexts.
@CharlieFRuan
Copy link
Contributor

CharlieFRuan commented Sep 25, 2024

Really appreciate the fix, will take a look soon!

Meanwhile if convenient, could you provide a small example that wouldn't work with the previous implementation but will work now? Or would feeding image to examples/get-started-web-worker be able to reproduce? Thanks!

@dstoc
Copy link
Contributor Author

dstoc commented Sep 25, 2024

Using the worker engine in examples/vision-model shows the issue: dstoc@d019388

Let me know if you want to add that change into this PR.

@CharlieFRuan
Copy link
Contributor

I see!

Let me know if you want to add that change into this PR.

That'd be great. Perhaps with a USE_WEB_WORKER flag on the top so users can switch back and forth. Thank you!

Copy link
Contributor

@CharlieFRuan CharlieFRuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on my end, works great; LGTM! Let's merge it after you add the web worker switch to vision-model.ts. Thank you!

@dstoc
Copy link
Contributor Author

dstoc commented Sep 26, 2024

Added.

@CharlieFRuan
Copy link
Contributor

Great work, thank you!

@CharlieFRuan CharlieFRuan merged commit fde1777 into mlc-ai:main Sep 26, 2024
1 check passed
@CharlieFRuan
Copy link
Contributor

Ahh I think the worker.ts is missed, I'll patch that

CharlieFRuan added a commit that referenced this pull request Sep 26, 2024
### Change

- #574
  - Enable image input for web/service worker

### TVMjs
- No change, version `0.18.0-dev0` just like 0.2.66
- Built at
apache/tvm@30fb16a
jzhao62 pushed a commit to jzhao62/web-llm that referenced this pull request Dec 8, 2024
The previous implementation relied on the HTMLImageElement constuctor
which is not available in worker contexts.
jzhao62 pushed a commit to jzhao62/web-llm that referenced this pull request Dec 8, 2024
### Change

- mlc-ai#574
  - Enable image input for web/service worker

### TVMjs
- No change, version `0.18.0-dev0` just like 0.2.66
- Built at
apache/tvm@30fb16a
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 this pull request may close these issues.

2 participants