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

Support for stable-diffusion-3-medium model #8482

Closed
rupeshs opened this issue Jun 12, 2024 · 20 comments
Closed

Support for stable-diffusion-3-medium model #8482

rupeshs opened this issue Jun 12, 2024 · 20 comments

Comments

@rupeshs
Copy link

rupeshs commented Jun 12, 2024

Is your feature request related to a problem? Please describe.
No.

Describe the solution you'd like.
Support SD3 medium model (https://huggingface.co/stabilityai/stable-diffusion-3-medium).

Describe alternatives you've considered.
It seems like this PR(#7232) is stale

@sayakpaul
Copy link
Member

Coming up in some hours ;)

@tin2tin
Copy link

tin2tin commented Jun 12, 2024

@painebenjamin
Copy link
Contributor

https://huggingface.co/stabilityai/stable-diffusion-3-medium/commit/fc46bd4cf48394d33a813fe81f4241568cc8b85b

image

So, do we need to wait for an update of Diffusers?

At some point in the near future the SD3 branch will be merged into diffusers which will add support for it. See this pull request for details.

At the time of writing, diffusers-formatted weights (and control files like model_index.json) are not available at the huggingface repository, so even if you pull that branch, it will not work yet. Give it a few hours and that will likely change.

@sayakpaul
Copy link
Member

We will let everyone know once y'all are good to go. Till then, have patience :)

@Yakonrus
Copy link

It’s strange that Stability AI weren’t give you accessin advance

@tin2tin
Copy link

tin2tin commented Jun 12, 2024

The files for diffusers are up, but gated files will only be accessible from the Huggingface platform, as there is no way, afaik, to get access when running diffusers locally, and only downloading it with diffusers from HF.
https://huggingface.co/stabilityai/stable-diffusion-3-medium-diffusers

@painebenjamin
Copy link
Contributor

painebenjamin commented Jun 12, 2024

We can use the code from the HF space to run it without needing to use the repository that is gated behind SAI's approval. You will still need to be logged into Huggingface and request access to the first repository, but you shouldn't have to wait for approval.

pip install git+https://github.com/huggingface/diffusers.git@sd3

Then...

import torch
from diffusers import StableDiffusion3Pipeline

pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3-medium",
    revision="refs/pr/26",
    torch_dtype=torch.float16,
)
pipe.to("cuda")

image = pipe(
    prompt="a photo of a cat holding a sign that says hello world",
    negative_prompt="",
    num_inference_steps=28,
    height=1024,
    width=1024,
    guidance_scale=7.0,
).images[0]

image.save("sd3_hello_world.png")

Happy generating!

@haofanwang
Copy link
Contributor

You guys are awesome!

@rolux
Copy link

rolux commented Jun 12, 2024

Happy generating!

Thanks a lot!

@OlegRuban-ai
Copy link

1
Hello! Is it possible to do something with optimization? On Comfy it runs with 12 GB GPU, and with diffusers - 21.

@sayakpaul
Copy link
Member

Yeah. The documentation includes all optimization related bits :)

@tin2tin
Copy link

tin2tin commented Jun 12, 2024

Hmm... I can't get access to the gated files, even though I accepted everything, and I am logged in, but trying to access them from my local computer through Diffusers just doesn't remove the gate blocking. Neither does accessing a mirrored single file, I can download it, but because of the gate, it doesn't work. Gated files does not play well with Diffusers at all.

@s9anus98a
Copy link

We can use the code from the HF space to run it without needing to use the repository that is gated behind SAI's approval. You will still need to be logged into Huggingface and request access to the first repository, but you shouldn't have to wait for approval.

pip install git+https://github.com/huggingface/diffusers.git@sd3

Then...

import torch
from diffusers import StableDiffusion3Pipeline

pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3-medium",
    revision="refs/pr/26",
    torch_dtype=torch.float16,
)
pipe.to("cuda")

image = pipe(
    prompt="a photo of a cat holding a sign that says hello world",
    negative_prompt="",
    num_inference_steps=28,
    height=1024,
    width=1024,
    guidance_scale=7.0,
).images[0]

image.save("sd3_hello_world.png")

Happy generating!

can anyone run sd3 medium on colab free? i tried and it take out all the space. 78GB. WTF??

@7iFinalBoSS
Copy link

We can use the code from the HF space to run it without needing to use the repository that is gated behind SAI's approval. You will still need to be logged into Huggingface and request access to the first repository, but you shouldn't have to wait for approval.

pip install git+https://github.com/huggingface/diffusers.git@sd3

Then...

import torch
from diffusers import StableDiffusion3Pipeline

pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3-medium",
    revision="refs/pr/26",
    torch_dtype=torch.float16,
)
pipe.to("cuda")

image = pipe(
    prompt="a photo of a cat holding a sign that says hello world",
    negative_prompt="",
    num_inference_steps=28,
    height=1024,
    width=1024,
    guidance_scale=7.0,
).images[0]

image.save("sd3_hello_world.png")

Happy generating!

can anyone run sd3 medium on colab free? i tried and it take out all the space. 78GB. WTF??

share your colab link...!

@rohitgandikota
Copy link

We can use the code from the HF space to run it without needing to use the repository that is gated behind SAI's approval. You will still need to be logged into Huggingface and request access to the first repository, but you shouldn't have to wait for approval.

pip install git+https://github.com/huggingface/diffusers.git@sd3

Then...

import torch
from diffusers import StableDiffusion3Pipeline

pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3-medium",
    revision="refs/pr/26",
    torch_dtype=torch.float16,
)
pipe.to("cuda")

image = pipe(
    prompt="a photo of a cat holding a sign that says hello world",
    negative_prompt="",
    num_inference_steps=28,
    height=1024,
    width=1024,
    guidance_scale=7.0,
).images[0]

image.save("sd3_hello_world.png")

Happy generating!

can anyone run sd3 medium on colab free? i tried and it take out all the space. 78GB. WTF??

I am trying locally and it takes around 20GB with float16 precision - you can go even low with bfloat16!

@rolux
Copy link

rolux commented Jun 12, 2024

Yeah. The documentation includes all optimization related bits :)

Currently, loading the T5 text encoder separately fails with

OSError: stabilityai/stable-diffusion-3-medium-diffusers does not appear to have a file named text_encoder_3/model-00004-of-00004.safetensors. Checkout 'https://huggingface.co/stabilityai/stable-diffusion-3-medium-diffusers/tree/main' for available files.

... but you're probably aware of that ;)

@rolux
Copy link

rolux commented Jun 12, 2024

Yeah. The documentation includes all optimization related bits :)

Currently, loading the T5 text encoder separately fails with

OSError: stabilityai/stable-diffusion-3-medium-diffusers does not appear to have a file named text_encoder_3/model-00004-of-00004.safetensors. Checkout 'https://huggingface.co/stabilityai/stable-diffusion-3-medium-diffusers/tree/main' for available files.

... but you're probably aware of that ;)

Seems to be fixed in the latest revision.

@s9anus98a
Copy link

what happen to sd3 model?

prompt: photo of a young woman with long, wavy brown hair lying down in grass, top down shot, summer, warm, laughing, joy, fun,

Untitled

@rupeshs
Copy link
Author

rupeshs commented Jun 13, 2024

@OlegRuban-ai Try SD3 for low VRAM systems: https://github.com/rupeshs/sd3-low-vram

sd3-lowvram

@DN6
Copy link
Collaborator

DN6 commented Jul 1, 2024

Closing as completed.

@DN6 DN6 closed this as completed Jul 1, 2024
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

No branches or pull requests