Skip to content

Commit 7d7c76e

Browse files
committed
up
1 parent a6ac560 commit 7d7c76e

File tree

5 files changed

+53
-53
lines changed

5 files changed

+53
-53
lines changed

src/diffusers/pipelines/bria_fibo/pipeline_bria_fibo_edit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ def get_prompt_embeds(
274274
prompt: Union[str, List[str]],
275275
num_images_per_prompt: int = 1,
276276
max_sequence_length: int = 2048,
277-
device: Optional[torch.device] = None,
278-
dtype: Optional[torch.dtype] = None,
277+
device: torch.device | None = None,
278+
dtype: torch.dtype | None = None,
279279
):
280280
device = device or self._execution_device
281281
dtype = dtype or self.text_encoder.dtype
@@ -359,7 +359,7 @@ def pad_embedding(prompt_embeds, max_tokens, attention_mask=None):
359359
def encode_prompt(
360360
self,
361361
prompt: Union[str, List[str]],
362-
device: Optional[torch.device] = None,
362+
device: torch.device | None = None,
363363
num_images_per_prompt: int = 1,
364364
guidance_scale: float = 5,
365365
negative_prompt: Optional[Union[str, List[str]]] = None,

src/diffusers/pipelines/chroma/pipeline_chroma_inpainting.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def retrieve_timesteps(
111111
scheduler,
112112
num_inference_steps: int | None = None,
113113
device: str | torch.device | None = None,
114-
timesteps: Optional[List[int]] = None,
114+
timesteps: list[int] | None = None,
115115
sigmas: list[float] | None = None,
116116
**kwargs,
117117
):
@@ -127,15 +127,15 @@ def retrieve_timesteps(
127127
must be `None`.
128128
device (`str` or `torch.device`, *optional*):
129129
The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
130-
timesteps (`List[int]`, *optional*):
130+
timesteps (`list[int]`, *optional*):
131131
Custom timesteps used to override the timestep spacing strategy of the scheduler. If `timesteps` is passed,
132132
`num_inference_steps` and `sigmas` must be `None`.
133-
sigmas (`List[float]`, *optional*):
133+
sigmas (`list[float]`, *optional*):
134134
Custom sigmas used to override the timestep spacing strategy of the scheduler. If `sigmas` is passed,
135135
`num_inference_steps` and `timesteps` must be `None`.
136136
137137
Returns:
138-
`Tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
138+
`tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
139139
second element is the number of inference steps.
140140
"""
141141
if timesteps is not None and sigmas is not None:
@@ -241,8 +241,8 @@ def _get_t5_prompt_embeds(
241241
prompt: Union[str, List[str], None] = None,
242242
num_images_per_prompt: int = 1,
243243
max_sequence_length: int = 512,
244-
device: Optional[torch.device] = None,
245-
dtype: Optional[torch.dtype] = None,
244+
device: torch.device | None = None,
245+
dtype: torch.dtype | None = None,
246246
):
247247
device = device or self._execution_device
248248
dtype = dtype or self.text_encoder.dtype
@@ -294,7 +294,7 @@ def encode_prompt(
294294
self,
295295
prompt: Union[str, List[str]],
296296
negative_prompt: Union[str, List[str], None] = None,
297-
device: Optional[torch.device] = None,
297+
device: torch.device | None = None,
298298
num_images_per_prompt: int = 1,
299299
prompt_embeds: torch.Tensor | None = None,
300300
negative_prompt_embeds: torch.Tensor | None = None,

src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_transfer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ def _get_prompt_embeds(
223223
self,
224224
prompt: Union[str, List[str]] = None,
225225
max_sequence_length: int = 512,
226-
device: Optional[torch.device] = None,
227-
dtype: Optional[torch.dtype] = None,
226+
device: torch.device | None = None,
227+
dtype: torch.dtype | None = None,
228228
):
229229
device = device or self._execution_device
230230
dtype = dtype or self.text_encoder.dtype
@@ -295,8 +295,8 @@ def encode_prompt(
295295
prompt_embeds: torch.Tensor | None = None,
296296
negative_prompt_embeds: torch.Tensor | None = None,
297297
max_sequence_length: int = 512,
298-
device: Optional[torch.device] = None,
299-
dtype: Optional[torch.dtype] = None,
298+
device: torch.device | None = None,
299+
dtype: torch.dtype | None = None,
300300
):
301301
r"""
302302
Encodes the prompt into text encoder hidden states.
@@ -381,8 +381,8 @@ def prepare_latents(
381381
num_frames_in: int = 93,
382382
num_frames_out: int = 93,
383383
do_classifier_free_guidance: bool = True,
384-
dtype: Optional[torch.dtype] = None,
385-
device: Optional[torch.device] = None,
384+
dtype: torch.dtype | None = None,
385+
device: torch.device | None = None,
386386
generator: torch.Generator | list[torch.Generator] | None = None,
387387
latents: torch.Tensor | None = None,
388388
) -> torch.Tensor:

src/diffusers/pipelines/flux2/pipeline_flux2_klein.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import inspect
16-
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
16+
from typing import Any, Callable
1717

1818
import numpy as np
1919
import PIL
@@ -83,7 +83,7 @@ def retrieve_timesteps(
8383
scheduler,
8484
num_inference_steps: int | None = None,
8585
device: str | torch.device | None = None,
86-
timesteps: Optional[List[int]] = None,
86+
timesteps: list[int] | None = None,
8787
sigmas: list[float] | None = None,
8888
**kwargs,
8989
):
@@ -99,15 +99,15 @@ def retrieve_timesteps(
9999
must be `None`.
100100
device (`str` or `torch.device`, *optional*):
101101
The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
102-
timesteps (`List[int]`, *optional*):
102+
timesteps (`list[int]`, *optional*):
103103
Custom timesteps used to override the timestep spacing strategy of the scheduler. If `timesteps` is passed,
104104
`num_inference_steps` and `sigmas` must be `None`.
105-
sigmas (`List[float]`, *optional*):
105+
sigmas (`list[float]`, *optional*):
106106
Custom sigmas used to override the timestep spacing strategy of the scheduler. If `sigmas` is passed,
107107
`num_inference_steps` and `timesteps` must be `None`.
108108
109109
Returns:
110-
`Tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
110+
`tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
111111
second element is the number of inference steps.
112112
"""
113113
if timesteps is not None and sigmas is not None:
@@ -208,11 +208,11 @@ def __init__(
208208
def _get_qwen3_prompt_embeds(
209209
text_encoder: Qwen3ForCausalLM,
210210
tokenizer: Qwen2TokenizerFast,
211-
prompt: Union[str, List[str]],
212-
dtype: Optional[torch.dtype] = None,
213-
device: Optional[torch.device] = None,
211+
prompt: str | list[str],
212+
dtype: torch.dtype | None = None,
213+
device: torch.device | None = None,
214214
max_sequence_length: int = 512,
215-
hidden_states_layers: List[int] = (9, 18, 27),
215+
hidden_states_layers: list[int] = (9, 18, 27),
216216
):
217217
dtype = text_encoder.dtype if dtype is None else dtype
218218
device = text_encoder.device if device is None else device
@@ -317,7 +317,7 @@ def _prepare_latent_ids(
317317
@staticmethod
318318
# Copied from diffusers.pipelines.flux2.pipeline_flux2.Flux2Pipeline._prepare_image_ids
319319
def _prepare_image_ids(
320-
image_latents: List[torch.Tensor], # [(1, C, H, W), (1, C, H, W), ...]
320+
image_latents: list[torch.Tensor], # [(1, C, H, W), (1, C, H, W), ...]
321321
scale: int = 10,
322322
):
323323
r"""
@@ -327,7 +327,7 @@ def _prepare_image_ids(
327327
dimensions.
328328
329329
Args:
330-
image_latents (List[torch.Tensor]):
330+
image_latents (list[torch.Tensor]):
331331
A list of image latent feature tensors, typically of shape (C, H, W).
332332
scale (int, optional):
333333
A factor used to define the time separation (T-coordinate) between latents. T-coordinate for the i-th
@@ -424,12 +424,12 @@ def _unpack_latents_with_ids(x: torch.Tensor, x_ids: torch.Tensor) -> list[torch
424424

425425
def encode_prompt(
426426
self,
427-
prompt: Union[str, List[str]],
428-
device: Optional[torch.device] = None,
427+
prompt: str | list[str],
428+
device: torch.device | None = None,
429429
num_images_per_prompt: int = 1,
430430
prompt_embeds: torch.Tensor | None = None,
431431
max_sequence_length: int = 512,
432-
text_encoder_out_layers: Tuple[int] = (9, 18, 27),
432+
text_encoder_out_layers: tuple[int] = (9, 18, 27),
433433
):
434434
device = device or self._execution_device
435435

@@ -507,7 +507,7 @@ def prepare_latents(
507507
# Copied from diffusers.pipelines.flux2.pipeline_flux2.Flux2Pipeline.prepare_image_latents
508508
def prepare_image_latents(
509509
self,
510-
images: List[torch.Tensor],
510+
images: list[torch.Tensor],
511511
batch_size,
512512
generator: torch.Generator,
513513
device,
@@ -608,25 +608,25 @@ def interrupt(self):
608608
@replace_example_docstring(EXAMPLE_DOC_STRING)
609609
def __call__(
610610
self,
611-
image: Optional[Union[List[PIL.Image.Image], PIL.Image.Image]] = None,
612-
prompt: Union[str, List[str]] = None,
611+
image: list[PIL.Image.Image] | PIL.Image.Image | None = None,
612+
prompt: str | list[str] = None,
613613
height: int | None = None,
614614
width: int | None = None,
615615
num_inference_steps: int = 50,
616616
sigmas: list[float] | None = None,
617-
guidance_scale: Optional[float] = 4.0,
617+
guidance_scale: float = 4.0,
618618
num_images_per_prompt: int = 1,
619619
generator: torch.Generator | list[torch.Generator] | None = None,
620620
latents: torch.Tensor | None = None,
621621
prompt_embeds: torch.Tensor | None = None,
622-
negative_prompt_embeds: Optional[Union[str, List[str]]] = None,
622+
negative_prompt_embeds: str | list[str] | None = None,
623623
output_type: str = "pil",
624624
return_dict: bool = True,
625-
attention_kwargs: Optional[Dict[str, Any]] = None,
626-
callback_on_step_end: Optional[Callable[[int, int, Dict], None]] = None,
627-
callback_on_step_end_tensor_inputs: List[str] = ["latents"],
625+
attention_kwargs: dict[str, Any] | None = None,
626+
callback_on_step_end: Callable[[int, int, dict], None] | None = None,
627+
callback_on_step_end_tensor_inputs: list[str] = ["latents"],
628628
max_sequence_length: int = 512,
629-
text_encoder_out_layers: Tuple[int] = (9, 18, 27),
629+
text_encoder_out_layers: tuple[int] = (9, 18, 27),
630630
):
631631
r"""
632632
Function invoked when calling the pipeline for generation.
@@ -693,7 +693,7 @@ def __call__(
693693
will be passed as `callback_kwargs` argument. You will only be able to include variables listed in the
694694
`._callback_tensor_inputs` attribute of your pipeline class.
695695
max_sequence_length (`int` defaults to 512): Maximum sequence length to use with the `prompt`.
696-
text_encoder_out_layers (`Tuple[int]`):
696+
text_encoder_out_layers (`tuple[int]`):
697697
Layer indices to use in the `text_encoder` to derive the final prompt embeddings.
698698
699699
Examples:

src/diffusers/pipelines/z_image/pipeline_z_image_inpaint.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def retrieve_timesteps(
107107
scheduler,
108108
num_inference_steps: int | None = None,
109109
device: str | torch.device | None = None,
110-
timesteps: Optional[List[int]] = None,
110+
timesteps: list[int] | None = None,
111111
sigmas: list[float] | None = None,
112112
**kwargs,
113113
):
@@ -123,15 +123,15 @@ def retrieve_timesteps(
123123
must be `None`.
124124
device (`str` or `torch.device`, *optional*):
125125
The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
126-
timesteps (`List[int]`, *optional*):
126+
timesteps (`list[int]`, *optional*):
127127
Custom timesteps used to override the timestep spacing strategy of the scheduler. If `timesteps` is passed,
128128
`num_inference_steps` and `sigmas` must be `None`.
129-
sigmas (`List[float]`, *optional*):
129+
sigmas (`list[float]`, *optional*):
130130
Custom sigmas used to override the timestep spacing strategy of the scheduler. If `sigmas` is passed,
131131
`num_inference_steps` and `timesteps` must be `None`.
132132
133133
Returns:
134-
`Tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
134+
`tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
135135
second element is the number of inference steps.
136136
"""
137137
if timesteps is not None and sigmas is not None:
@@ -214,12 +214,12 @@ def __init__(
214214
# Copied from diffusers.pipelines.z_image.pipeline_z_image.ZImagePipeline.encode_prompt
215215
def encode_prompt(
216216
self,
217-
prompt: Union[str, List[str]],
218-
device: Optional[torch.device] = None,
217+
prompt: str | list[str],
218+
device: torch.device | None = None,
219219
do_classifier_free_guidance: bool = True,
220-
negative_prompt: Optional[Union[str, List[str]]] = None,
221-
prompt_embeds: Optional[List[torch.FloatTensor]] = None,
222-
negative_prompt_embeds: Optional[torch.FloatTensor] = None,
220+
negative_prompt: str | list[str] | None = None,
221+
prompt_embeds: list[torch.FloatTensor] | None = None,
222+
negative_prompt_embeds: torch.FloatTensor | None = None,
223223
max_sequence_length: int = 512,
224224
):
225225
prompt = [prompt] if isinstance(prompt, str) else prompt
@@ -249,11 +249,11 @@ def encode_prompt(
249249
# Copied from diffusers.pipelines.z_image.pipeline_z_image.ZImagePipeline._encode_prompt
250250
def _encode_prompt(
251251
self,
252-
prompt: Union[str, List[str]],
253-
device: Optional[torch.device] = None,
254-
prompt_embeds: Optional[List[torch.FloatTensor]] = None,
252+
prompt: str | list[str],
253+
device: torch.device | None = None,
254+
prompt_embeds: list[torch.FloatTensor] | None = None,
255255
max_sequence_length: int = 512,
256-
) -> List[torch.FloatTensor]:
256+
) -> list[torch.FloatTensor]:
257257
device = device or self._execution_device
258258

259259
if prompt_embeds is not None:

0 commit comments

Comments
 (0)