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

Saving Image Locally #6310

Closed
wants to merge 35 commits into from
Closed

Conversation

hi-sushanta
Copy link
Contributor

I've expanded the Stable Diffusion pipeline's capabilities by introducing a new parameter that empowers you to preserve generated output locally, precisely where you wish.

Before submitting

hi-sushanta and others added 30 commits October 5, 2023 06:34
…standing other developers what are doing and where it's using.
This changes suggest by maintener.

Co-authored-by: Sayak Paul <[email protected]>
Add suggested text

Co-authored-by: Sayak Paul <[email protected]>
I changed the Parameter to Args text.
proper indentation set in this file.
a little bit of change in the act_fun argument line.
similar doc-string add to have in the original diffusion repository.
@sayakpaul
Copy link
Member

We don't need this parameter as saving an image is just a one-liner.

@hi-sushanta
Copy link
Contributor Author

But it's usefull to save generated output locally.
Example:

import torch
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
pipe = pipe.to("cuda")
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt,save_img_path="marse-with-horse.png")

@hi-sushanta
Copy link
Contributor Author

And also it's small line of code.

@sayakpaul
Copy link
Member

sayakpaul commented Dec 26, 2023

That is exactly the point.

prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]
image.save("name.jpeg")

Does the job.

Then when num_images_per_prompt > 1, you have multiple output images. So, the behavior of save_img_path becomes undefined.

Plus there are other output formats we support too, such as "np", "pt", etc. So, its on the users how they wanna save it.

@patrickvonplaten
Copy link
Contributor

Strongly agree with @sayakpaul here. Let's try to not bloat the pipelines too much

@hi-sushanta hi-sushanta deleted the save_out branch December 27, 2023 00:33
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.

3 participants