-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add Image-To-Image Pipeline #3
Conversation
Wow, thanks. I'm a bit slow with the library update but i think it was worth it, i got one unet step to be less than 1 second on 3090, you can see results here microsoft/onnxruntime#17373 (comment) Also works on m1 mac and should be around 2sec for a step I need to do a few fixes on ONNX and then will publish the update. Then this one will be actually usable and will change into diffusers.js Will review the changes later today |
No worries. That UNET speedup is very impressive, thank you for that! Perfect, I'll wait for that update. In addition, I will close the issue that I had since I was able to run the project successfully. Let me know if there are any issues with my changes. Thank you! |
@jdp8 i've updated @aislamov/onnxruntime-web64 to version 1.0.0 and now it should work very fast change this line
to
if you are using windows and don't have windows sdk installed, you might need to download this https://github.com/microsoft/DirectXShaderCompiler and put dxcompiler.dll to google chrome dir. Then launch chome with this command line flag if it will crash with let me know if something does not work |
@dakenf I tried to run it with your changes but I got this error when trying to download the UNET model: Errors in the console: These are the steps that I followed, please let me know if I'm missing something:
I'm using an M1 Pro (16 GB) and the models are still being downloaded from the |
Hmm. Let me do some more tests and update the model in reposotory |
@jdp8 can you try changing the first line in StableDiffusionPipeline to
|
Ok, i've just published @aislamov/onnxruntime-web64 1.0.1 |
Most likely it's out of memory issue. Try these
i'm now working on VRAM usage reduction since it uses about 10gb in current release |
I'm running the VAE Encoder that's in your Hugging Face repo, specifically this one from the 'Initial fp16 ONNX commit'. The strange thing is that it doesn't fail when using the 'wasm' backend but fails when using the 'webgpu' backend. I tried to use two methods separately to release or dispose the text_encoder and vae_encoder sessions after using them in order to free up memory but they didn't prevent the error from occurring. The methods that I used were |
I'm going to merge it and then do some testing |
I've updated the model on huggingface and onnxruntime package. It now takes 1 second for a step on m1 max and image2image works fine I will do some refactoring on the weekend to change this repo to diffusers.js library |
Just tested it and it generated the image in less than a minute on M1 Pro. Thank you! Awesome, that's great news! I'll be on the lookout to see if I can help with anything else. |
Description
The changes include adding the Image-To-Image pipeline, along with the input fields for the Text-To-Image and Image-To-Image pipelines such as the Seed, Guidance Scale, Input Image and Strength. The Image-To-Image pipeline is basically the same as the Text-To-Image pipeline except that instead of having a random latent as input, a noisy input image is used as the input latent.
Specific Changes
App.tsx
file.App.tsx
.App.tsx
.encodeImage(input_image)
that uses the VAE Encoder to encode the input image from image space to latent space. The function was added toStableDiffusionPipeline.ts
. The code was taken from thepil_to_latent(input_im)
function shown here.add_noise()
. Added to thePNDMScheduler.ts
file. The code was taken from here.package.json
file in order to use a seedable Random Number Generator (RNG).randomNormal()
andrandomNormalTensor()
functions in theTensor.ts
file to accept the input seed and the RNG.encodeImage()
andadd_noise()
functions and add a modification to the img2img timesteps depending on the strength and inference steps. Added to theStableDiffusionPipeline.ts
file. Code taken from here.Issues
To make the project work successfully, there were other slight changes done:
package.json
file to "."images
argument from therunInference()
function in theApp.tsx
file.