Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 47ee2a737a | |||
| e0e9f81971 | |||
| 5d848ec07c | |||
| 94fc2d3fe6 | |||
| 503e359204 |
@@ -52,7 +52,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -U setuptools wheel twine
|
pip install -U setuptools wheel twine torch
|
||||||
|
|
||||||
- name: Build the dist files
|
- name: Build the dist files
|
||||||
run: python setup.py bdist_wheel && python setup.py sdist
|
run: python setup.py bdist_wheel && python setup.py sdist
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ Please refer to the [How to use Stable Diffusion in Apple Silicon](https://huggi
|
|||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
|
|
||||||
Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the `from_pretrained` method to load any pretrained diffusion model (browse the [Hub](https://huggingface.co/models?library=diffusers&sort=downloads) for 19000+ checkpoints):
|
Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the `from_pretrained` method to load any pretrained diffusion model (browse the [Hub](https://huggingface.co/models?library=diffusers&sort=downloads) for 22000+ checkpoints):
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from diffusers import DiffusionPipeline
|
from diffusers import DiffusionPipeline
|
||||||
@@ -219,7 +219,7 @@ Also, say 👋 in our public Discord channel <a href="https://discord.gg/G7tWnz9
|
|||||||
- https://github.com/deep-floyd/IF
|
- https://github.com/deep-floyd/IF
|
||||||
- https://github.com/bentoml/BentoML
|
- https://github.com/bentoml/BentoML
|
||||||
- https://github.com/bmaltais/kohya_ss
|
- https://github.com/bmaltais/kohya_ss
|
||||||
- +8000 other amazing GitHub repositories 💪
|
- +9000 other amazing GitHub repositories 💪
|
||||||
|
|
||||||
Thank you for using us ❤️.
|
Thank you for using us ❤️.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -637,7 +637,7 @@ def main(args):
|
|||||||
generator=generator,
|
generator=generator,
|
||||||
batch_size=args.eval_batch_size,
|
batch_size=args.eval_batch_size,
|
||||||
num_inference_steps=args.ddpm_num_inference_steps,
|
num_inference_steps=args.ddpm_num_inference_steps,
|
||||||
output_type="numpy",
|
output_type="np",
|
||||||
).images
|
).images
|
||||||
|
|
||||||
if args.use_ema:
|
if args.use_ema:
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ def main(args):
|
|||||||
generator=generator,
|
generator=generator,
|
||||||
batch_size=args.eval_batch_size,
|
batch_size=args.eval_batch_size,
|
||||||
num_inference_steps=args.ddpm_num_inference_steps,
|
num_inference_steps=args.ddpm_num_inference_steps,
|
||||||
output_type="numpy",
|
output_type="np",
|
||||||
).images
|
).images
|
||||||
|
|
||||||
if args.use_ema:
|
if args.use_ema:
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class BasicTransformerBlock(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
# Notice that normalization is always applied before the real computation in the following blocks.
|
# Notice that normalization is always applied before the real computation in the following blocks.
|
||||||
# 0. Self-Attention
|
# 0. Self-Attention
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class Transformer2DModel(ModelMixin, ConfigMixin):
|
|||||||
"""
|
"""
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
# ensure attention_mask is a bias, and give it a singleton query_tokens dimension.
|
# ensure attention_mask is a bias, and give it a singleton query_tokens dimension.
|
||||||
# we may have done this conversion already, e.g. if we came here via UNet2DConditionModel#forward.
|
# we may have done this conversion already, e.g. if we came here via UNet2DConditionModel#forward.
|
||||||
# we can tell by counting dims; if ndim == 2: it's a mask rather than a bias.
|
# we can tell by counting dims; if ndim == 2: it's a mask rather than a bias.
|
||||||
|
|||||||
@@ -846,7 +846,7 @@ class UNetMidBlock2DCrossAttn(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
hidden_states = self.resnets[0](hidden_states, temb)
|
hidden_states = self.resnets[0](hidden_states, temb)
|
||||||
for attn, resnet in zip(self.attentions, self.resnets[1:]):
|
for attn, resnet in zip(self.attentions, self.resnets[1:]):
|
||||||
@@ -986,7 +986,7 @@ class UNetMidBlock2DSimpleCrossAttn(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
if attention_mask is None:
|
if attention_mask is None:
|
||||||
# if encoder_hidden_states is defined: we are doing cross-attn, so we should use cross-attn mask.
|
# if encoder_hidden_states is defined: we are doing cross-attn, so we should use cross-attn mask.
|
||||||
@@ -1116,7 +1116,7 @@ class AttnDownBlock2D(nn.Module):
|
|||||||
) -> Tuple[torch.FloatTensor, Tuple[torch.FloatTensor, ...]]:
|
) -> Tuple[torch.FloatTensor, Tuple[torch.FloatTensor, ...]]:
|
||||||
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
output_states = ()
|
output_states = ()
|
||||||
|
|
||||||
@@ -1241,7 +1241,7 @@ class CrossAttnDownBlock2D(nn.Module):
|
|||||||
) -> Tuple[torch.FloatTensor, Tuple[torch.FloatTensor, ...]]:
|
) -> Tuple[torch.FloatTensor, Tuple[torch.FloatTensor, ...]]:
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
output_states = ()
|
output_states = ()
|
||||||
|
|
||||||
@@ -1986,7 +1986,7 @@ class SimpleCrossAttnDownBlock2D(nn.Module):
|
|||||||
) -> Tuple[torch.FloatTensor, Tuple[torch.FloatTensor, ...]]:
|
) -> Tuple[torch.FloatTensor, Tuple[torch.FloatTensor, ...]]:
|
||||||
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
output_states = ()
|
output_states = ()
|
||||||
|
|
||||||
@@ -2201,7 +2201,7 @@ class KCrossAttnDownBlock2D(nn.Module):
|
|||||||
) -> Tuple[torch.FloatTensor, Tuple[torch.FloatTensor, ...]]:
|
) -> Tuple[torch.FloatTensor, Tuple[torch.FloatTensor, ...]]:
|
||||||
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
output_states = ()
|
output_states = ()
|
||||||
|
|
||||||
@@ -2483,7 +2483,7 @@ class CrossAttnUpBlock2D(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
is_freeu_enabled = (
|
is_freeu_enabled = (
|
||||||
getattr(self, "s1", None)
|
getattr(self, "s1", None)
|
||||||
@@ -3312,7 +3312,7 @@ class SimpleCrossAttnUpBlock2D(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
if attention_mask is None:
|
if attention_mask is None:
|
||||||
# if encoder_hidden_states is defined: we are doing cross-attn, so we should use cross-attn mask.
|
# if encoder_hidden_states is defined: we are doing cross-attn, so we should use cross-attn mask.
|
||||||
@@ -3694,7 +3694,7 @@ class KAttentionBlock(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
# 1. Self-Attention
|
# 1. Self-Attention
|
||||||
if self.add_self_attention:
|
if self.add_self_attention:
|
||||||
|
|||||||
@@ -1183,7 +1183,7 @@ class CrossAttnDownBlockMotion(nn.Module):
|
|||||||
):
|
):
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
output_states = ()
|
output_states = ()
|
||||||
|
|
||||||
@@ -1367,7 +1367,7 @@ class CrossAttnUpBlockMotion(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
is_freeu_enabled = (
|
is_freeu_enabled = (
|
||||||
getattr(self, "s1", None)
|
getattr(self, "s1", None)
|
||||||
@@ -1707,7 +1707,7 @@ class UNetMidBlockCrossAttnMotion(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
hidden_states = self.resnets[0](hidden_states, temb)
|
hidden_states = self.resnets[0](hidden_states, temb)
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class AmusedImg2ImgPipeline(DiffusionPipeline):
|
|||||||
on the amount of noise initially added. When `strength` is 1, added noise is maximum and the denoising
|
on the amount of noise initially added. When `strength` is 1, added noise is maximum and the denoising
|
||||||
process runs for the full number of iterations specified in `num_inference_steps`. A value of 1
|
process runs for the full number of iterations specified in `num_inference_steps`. A value of 1
|
||||||
essentially ignores `image`.
|
essentially ignores `image`.
|
||||||
num_inference_steps (`int`, *optional*, defaults to 16):
|
num_inference_steps (`int`, *optional*, defaults to 12):
|
||||||
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
|
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
|
||||||
expense of slower inference.
|
expense of slower inference.
|
||||||
guidance_scale (`float`, *optional*, defaults to 10.0):
|
guidance_scale (`float`, *optional*, defaults to 10.0):
|
||||||
@@ -191,7 +191,7 @@ class AmusedImg2ImgPipeline(DiffusionPipeline):
|
|||||||
negative_prompt_embeds is None and negative_encoder_hidden_states is not None
|
negative_prompt_embeds is None and negative_encoder_hidden_states is not None
|
||||||
):
|
):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"pass either both `negatve_prompt_embeds` and `negative_encoder_hidden_states` or neither"
|
"pass either both `negative_prompt_embeds` and `negative_encoder_hidden_states` or neither"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (prompt is None and prompt_embeds is None) or (prompt is not None and prompt_embeds is not None):
|
if (prompt is None and prompt_embeds is None) or (prompt is not None and prompt_embeds is not None):
|
||||||
|
|||||||
@@ -824,20 +824,22 @@ class StableDiffusionControlNetPipeline(
|
|||||||
return latents
|
return latents
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -869,20 +869,22 @@ class StableDiffusionXLControlNetPipeline(
|
|||||||
self.vae.decoder.mid_block.to(dtype)
|
self.vae.decoder.mid_block.to(dtype)
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
+5
-5
@@ -133,7 +133,7 @@ class SpectrogramDiffusionPipeline(DiffusionPipeline):
|
|||||||
generator: Optional[torch.Generator] = None,
|
generator: Optional[torch.Generator] = None,
|
||||||
num_inference_steps: int = 100,
|
num_inference_steps: int = 100,
|
||||||
return_dict: bool = True,
|
return_dict: bool = True,
|
||||||
output_type: str = "numpy",
|
output_type: str = "np",
|
||||||
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
|
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
|
||||||
callback_steps: int = 1,
|
callback_steps: int = 1,
|
||||||
) -> Union[AudioPipelineOutput, Tuple]:
|
) -> Union[AudioPipelineOutput, Tuple]:
|
||||||
@@ -157,7 +157,7 @@ class SpectrogramDiffusionPipeline(DiffusionPipeline):
|
|||||||
expense of slower inference.
|
expense of slower inference.
|
||||||
return_dict (`bool`, *optional*, defaults to `True`):
|
return_dict (`bool`, *optional*, defaults to `True`):
|
||||||
Whether or not to return a [`~pipelines.AudioPipelineOutput`] instead of a plain tuple.
|
Whether or not to return a [`~pipelines.AudioPipelineOutput`] instead of a plain tuple.
|
||||||
output_type (`str`, *optional*, defaults to `"numpy"`):
|
output_type (`str`, *optional*, defaults to `"np"`):
|
||||||
The output format of the generated audio.
|
The output format of the generated audio.
|
||||||
callback (`Callable`, *optional*):
|
callback (`Callable`, *optional*):
|
||||||
A function that calls every `callback_steps` steps during inference. The function is called with the
|
A function that calls every `callback_steps` steps during inference. The function is called with the
|
||||||
@@ -249,16 +249,16 @@ class SpectrogramDiffusionPipeline(DiffusionPipeline):
|
|||||||
|
|
||||||
logger.info("Generated segment", i)
|
logger.info("Generated segment", i)
|
||||||
|
|
||||||
if output_type == "numpy" and not is_onnx_available():
|
if output_type == "np" and not is_onnx_available():
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Cannot return output in 'np' format if ONNX is not available. Make sure to have ONNX installed or set 'output_type' to 'mel'."
|
"Cannot return output in 'np' format if ONNX is not available. Make sure to have ONNX installed or set 'output_type' to 'mel'."
|
||||||
)
|
)
|
||||||
elif output_type == "numpy" and self.melgan is None:
|
elif output_type == "np" and self.melgan is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Cannot return output in 'np' format if melgan component is not defined. Make sure to define `self.melgan` or set 'output_type' to 'mel'."
|
"Cannot return output in 'np' format if melgan component is not defined. Make sure to define `self.melgan` or set 'output_type' to 'mel'."
|
||||||
)
|
)
|
||||||
|
|
||||||
if output_type == "numpy":
|
if output_type == "np":
|
||||||
output = self.melgan(input_features=full_pred_mel.astype(np.float32))
|
output = self.melgan(input_features=full_pred_mel.astype(np.float32))
|
||||||
else:
|
else:
|
||||||
output = full_pred_mel
|
output = full_pred_mel
|
||||||
|
|||||||
@@ -2004,7 +2004,7 @@ class CrossAttnUpBlockFlat(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
is_freeu_enabled = (
|
is_freeu_enabled = (
|
||||||
getattr(self, "s1", None)
|
getattr(self, "s1", None)
|
||||||
@@ -2338,7 +2338,7 @@ class UNetMidBlockFlatCrossAttn(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
if cross_attention_kwargs is not None:
|
if cross_attention_kwargs is not None:
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
hidden_states = self.resnets[0](hidden_states, temb)
|
hidden_states = self.resnets[0](hidden_states, temb)
|
||||||
for attn, resnet in zip(self.attentions, self.resnets[1:]):
|
for attn, resnet in zip(self.attentions, self.resnets[1:]):
|
||||||
@@ -2479,7 +2479,7 @@ class UNetMidBlockFlatSimpleCrossAttn(nn.Module):
|
|||||||
) -> torch.FloatTensor:
|
) -> torch.FloatTensor:
|
||||||
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
cross_attention_kwargs = cross_attention_kwargs if cross_attention_kwargs is not None else {}
|
||||||
if cross_attention_kwargs.get("scale", None) is not None:
|
if cross_attention_kwargs.get("scale", None) is not None:
|
||||||
logger.warning("Passing `scale` to `cross_attention_kwargs` is depcrecated. `scale` will be ignored.")
|
logger.warning("Passing `scale` to `cross_attention_kwargs` is deprecated. `scale` will be ignored.")
|
||||||
|
|
||||||
if attention_mask is None:
|
if attention_mask is None:
|
||||||
# if encoder_hidden_states is defined: we are doing cross-attn, so we should use cross-attn mask.
|
# if encoder_hidden_states is defined: we are doing cross-attn, so we should use cross-attn mask.
|
||||||
|
|||||||
+9
-7
@@ -548,20 +548,22 @@ class LatentConsistencyModelImg2ImgPipeline(
|
|||||||
return latents
|
return latents
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
+9
-7
@@ -490,20 +490,22 @@ class LatentConsistencyModelPipeline(
|
|||||||
latents = latents * self.scheduler.init_noise_sigma
|
latents = latents * self.scheduler.init_noise_sigma
|
||||||
return latents
|
return latents
|
||||||
|
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -713,20 +713,22 @@ class LEditsPPPipelineStableDiffusionXL(
|
|||||||
self.vae.decoder.mid_block.to(dtype)
|
self.vae.decoder.mid_block.to(dtype)
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -669,20 +669,22 @@ class StableDiffusionPipeline(
|
|||||||
return latents
|
return latents
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -767,20 +767,22 @@ class StableDiffusionImg2ImgPipeline(
|
|||||||
return latents
|
return latents
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -909,20 +909,22 @@ class StableDiffusionInpaintPipeline(
|
|||||||
return timesteps, num_inference_steps - t_start
|
return timesteps, num_inference_steps - t_start
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
+2
-2
@@ -1304,7 +1304,7 @@ class StableDiffusionDiffEditPipeline(
|
|||||||
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
|
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
|
||||||
callback_steps: int = 1,
|
callback_steps: int = 1,
|
||||||
cross_attention_kwargs: Optional[Dict[str, Any]] = None,
|
cross_attention_kwargs: Optional[Dict[str, Any]] = None,
|
||||||
clip_ckip: int = None,
|
clip_skip: int = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
The call function to the pipeline for generation.
|
The call function to the pipeline for generation.
|
||||||
@@ -1426,7 +1426,7 @@ class StableDiffusionDiffEditPipeline(
|
|||||||
prompt_embeds=prompt_embeds,
|
prompt_embeds=prompt_embeds,
|
||||||
negative_prompt_embeds=negative_prompt_embeds,
|
negative_prompt_embeds=negative_prompt_embeds,
|
||||||
lora_scale=text_encoder_lora_scale,
|
lora_scale=text_encoder_lora_scale,
|
||||||
clip_skip=clip_ckip,
|
clip_skip=clip_skip,
|
||||||
)
|
)
|
||||||
# For classifier free guidance, we need to do two forward passes.
|
# For classifier free guidance, we need to do two forward passes.
|
||||||
# Here we concatenate the unconditional and text embeddings into a single batch
|
# Here we concatenate the unconditional and text embeddings into a single batch
|
||||||
|
|||||||
@@ -644,20 +644,22 @@ class StableDiffusionLDM3DPipeline(
|
|||||||
return latents
|
return latents
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -632,7 +632,7 @@ class StableDiffusionSAGPipeline(DiffusionPipeline, StableDiffusionMixin, Textua
|
|||||||
# corresponds to doing no classifier free guidance.
|
# corresponds to doing no classifier free guidance.
|
||||||
do_classifier_free_guidance = guidance_scale > 1.0
|
do_classifier_free_guidance = guidance_scale > 1.0
|
||||||
# and `sag_scale` is` `s` of equation (16)
|
# and `sag_scale` is` `s` of equation (16)
|
||||||
# of the self-attentnion guidance paper: https://arxiv.org/pdf/2210.00939.pdf
|
# of the self-attention guidance paper: https://arxiv.org/pdf/2210.00939.pdf
|
||||||
# `sag_scale = 0` means no self-attention guidance
|
# `sag_scale = 0` means no self-attention guidance
|
||||||
do_self_attention_guidance = sag_scale > 0.0
|
do_self_attention_guidance = sag_scale > 0.0
|
||||||
|
|
||||||
@@ -667,7 +667,7 @@ class StableDiffusionSAGPipeline(DiffusionPipeline, StableDiffusionMixin, Textua
|
|||||||
|
|
||||||
if timesteps.dtype not in [torch.int16, torch.int32, torch.int64]:
|
if timesteps.dtype not in [torch.int16, torch.int32, torch.int64]:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"{self.__class__.__name__} does not support using a scheduler of type {self.scheduler.__class__.__name__}. Please make sure to use one of 'DDIMScheduler, PNDMScheduler, DDPMScheduler, DEISMultistepScheduler, UniPCMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinlgestepScheduler'."
|
f"{self.__class__.__name__} does not support using a scheduler of type {self.scheduler.__class__.__name__}. Please make sure to use one of 'DDIMScheduler, PNDMScheduler, DDPMScheduler, DEISMultistepScheduler, UniPCMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler'."
|
||||||
)
|
)
|
||||||
|
|
||||||
# 5. Prepare latent variables
|
# 5. Prepare latent variables
|
||||||
@@ -723,7 +723,7 @@ class StableDiffusionSAGPipeline(DiffusionPipeline, StableDiffusionMixin, Textua
|
|||||||
noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
|
noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
|
||||||
noise_pred = noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
|
noise_pred = noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
|
||||||
|
|
||||||
# perform self-attention guidance with the stored self-attentnion map
|
# perform self-attention guidance with the stored self-attention map
|
||||||
if do_self_attention_guidance:
|
if do_self_attention_guidance:
|
||||||
# classifier-free guidance produces two chunks of attention map
|
# classifier-free guidance produces two chunks of attention map
|
||||||
# and we only use unconditional one according to equation (25)
|
# and we only use unconditional one according to equation (25)
|
||||||
|
|||||||
@@ -740,20 +740,22 @@ class StableDiffusionXLPipeline(
|
|||||||
self.vae.decoder.mid_block.to(dtype)
|
self.vae.decoder.mid_block.to(dtype)
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -874,20 +874,22 @@ class StableDiffusionXLImg2ImgPipeline(
|
|||||||
self.vae.decoder.mid_block.to(dtype)
|
self.vae.decoder.mid_block.to(dtype)
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -1110,20 +1110,22 @@ class StableDiffusionXLInpaintPipeline(
|
|||||||
self.vae.decoder.mid_block.to(dtype)
|
self.vae.decoder.mid_block.to(dtype)
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -613,20 +613,22 @@ class StableDiffusionAdapterPipeline(DiffusionPipeline, StableDiffusionMixin):
|
|||||||
return height, width
|
return height, width
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -784,20 +784,22 @@ class StableDiffusionXLAdapterPipeline(
|
|||||||
return height, width
|
return height, width
|
||||||
|
|
||||||
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
||||||
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
def get_guidance_scale_embedding(
|
||||||
|
self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
|
||||||
|
) -> torch.FloatTensor:
|
||||||
"""
|
"""
|
||||||
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
timesteps (`torch.Tensor`):
|
w (`torch.Tensor`):
|
||||||
generate embedding vectors at these timesteps
|
Generate embedding vectors with a specified guidance scale to subsequently enrich timestep embeddings.
|
||||||
embedding_dim (`int`, *optional*, defaults to 512):
|
embedding_dim (`int`, *optional*, defaults to 512):
|
||||||
dimension of the embeddings to generate
|
Dimension of the embeddings to generate.
|
||||||
dtype:
|
dtype (`torch.dtype`, *optional*, defaults to `torch.float32`):
|
||||||
data type of the generated embeddings
|
Data type of the generated embeddings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
|
`torch.FloatTensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
|
||||||
"""
|
"""
|
||||||
assert len(w.shape) == 1
|
assert len(w.shape) == 1
|
||||||
w = w * 1000.0
|
w = w * 1000.0
|
||||||
|
|||||||
@@ -575,8 +575,8 @@ class TextToVideoZeroPipeline(DiffusionPipeline, StableDiffusionMixin, TextualIn
|
|||||||
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for video
|
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for video
|
||||||
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
|
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
|
||||||
tensor is generated by sampling using the supplied random `generator`.
|
tensor is generated by sampling using the supplied random `generator`.
|
||||||
output_type (`str`, *optional*, defaults to `"numpy"`):
|
output_type (`str`, *optional*, defaults to `"np"`):
|
||||||
The output format of the generated video. Choose between `"latent"` and `"numpy"`.
|
The output format of the generated video. Choose between `"latent"` and `"np"`.
|
||||||
return_dict (`bool`, *optional*, defaults to `True`):
|
return_dict (`bool`, *optional*, defaults to `True`):
|
||||||
Whether or not to return a
|
Whether or not to return a
|
||||||
[`~pipelines.text_to_video_synthesis.pipeline_text_to_video_zero.TextToVideoPipelineOutput`] instead of
|
[`~pipelines.text_to_video_synthesis.pipeline_text_to_video_zero.TextToVideoPipelineOutput`] instead of
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class ControlNetPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": image,
|
"image": image,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ class StableDiffusionMultiControlNetPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": images,
|
"image": images,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,7 +602,7 @@ class StableDiffusionMultiControlNetOneModelPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": images,
|
"image": images,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1092,6 +1092,13 @@ class ControlNetPipelineSlowTests(unittest.TestCase):
|
|||||||
for param_name, param_value in single_file_pipe.controlnet.config.items():
|
for param_name, param_value in single_file_pipe.controlnet.config.items():
|
||||||
if param_name in PARAMS_TO_IGNORE:
|
if param_name in PARAMS_TO_IGNORE:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# This parameter doesn't appear to be loaded from the config.
|
||||||
|
# So when it is registered to config, it remains a tuple as this is the default in the class definition
|
||||||
|
# from_pretrained, does load from config and converts to a list when registering to config
|
||||||
|
if param_name == "conditioning_embedding_out_channels" and isinstance(param_value, tuple):
|
||||||
|
param_value = list(param_value)
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
pipe.controlnet.config[param_name] == param_value
|
pipe.controlnet.config[param_name] == param_value
|
||||||
), f"{param_name} differs between single file loading and pretrained loading"
|
), f"{param_name} differs between single file loading and pretrained loading"
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class ControlNetImg2ImgPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": image,
|
"image": image,
|
||||||
"control_image": control_image,
|
"control_image": control_image,
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ class StableDiffusionMultiControlNetPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": image,
|
"image": image,
|
||||||
"control_image": control_image,
|
"control_image": control_image,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class ControlNetInpaintPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": image,
|
"image": image,
|
||||||
"mask_image": mask_image,
|
"mask_image": mask_image,
|
||||||
"control_image": control_image,
|
"control_image": control_image,
|
||||||
@@ -375,7 +375,7 @@ class MultiControlNetInpaintPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": image,
|
"image": image,
|
||||||
"mask_image": mask_image,
|
"mask_image": mask_image,
|
||||||
"control_image": control_image,
|
"control_image": control_image,
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ class ControlNetPipelineSDXLFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": init_image,
|
"image": init_image,
|
||||||
"mask_image": mask_image,
|
"mask_image": mask_image,
|
||||||
"control_image": control_image,
|
"control_image": control_image,
|
||||||
|
|||||||
@@ -1002,6 +1002,11 @@ class ControlNetSDXLPipelineSlowTests(unittest.TestCase):
|
|||||||
for param_name, param_value in single_file_pipe.unet.config.items():
|
for param_name, param_value in single_file_pipe.unet.config.items():
|
||||||
if param_name in PARAMS_TO_IGNORE:
|
if param_name in PARAMS_TO_IGNORE:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Upcast attention might be set to None in a config file, which is incorrect. It should default to False in the model
|
||||||
|
if param_name == "upcast_attention" and pipe.unet.config[param_name] is None:
|
||||||
|
pipe.unet.config[param_name] = False
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
pipe.unet.config[param_name] == param_value
|
pipe.unet.config[param_name] == param_value
|
||||||
), f"{param_name} differs between single file loading and pretrained loading"
|
), f"{param_name} differs between single file loading and pretrained loading"
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class ControlNetPipelineSDXLImg2ImgFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"image": image,
|
"image": image,
|
||||||
"control_image": image,
|
"control_image": image,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class DDIMPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
|||||||
"batch_size": 1,
|
"batch_size": 1,
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ class DDIMPipelineIntegrationTests(unittest.TestCase):
|
|||||||
ddim.set_progress_bar_config(disable=None)
|
ddim.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image = ddim(generator=generator, eta=0.0, output_type="numpy").images
|
image = ddim(generator=generator, eta=0.0, output_type="np").images
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ class DDIMPipelineIntegrationTests(unittest.TestCase):
|
|||||||
ddpm.set_progress_bar_config(disable=None)
|
ddpm.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image = ddpm(generator=generator, output_type="numpy").images
|
image = ddpm(generator=generator, output_type="np").images
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ class DDPMPipelineFastTests(unittest.TestCase):
|
|||||||
ddpm.set_progress_bar_config(disable=None)
|
ddpm.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.Generator(device=device).manual_seed(0)
|
generator = torch.Generator(device=device).manual_seed(0)
|
||||||
image = ddpm(generator=generator, num_inference_steps=2, output_type="numpy").images
|
image = ddpm(generator=generator, num_inference_steps=2, output_type="np").images
|
||||||
|
|
||||||
generator = torch.Generator(device=device).manual_seed(0)
|
generator = torch.Generator(device=device).manual_seed(0)
|
||||||
image_from_tuple = ddpm(generator=generator, num_inference_steps=2, output_type="numpy", return_dict=False)[0]
|
image_from_tuple = ddpm(generator=generator, num_inference_steps=2, output_type="np", return_dict=False)[0]
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
image_from_tuple_slice = image_from_tuple[0, -3:, -3:, -1]
|
image_from_tuple_slice = image_from_tuple[0, -3:, -3:, -1]
|
||||||
@@ -75,10 +75,10 @@ class DDPMPipelineFastTests(unittest.TestCase):
|
|||||||
ddpm.set_progress_bar_config(disable=None)
|
ddpm.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image = ddpm(generator=generator, num_inference_steps=2, output_type="numpy").images
|
image = ddpm(generator=generator, num_inference_steps=2, output_type="np").images
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image_eps = ddpm(generator=generator, num_inference_steps=2, output_type="numpy")[0]
|
image_eps = ddpm(generator=generator, num_inference_steps=2, output_type="np")[0]
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
image_eps_slice = image_eps[0, -3:, -3:, -1]
|
image_eps_slice = image_eps[0, -3:, -3:, -1]
|
||||||
@@ -102,7 +102,7 @@ class DDPMPipelineIntegrationTests(unittest.TestCase):
|
|||||||
ddpm.set_progress_bar_config(disable=None)
|
ddpm.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image = ddpm(generator=generator, output_type="numpy").images
|
image = ddpm(generator=generator, output_type="np").images
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class IFPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin, unittest.T
|
|||||||
"prompt": "A painting of a squirrel eating a burger",
|
"prompt": "A painting of a squirrel eating a burger",
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class IFImg2ImgPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin, uni
|
|||||||
"image": image,
|
"image": image,
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class IFImg2ImgSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipelineT
|
|||||||
"original_image": original_image,
|
"original_image": original_image,
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class IFInpaintingPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin,
|
|||||||
"mask_image": mask_image,
|
"mask_image": mask_image,
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class IFInpaintingSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipeli
|
|||||||
"mask_image": mask_image,
|
"mask_image": mask_image,
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class IFSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMi
|
|||||||
"image": image,
|
"image": image,
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class DiTPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
|||||||
"class_labels": [1],
|
"class_labels": [1],
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class LDMTextToImagePipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ class LDMTextToImagePipelineSlowTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ class LDMTextToImagePipelineNightlyTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 50,
|
"num_inference_steps": 50,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class LDMSuperResolutionPipelineFastTests(unittest.TestCase):
|
|||||||
init_image = self.dummy_image.to(device)
|
init_image = self.dummy_image.to(device)
|
||||||
|
|
||||||
generator = torch.Generator(device=device).manual_seed(0)
|
generator = torch.Generator(device=device).manual_seed(0)
|
||||||
image = ldm(image=init_image, generator=generator, num_inference_steps=2, output_type="numpy").images
|
image = ldm(image=init_image, generator=generator, num_inference_steps=2, output_type="np").images
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class LDMSuperResolutionPipelineFastTests(unittest.TestCase):
|
|||||||
|
|
||||||
init_image = self.dummy_image.to(torch_device)
|
init_image = self.dummy_image.to(torch_device)
|
||||||
|
|
||||||
image = ldm(init_image, num_inference_steps=2, output_type="numpy").images
|
image = ldm(init_image, num_inference_steps=2, output_type="np").images
|
||||||
|
|
||||||
assert image.shape == (1, 64, 64, 3)
|
assert image.shape == (1, 64, 64, 3)
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class LDMSuperResolutionPipelineIntegrationTests(unittest.TestCase):
|
|||||||
ldm.set_progress_bar_config(disable=None)
|
ldm.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image = ldm(image=init_image, generator=generator, num_inference_steps=20, output_type="numpy").images
|
image = ldm(image=init_image, generator=generator, num_inference_steps=20, output_type="np").images
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class PaintByExamplePipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ class PNDMPipelineFastTests(unittest.TestCase):
|
|||||||
pndm.set_progress_bar_config(disable=None)
|
pndm.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image = pndm(generator=generator, num_inference_steps=20, output_type="numpy").images
|
image = pndm(generator=generator, num_inference_steps=20, output_type="np").images
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image_from_tuple = pndm(generator=generator, num_inference_steps=20, output_type="numpy", return_dict=False)[0]
|
image_from_tuple = pndm(generator=generator, num_inference_steps=20, output_type="np", return_dict=False)[0]
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
image_from_tuple_slice = image_from_tuple[0, -3:, -3:, -1]
|
image_from_tuple_slice = image_from_tuple[0, -3:, -3:, -1]
|
||||||
@@ -77,7 +77,7 @@ class PNDMPipelineIntegrationTests(unittest.TestCase):
|
|||||||
pndm.to(torch_device)
|
pndm.to(torch_device)
|
||||||
pndm.set_progress_bar_config(disable=None)
|
pndm.set_progress_bar_config(disable=None)
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image = pndm(generator=generator, output_type="numpy").images
|
image = pndm(generator=generator, output_type="np").images
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class OnnxStableDiffusionPipelineFastTests(OnnxPipelineTesterMixin, unittest.Tes
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class OnnxStableDiffusionImg2ImgPipelineFastTests(OnnxPipelineTesterMixin, unitt
|
|||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"strength": 0.75,
|
"strength": 0.75,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class OnnxStableDiffusionUpscalePipelineFastTests(OnnxPipelineTesterMixin, unitt
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -775,7 +775,7 @@ class StableDiffusionPipelineSlowTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -950,7 +950,7 @@ class StableDiffusionPipelineSlowTests(unittest.TestCase):
|
|||||||
generator=generator,
|
generator=generator,
|
||||||
guidance_scale=7.5,
|
guidance_scale=7.5,
|
||||||
num_inference_steps=2,
|
num_inference_steps=2,
|
||||||
output_type="numpy",
|
output_type="np",
|
||||||
)
|
)
|
||||||
image_chunked = output_chunked.images
|
image_chunked = output_chunked.images
|
||||||
|
|
||||||
@@ -966,7 +966,7 @@ class StableDiffusionPipelineSlowTests(unittest.TestCase):
|
|||||||
generator=generator,
|
generator=generator,
|
||||||
guidance_scale=7.5,
|
guidance_scale=7.5,
|
||||||
num_inference_steps=2,
|
num_inference_steps=2,
|
||||||
output_type="numpy",
|
output_type="np",
|
||||||
)
|
)
|
||||||
image = output.images
|
image = output.images
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ class StableDiffusionImg2ImgPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class StableDiffusionInpaintPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ class StableDiffusionSimpleInpaintPipelineFastTests(StableDiffusionInpaintPipeli
|
|||||||
"generator": [generator1, generator2],
|
"generator": [generator1, generator2],
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -586,7 +586,7 @@ class StableDiffusionInpaintPipelineSlowTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -847,7 +847,7 @@ class StableDiffusionInpaintPipelineAsymmetricAutoencoderKLSlowTests(unittest.Te
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -1072,7 +1072,7 @@ class StableDiffusionInpaintPipelineNightlyTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 50,
|
"num_inference_steps": 50,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class StableDiffusionInstructPix2PixPipelineFastTests(
|
|||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"image_guidance_scale": 1,
|
"image_guidance_scale": 1,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ class StableDiffusionInstructPix2PixPipelineSlowTests(unittest.TestCase):
|
|||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"image_guidance_scale": 1.0,
|
"image_guidance_scale": 1.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class StableDiffusion2PipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ class StableDiffusion2PipelineSlowTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -557,7 +557,7 @@ class StableDiffusion2PipelineNightlyTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 50,
|
"num_inference_steps": 50,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class StableDiffusionAttendAndExcitePipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 1,
|
"num_inference_steps": 1,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"max_iter_to_alter": 2,
|
"max_iter_to_alter": 2,
|
||||||
"thresholds": {0: 0.7},
|
"thresholds": {0: 0.7},
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ class StableDiffusionAttendAndExcitePipelineIntegrationTests(unittest.TestCase):
|
|||||||
generator=generator,
|
generator=generator,
|
||||||
num_inference_steps=5,
|
num_inference_steps=5,
|
||||||
max_iter_to_alter=5,
|
max_iter_to_alter=5,
|
||||||
output_type="numpy",
|
output_type="np",
|
||||||
).images[0]
|
).images[0]
|
||||||
|
|
||||||
expected_image = load_numpy(
|
expected_image = load_numpy(
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class StableDiffusionDepth2ImgPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -395,7 +395,7 @@ class StableDiffusionDepth2ImgPipelineSlowTests(unittest.TestCase):
|
|||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"strength": 0.75,
|
"strength": 0.75,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -534,7 +534,7 @@ class StableDiffusionImg2ImgPipelineNightlyTests(unittest.TestCase):
|
|||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"strength": 0.75,
|
"strength": 0.75,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class StableDiffusionDiffEditPipelineFastTests(PipelineLatentTesterMixin, Pipeli
|
|||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"inpaint_strength": 1.0,
|
"inpaint_strength": 1.0,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
@@ -165,7 +165,7 @@ class StableDiffusionDiffEditPipelineFastTests(PipelineLatentTesterMixin, Pipeli
|
|||||||
"num_maps_per_mask": 2,
|
"num_maps_per_mask": 2,
|
||||||
"mask_encode_strength": 1.0,
|
"mask_encode_strength": 1.0,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
@@ -186,7 +186,7 @@ class StableDiffusionDiffEditPipelineFastTests(PipelineLatentTesterMixin, Pipeli
|
|||||||
"inpaint_strength": 1.0,
|
"inpaint_strength": 1.0,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"decode_latents": True,
|
"decode_latents": True,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ class StableDiffusionDiffEditPipelineNightlyTests(unittest.TestCase):
|
|||||||
negative_prompt=source_prompt,
|
negative_prompt=source_prompt,
|
||||||
inpaint_strength=0.7,
|
inpaint_strength=0.7,
|
||||||
num_inference_steps=25,
|
num_inference_steps=25,
|
||||||
output_type="numpy",
|
output_type="np",
|
||||||
).images[0]
|
).images[0]
|
||||||
|
|
||||||
expected_image = (
|
expected_image = (
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class StableDiffusion2InpaintPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class StableDiffusionLatentUpscalePipelineFastTests(
|
|||||||
"image": self.dummy_image.cpu(),
|
"image": self.dummy_image.cpu(),
|
||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class StableDiffusion2VPredictionPipelineIntegrationTests(unittest.TestCase):
|
|||||||
prompt = "A painting of a squirrel eating a burger"
|
prompt = "A painting of a squirrel eating a burger"
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
|
|
||||||
output = sd_pipe([prompt], generator=generator, num_inference_steps=5, output_type="numpy")
|
output = sd_pipe([prompt], generator=generator, num_inference_steps=5, output_type="np")
|
||||||
image = output.images
|
image = output.images
|
||||||
|
|
||||||
image_slice = image[0, 253:256, 253:256, -1]
|
image_slice = image[0, 253:256, 253:256, -1]
|
||||||
@@ -335,7 +335,7 @@ class StableDiffusion2VPredictionPipelineIntegrationTests(unittest.TestCase):
|
|||||||
prompt = "a photograph of an astronaut riding a horse"
|
prompt = "a photograph of an astronaut riding a horse"
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
image = sd_pipe(
|
image = sd_pipe(
|
||||||
[prompt], generator=generator, guidance_scale=7.5, num_inference_steps=5, output_type="numpy"
|
[prompt], generator=generator, guidance_scale=7.5, num_inference_steps=5, output_type="np"
|
||||||
).images
|
).images
|
||||||
|
|
||||||
image_slice = image[0, 253:256, 253:256, -1]
|
image_slice = image[0, 253:256, 253:256, -1]
|
||||||
@@ -357,7 +357,7 @@ class StableDiffusion2VPredictionPipelineIntegrationTests(unittest.TestCase):
|
|||||||
pipe.enable_attention_slicing()
|
pipe.enable_attention_slicing()
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
output_chunked = pipe(
|
output_chunked = pipe(
|
||||||
[prompt], generator=generator, guidance_scale=7.5, num_inference_steps=10, output_type="numpy"
|
[prompt], generator=generator, guidance_scale=7.5, num_inference_steps=10, output_type="np"
|
||||||
)
|
)
|
||||||
image_chunked = output_chunked.images
|
image_chunked = output_chunked.images
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ class StableDiffusion2VPredictionPipelineIntegrationTests(unittest.TestCase):
|
|||||||
# disable slicing
|
# disable slicing
|
||||||
pipe.disable_attention_slicing()
|
pipe.disable_attention_slicing()
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
output = pipe([prompt], generator=generator, guidance_scale=7.5, num_inference_steps=10, output_type="numpy")
|
output = pipe([prompt], generator=generator, guidance_scale=7.5, num_inference_steps=10, output_type="np")
|
||||||
image = output.images
|
image = output.images
|
||||||
|
|
||||||
# make sure that more than 3.0 GB is allocated
|
# make sure that more than 3.0 GB is allocated
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class AdapterTests:
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -117,7 +117,7 @@ class StableDiffusionImageVariationPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ class StableDiffusionImageVariationPipelineNightlyTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 50,
|
"num_inference_steps": 50,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class StableDiffusionLDM3DPipelineFastTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ class StableDiffusionLDM3DPipelineSlowTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ class StableDiffusionPipelineNightlyTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 50,
|
"num_inference_steps": 50,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class StableDiffusionPanoramaPipelineFastTests(PipelineLatentTesterMixin, Pipeli
|
|||||||
"width": None,
|
"width": None,
|
||||||
"num_inference_steps": 1,
|
"num_inference_steps": 1,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ class StableDiffusionPanoramaNightlyTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 7.5,
|
"guidance_scale": 7.5,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ class StableDiffusionXLAdapterPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 5.0,
|
"guidance_scale": 5.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class StableDiffusionXLInstructPix2PixPipelineFastTests(
|
|||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"image_guidance_scale": 1,
|
"image_guidance_scale": 1,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class StableUnCLIPPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"prior_num_inference_steps": 2,
|
"prior_num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -117,10 +117,10 @@ def _test_from_save_pretrained_dynamo(in_queue, out_queue, timeout):
|
|||||||
new_ddpm.to(torch_device)
|
new_ddpm.to(torch_device)
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(0)
|
generator = torch.Generator(device=torch_device).manual_seed(0)
|
||||||
image = ddpm(generator=generator, num_inference_steps=5, output_type="numpy").images
|
image = ddpm(generator=generator, num_inference_steps=5, output_type="np").images
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(0)
|
generator = torch.Generator(device=torch_device).manual_seed(0)
|
||||||
new_image = new_ddpm(generator=generator, num_inference_steps=5, output_type="numpy").images
|
new_image = new_ddpm(generator=generator, num_inference_steps=5, output_type="np").images
|
||||||
|
|
||||||
assert np.abs(image - new_image).max() < 1e-5, "Models don't give the same forward pass"
|
assert np.abs(image - new_image).max() < 1e-5, "Models don't give the same forward pass"
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -363,12 +363,12 @@ class DownloadTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
pipe = pipe.to(torch_device)
|
pipe = pipe.to(torch_device)
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
out = pipe(prompt, num_inference_steps=2, generator=generator, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
pipe_2 = StableDiffusionPipeline.from_pretrained("hf-internal-testing/tiny-stable-diffusion-torch")
|
pipe_2 = StableDiffusionPipeline.from_pretrained("hf-internal-testing/tiny-stable-diffusion-torch")
|
||||||
pipe_2 = pipe_2.to(torch_device)
|
pipe_2 = pipe_2.to(torch_device)
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
out_2 = pipe_2(prompt, num_inference_steps=2, generator=generator, output_type="numpy").images
|
out_2 = pipe_2(prompt, num_inference_steps=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
assert np.max(np.abs(out - out_2)) < 1e-3
|
assert np.max(np.abs(out - out_2)) < 1e-3
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
pipe = pipe.to(torch_device)
|
pipe = pipe.to(torch_device)
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
out = pipe(prompt, num_inference_steps=2, generator=generator, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
pipe.save_pretrained(tmpdirname)
|
pipe.save_pretrained(tmpdirname)
|
||||||
@@ -388,7 +388,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
|
|
||||||
out_2 = pipe_2(prompt, num_inference_steps=2, generator=generator, output_type="numpy").images
|
out_2 = pipe_2(prompt, num_inference_steps=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
assert np.max(np.abs(out - out_2)) < 1e-3
|
assert np.max(np.abs(out - out_2)) < 1e-3
|
||||||
|
|
||||||
@@ -398,7 +398,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
pipe = pipe.to(torch_device)
|
pipe = pipe.to(torch_device)
|
||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
out = pipe(prompt, num_inference_steps=2, generator=generator, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
pipe.save_pretrained(tmpdirname)
|
pipe.save_pretrained(tmpdirname)
|
||||||
@@ -407,7 +407,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
|
|
||||||
out_2 = pipe_2(prompt, num_inference_steps=2, generator=generator, output_type="numpy").images
|
out_2 = pipe_2(prompt, num_inference_steps=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
assert np.max(np.abs(out - out_2)) < 1e-3
|
assert np.max(np.abs(out - out_2)) < 1e-3
|
||||||
|
|
||||||
@@ -590,7 +590,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
pipe = pipe.to(torch_device)
|
pipe = pipe.to(torch_device)
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
out = pipe(prompt, num_inference_steps=2, generator=generator, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
pipe.save_pretrained(tmpdirname)
|
pipe.save_pretrained(tmpdirname)
|
||||||
@@ -601,7 +601,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
|
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
|
|
||||||
out_2 = pipe_2(prompt, num_inference_steps=2, generator=generator, output_type="numpy").images
|
out_2 = pipe_2(prompt, num_inference_steps=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
assert np.max(np.abs(out - out_2)) < 1e-3
|
assert np.max(np.abs(out - out_2)) < 1e-3
|
||||||
|
|
||||||
@@ -626,7 +626,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
assert pipe._maybe_convert_prompt("<*>", pipe.tokenizer) == "<*>"
|
assert pipe._maybe_convert_prompt("<*>", pipe.tokenizer) == "<*>"
|
||||||
|
|
||||||
prompt = "hey <*>"
|
prompt = "hey <*>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
# single token load local with weight name
|
# single token load local with weight name
|
||||||
@@ -642,7 +642,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
assert pipe._maybe_convert_prompt("<**>", pipe.tokenizer) == "<**>"
|
assert pipe._maybe_convert_prompt("<**>", pipe.tokenizer) == "<**>"
|
||||||
|
|
||||||
prompt = "hey <**>"
|
prompt = "hey <**>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
# multi token load
|
# multi token load
|
||||||
@@ -665,7 +665,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
assert pipe._maybe_convert_prompt("<***>", pipe.tokenizer) == "<***> <***>_1 <***>_2"
|
assert pipe._maybe_convert_prompt("<***>", pipe.tokenizer) == "<***> <***>_1 <***>_2"
|
||||||
|
|
||||||
prompt = "hey <***>"
|
prompt = "hey <***>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
# multi token load a1111
|
# multi token load a1111
|
||||||
@@ -693,7 +693,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
assert pipe._maybe_convert_prompt("<****>", pipe.tokenizer) == "<****> <****>_1 <****>_2"
|
assert pipe._maybe_convert_prompt("<****>", pipe.tokenizer) == "<****> <****>_1 <****>_2"
|
||||||
|
|
||||||
prompt = "hey <****>"
|
prompt = "hey <****>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
# multi embedding load
|
# multi embedding load
|
||||||
@@ -718,7 +718,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
assert pipe._maybe_convert_prompt("<******>", pipe.tokenizer) == "<******>"
|
assert pipe._maybe_convert_prompt("<******>", pipe.tokenizer) == "<******>"
|
||||||
|
|
||||||
prompt = "hey <*****> <******>"
|
prompt = "hey <*****> <******>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
# single token state dict load
|
# single token state dict load
|
||||||
@@ -731,7 +731,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
assert pipe._maybe_convert_prompt("<x>", pipe.tokenizer) == "<x>"
|
assert pipe._maybe_convert_prompt("<x>", pipe.tokenizer) == "<x>"
|
||||||
|
|
||||||
prompt = "hey <x>"
|
prompt = "hey <x>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
# multi embedding state dict load
|
# multi embedding state dict load
|
||||||
@@ -751,7 +751,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
assert pipe._maybe_convert_prompt("<xxxxxx>", pipe.tokenizer) == "<xxxxxx>"
|
assert pipe._maybe_convert_prompt("<xxxxxx>", pipe.tokenizer) == "<xxxxxx>"
|
||||||
|
|
||||||
prompt = "hey <xxxxx> <xxxxxx>"
|
prompt = "hey <xxxxx> <xxxxxx>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
# auto1111 multi-token state dict load
|
# auto1111 multi-token state dict load
|
||||||
@@ -777,7 +777,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
assert pipe._maybe_convert_prompt("<xxxx>", pipe.tokenizer) == "<xxxx> <xxxx>_1 <xxxx>_2"
|
assert pipe._maybe_convert_prompt("<xxxx>", pipe.tokenizer) == "<xxxx> <xxxx>_1 <xxxx>_2"
|
||||||
|
|
||||||
prompt = "hey <xxxx>"
|
prompt = "hey <xxxx>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
# multiple references to multi embedding
|
# multiple references to multi embedding
|
||||||
@@ -789,7 +789,7 @@ class DownloadTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
prompt = "hey <cat> <cat>"
|
prompt = "hey <cat> <cat>"
|
||||||
out = pipe(prompt, num_inference_steps=1, output_type="numpy").images
|
out = pipe(prompt, num_inference_steps=1, output_type="np").images
|
||||||
assert out.shape == (1, 128, 128, 3)
|
assert out.shape == (1, 128, 128, 3)
|
||||||
|
|
||||||
def test_text_inversion_multi_tokens(self):
|
def test_text_inversion_multi_tokens(self):
|
||||||
@@ -1739,10 +1739,10 @@ class PipelineSlowTests(unittest.TestCase):
|
|||||||
new_ddpm.to(torch_device)
|
new_ddpm.to(torch_device)
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(0)
|
generator = torch.Generator(device=torch_device).manual_seed(0)
|
||||||
image = ddpm(generator=generator, num_inference_steps=5, output_type="numpy").images
|
image = ddpm(generator=generator, num_inference_steps=5, output_type="np").images
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(0)
|
generator = torch.Generator(device=torch_device).manual_seed(0)
|
||||||
new_image = new_ddpm(generator=generator, num_inference_steps=5, output_type="numpy").images
|
new_image = new_ddpm(generator=generator, num_inference_steps=5, output_type="np").images
|
||||||
|
|
||||||
assert np.abs(image - new_image).max() < 1e-5, "Models don't give the same forward pass"
|
assert np.abs(image - new_image).max() < 1e-5, "Models don't give the same forward pass"
|
||||||
|
|
||||||
@@ -1765,10 +1765,10 @@ class PipelineSlowTests(unittest.TestCase):
|
|||||||
ddpm_from_hub.set_progress_bar_config(disable=None)
|
ddpm_from_hub.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(0)
|
generator = torch.Generator(device=torch_device).manual_seed(0)
|
||||||
image = ddpm(generator=generator, num_inference_steps=5, output_type="numpy").images
|
image = ddpm(generator=generator, num_inference_steps=5, output_type="np").images
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(0)
|
generator = torch.Generator(device=torch_device).manual_seed(0)
|
||||||
new_image = ddpm_from_hub(generator=generator, num_inference_steps=5, output_type="numpy").images
|
new_image = ddpm_from_hub(generator=generator, num_inference_steps=5, output_type="np").images
|
||||||
|
|
||||||
assert np.abs(image - new_image).max() < 1e-5, "Models don't give the same forward pass"
|
assert np.abs(image - new_image).max() < 1e-5, "Models don't give the same forward pass"
|
||||||
|
|
||||||
@@ -1788,10 +1788,10 @@ class PipelineSlowTests(unittest.TestCase):
|
|||||||
ddpm_from_hub_custom_model.set_progress_bar_config(disable=None)
|
ddpm_from_hub_custom_model.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(0)
|
generator = torch.Generator(device=torch_device).manual_seed(0)
|
||||||
image = ddpm_from_hub_custom_model(generator=generator, num_inference_steps=5, output_type="numpy").images
|
image = ddpm_from_hub_custom_model(generator=generator, num_inference_steps=5, output_type="np").images
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(0)
|
generator = torch.Generator(device=torch_device).manual_seed(0)
|
||||||
new_image = ddpm_from_hub(generator=generator, num_inference_steps=5, output_type="numpy").images
|
new_image = ddpm_from_hub(generator=generator, num_inference_steps=5, output_type="np").images
|
||||||
|
|
||||||
assert np.abs(image - new_image).max() < 1e-5, "Models don't give the same forward pass"
|
assert np.abs(image - new_image).max() < 1e-5, "Models don't give the same forward pass"
|
||||||
|
|
||||||
@@ -1803,7 +1803,7 @@ class PipelineSlowTests(unittest.TestCase):
|
|||||||
pipe.to(torch_device)
|
pipe.to(torch_device)
|
||||||
pipe.set_progress_bar_config(disable=None)
|
pipe.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
images = pipe(output_type="numpy").images
|
images = pipe(output_type="np").images
|
||||||
assert images.shape == (1, 32, 32, 3)
|
assert images.shape == (1, 32, 32, 3)
|
||||||
assert isinstance(images, np.ndarray)
|
assert isinstance(images, np.ndarray)
|
||||||
|
|
||||||
@@ -1878,7 +1878,7 @@ class PipelineSlowTests(unittest.TestCase):
|
|||||||
generator = [torch.Generator(device="cpu").manual_seed(33) for _ in range(prompt_embeds.shape[0])]
|
generator = [torch.Generator(device="cpu").manual_seed(33) for _ in range(prompt_embeds.shape[0])]
|
||||||
|
|
||||||
images = pipe(
|
images = pipe(
|
||||||
prompt_embeds=prompt_embeds, generator=generator, num_inference_steps=20, output_type="numpy"
|
prompt_embeds=prompt_embeds, generator=generator, num_inference_steps=20, output_type="np"
|
||||||
).images
|
).images
|
||||||
|
|
||||||
for i, image in enumerate(images):
|
for i, image in enumerate(images):
|
||||||
@@ -1916,7 +1916,7 @@ class PipelineNightlyTests(unittest.TestCase):
|
|||||||
ddim.set_progress_bar_config(disable=None)
|
ddim.set_progress_bar_config(disable=None)
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(seed)
|
generator = torch.Generator(device=torch_device).manual_seed(seed)
|
||||||
ddpm_images = ddpm(batch_size=2, generator=generator, output_type="numpy").images
|
ddpm_images = ddpm(batch_size=2, generator=generator, output_type="np").images
|
||||||
|
|
||||||
generator = torch.Generator(device=torch_device).manual_seed(seed)
|
generator = torch.Generator(device=torch_device).manual_seed(seed)
|
||||||
ddim_images = ddim(
|
ddim_images = ddim(
|
||||||
@@ -1924,7 +1924,7 @@ class PipelineNightlyTests(unittest.TestCase):
|
|||||||
generator=generator,
|
generator=generator,
|
||||||
num_inference_steps=1000,
|
num_inference_steps=1000,
|
||||||
eta=1.0,
|
eta=1.0,
|
||||||
output_type="numpy",
|
output_type="np",
|
||||||
use_clipped_model_output=True, # Need this to make DDIM match DDPM
|
use_clipped_model_output=True, # Need this to make DDIM match DDPM
|
||||||
).images
|
).images
|
||||||
|
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class UnCLIPPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
|
|||||||
"prior_num_inference_steps": 2,
|
"prior_num_inference_steps": 2,
|
||||||
"decoder_num_inference_steps": 2,
|
"decoder_num_inference_steps": 2,
|
||||||
"super_res_num_inference_steps": 2,
|
"super_res_num_inference_steps": 2,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class UniDiffuserPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ class UniDiffuserPipelineFastTests(
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 2,
|
"num_inference_steps": 2,
|
||||||
"guidance_scale": 6.0,
|
"guidance_scale": 6.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
"prompt_latents": latents.get("prompt_latents"),
|
"prompt_latents": latents.get("prompt_latents"),
|
||||||
"vae_latents": latents.get("vae_latents"),
|
"vae_latents": latents.get("vae_latents"),
|
||||||
"clip_latents": latents.get("clip_latents"),
|
"clip_latents": latents.get("clip_latents"),
|
||||||
@@ -590,7 +590,7 @@ class UniDiffuserPipelineSlowTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 8.0,
|
"guidance_scale": 8.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
if generate_latents:
|
if generate_latents:
|
||||||
latents = self.get_fixed_latents(device, seed=seed)
|
latents = self.get_fixed_latents(device, seed=seed)
|
||||||
@@ -706,7 +706,7 @@ class UniDiffuserPipelineNightlyTests(unittest.TestCase):
|
|||||||
"generator": generator,
|
"generator": generator,
|
||||||
"num_inference_steps": 3,
|
"num_inference_steps": 3,
|
||||||
"guidance_scale": 8.0,
|
"guidance_scale": 8.0,
|
||||||
"output_type": "numpy",
|
"output_type": "np",
|
||||||
}
|
}
|
||||||
if generate_latents:
|
if generate_latents:
|
||||||
latents = self.get_fixed_latents(device, seed=seed)
|
latents = self.get_fixed_latents(device, seed=seed)
|
||||||
|
|||||||
Reference in New Issue
Block a user