modernize typing

This commit is contained in:
Vladimir Mandic
2026-02-19 09:15:37 +01:00
parent 7aded79e8a
commit bfe014f5da
222 changed files with 1538 additions and 1444 deletions
+4 -3
View File
@@ -1,4 +1,3 @@
import typing
import os
import time
import torch
@@ -33,7 +32,7 @@ def prompt_callback(step, kwargs):
return kwargs
def diffusers_callback_legacy(step: int, timestep: int, latents: typing.Union[torch.FloatTensor, np.ndarray]):
def diffusers_callback_legacy(step: int, timestep: int, latents: torch.FloatTensor | np.ndarray):
if p is None:
return
if isinstance(latents, np.ndarray): # latents from Onnx pipelines is ndarray.
@@ -51,7 +50,9 @@ def diffusers_callback_legacy(step: int, timestep: int, latents: typing.Union[to
time.sleep(0.1)
def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict = {}):
def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict = None):
if kwargs is None:
kwargs = {}
t0 = time.time()
if devices.backend == "ipex":
torch.xpu.synchronize(devices.device)