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

It seems like Xenova/swin2SR-classical-sr-x2-64 model only work with image url?How to implement partial output with it? #1188

Open
codenoobforreal opened this issue Feb 10, 2025 · 4 comments
Labels
question Further information is requested

Comments

@codenoobforreal
Copy link

codenoobforreal commented Feb 10, 2025

Question

I have fun with react demo and Xenova/swin2SR-classical-sr-x2-64 model.
https://huggingface.co/Xenova/swin2SR-classical-sr-x2-64
I tried to give object URL to upscaler function but it doesn't work, I wonder if it only accepts image url.
Also I want to know how to do partial output like the translate react demo.

I tried to convert output data to base64 for rendering but It doesn't work.

Image
Image

Is it output png rawdata only?

@codenoobforreal codenoobforreal added the question Further information is requested label Feb 10, 2025
@emojiiii
Copy link
Contributor

const image = await RawImage.fromURL(url);
const output = (await upscaler(image)) as unknown as RawImage;
const result = output.toBlob();

@codenoobforreal
Copy link
Author

const image = await RawImage.fromURL(url);
const output = (await upscaler(image)) as unknown as RawImage;
const result = output.toBlob();

Sorry for the late reply.
I tried the const result = output.toBlob(); solution, but it doesn't work.

Image

I pushed a repo to github:https://github.com/codenoobforreal/xobia
run dev script,go to http://localhost:5173/image-to-image
open devtool,click on random image once and wait for logging

@emojiiii
Copy link
Contributor

@codenoobforreal
Copy link
Author

postMessage can only pass structured data, so it is wrong to pass the entire object directly.

https://github.com/codenoobforreal/xobia/blob/master/src/features/image-to-image/superResolution.js#L33C3-L33C9 https://github.com/codenoobforreal/xobia/blob/master/src/routes/image-to-image.tsx#L84

Thanks for pointing out the potential bug of the file picker, the problem at the moment is that I don't know how to convert the worker output raw data to show the result image on the page.
I got a type error as you can see in the picture above when trying the toBlob function.
https://github.com/codenoobforreal/xobia/blob/02cde76ed629fc0a9514f37fba4bbaaf6c230aa7/src/routes/image-to-image.tsx#L48

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

No branches or pull requests

2 participants