huggingface / diffusers

🤗 Diffusers: State-of-the-art diffusion models for image and audio generation in PyTorch and FLAX.
https://huggingface.co/docs/diffusers
Apache License 2.0
25.04k stars 5.18k forks source link

Pixart Sigma pipeline forgets to specify the resolution microconditioning #8876

Closed AmericanPresidentJimmyCarter closed 1 month ago

AmericanPresidentJimmyCarter commented 1 month ago

Describe the bug

Pixart Alpha pipeline:

        # 6.1 Prepare micro-conditions.
        added_cond_kwargs = {"resolution": None, "aspect_ratio": None}
        if self.transformer.config.sample_size == 128:
            resolution = torch.tensor([height, width]).repeat(batch_size * num_images_per_prompt, 1)
            aspect_ratio = torch.tensor([float(height / width)]).repeat(batch_size * num_images_per_prompt, 1)
            resolution = resolution.to(dtype=prompt_embeds.dtype, device=device)
            aspect_ratio = aspect_ratio.to(dtype=prompt_embeds.dtype, device=device)

            if do_classifier_free_guidance:
                resolution = torch.cat([resolution, resolution], dim=0)
                aspect_ratio = torch.cat([aspect_ratio, aspect_ratio], dim=0)

            added_cond_kwargs = {"resolution": resolution, "aspect_ratio": aspect_ratio}

        # 7. Denoising loop

https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pixart_alpha/pipeline_pixart_alpha.py#L881C1-L893C89

Pixart Sigma pipeline:

        # 6.1 Prepare micro-conditions.
        added_cond_kwargs = {"resolution": None, "aspect_ratio": None}

        # 7. Denoising loop

https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pixart_alpha/pipeline_pixart_sigma.py#L807-L808C9

Reproduction

Run the pipeline.

Logs

No response

System Info

main, Linux

Who can help?

@yiyixuxu @DN6

DN6 commented 1 month ago

cc: @sayakpaul can you take a look here please?

sayakpaul commented 1 month ago

I don't think it uses micro-conditioning. The pipeline was contributed by the author himself @lawrence-cj. So, ccing him here.

AmericanPresidentJimmyCarter commented 1 month ago

It might be the case, it looks like it's unset in the reference code. I will close the issue for now and maybe @lawrence-cj can chime in later.

AmericanPresidentJimmyCarter commented 1 month ago

Reopening. The Pixart Sigma demo does use the microconditionings. https://huggingface.co/spaces/PixArt-alpha/PixArt-Sigma/blob/main/diffusers_patches.py#L357-L369

@lawrence-cj

AmericanPresidentJimmyCarter commented 1 month ago

Nevermind, I see this at the bottom: https://huggingface.co/spaces/PixArt-alpha/PixArt-Sigma/blob/main/diffusers_patches.py#L528-L535

lawrence-cj commented 1 month ago

Oh yes. The Sigma model doesn't use the micro-condition strategy.