@@ -74,65 +74,6 @@ def calculate_shift(
7474
7575 return mu
7676
77- # def retrieve_timesteps(
78- # scheduler,
79- # num_inference_steps: Optional[int] = None,
80- # device: Optional[Union[str, torch.device]] = None,
81- # timesteps: Optional[List[int]] = None,
82- # sigmas: Optional[List[float]] = None,
83- # **kwargs,
84- # ):
85- # r"""
86- # Calls the scheduler's `set_timesteps` method and retrieves timesteps from the scheduler after the call. Handles
87- # custom timesteps. Any kwargs will be supplied to `scheduler.set_timesteps`.
88-
89- # Args:
90- # scheduler (`SchedulerMixin`):
91- # The scheduler to get timesteps from.
92- # num_inference_steps (`int`):
93- # The number of diffusion steps used when generating samples with a pre-trained model. If used, `timesteps`
94- # must be `None`.
95- # device (`str` or `torch.device`, *optional*):
96- # The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
97- # timesteps (`List[int]`, *optional*):
98- # Custom timesteps used to override the timestep spacing strategy of the scheduler. If `timesteps` is passed,
99- # `num_inference_steps` and `sigmas` must be `None`.
100- # sigmas (`List[float]`, *optional*):
101- # Custom sigmas used to override the timestep spacing strategy of the scheduler. If `sigmas` is passed,
102- # `num_inference_steps` and `timesteps` must be `None`.
103-
104- # Returns:
105- # `Tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
106- # second element is the number of inference steps.
107- # """
108- # if timesteps is not None and sigmas is not None:
109- # raise ValueError("Only one of `timesteps` or `sigmas` can be passed. Please choose one to set custom values")
110- # if timesteps is not None:
111- # accepts_timesteps = "timesteps" in set(inspect.signature(scheduler.set_timesteps).parameters.keys())
112- # if not accepts_timesteps:
113- # raise ValueError(
114- # f"The current scheduler class {scheduler.__class__}'s `set_timesteps` does not support custom"
115- # f" timestep schedules. Please check whether you are using the correct scheduler."
116- # )
117- # scheduler.set_timesteps(timesteps=timesteps, device=device, **kwargs)
118- # timesteps = scheduler.timesteps
119- # num_inference_steps = len(timesteps)
120- # elif sigmas is not None:
121- # accept_sigmas = "sigmas" in set(inspect.signature(scheduler.set_timesteps).parameters.keys())
122- # if not accept_sigmas:
123- # raise ValueError(
124- # f"The current scheduler class {scheduler.__class__}'s `set_timesteps` does not support custom"
125- # f" sigmas schedules. Please check whether you are using the correct scheduler."
126- # )
127- # scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs)
128- # timesteps = scheduler.timesteps
129- # num_inference_steps = len(timesteps)
130- # else:
131- # scheduler.set_timesteps(num_inference_steps, device=device, **kwargs)
132- # timesteps = scheduler.timesteps
133- # return timesteps, num_inference_steps
134-
135-
13677class CogView4Pipeline (DiffusionPipeline ):
13778 r"""
13879 Pipeline for text-to-image generation using CogView4.
0 commit comments