Skip to content

Conversation

yiyixuxu
Copy link
Collaborator

@yiyixuxu yiyixuxu commented Oct 2, 2024

for 1920 X 1080 should get an input error and ask user to resize to 1920 x 1072 (on current main will get an error on scheduler step)

ValueError: `height` and `width` have to be divisible by 16 but are 1920 and 1080.You can use height 1920 and width 1072.
import torch
import argparse
from diffusers import StableDiffusion3Pipeline

def main(height, width):
    device = torch.device("cuda:1")

    pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16)
    pipe = pipe.to(device)
    generator = torch.Generator(device=device).manual_seed(0)

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

    print(f"{height}x{width} -> image: {image.size}")
    image.save(f"yiyi_test_1_out_{height}_{width}.png")

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Generate an image with Stable Diffusion 3")
    parser.add_argument("--height", type=int, default=1920, help="Height of the output image")
    parser.add_argument("--width", type=int, default=1080, help="Width of the output image")
    
    args = parser.parse_args()
    
    main(args.height, args.width)

@yiyixuxu yiyixuxu requested a review from asomoza October 2, 2024 21:15
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@asomoza asomoza left a comment

Choose a reason for hiding this comment

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

thanks, LGTM

@yiyixuxu yiyixuxu merged commit 99f6082 into main Oct 3, 2024
18 checks passed
@yiyixuxu yiyixuxu deleted the sd3-size branch October 3, 2024 18:36
leisuzz pushed a commit to leisuzz/diffusers that referenced this pull request Oct 11, 2024
sayakpaul pushed a commit that referenced this pull request Dec 23, 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

Successfully merging this pull request may close these issues.

3 participants