Skip to content

Commit 0451caf

Browse files
committed
make fix-copies
1 parent 9f04fa1 commit 0451caf

File tree

4 files changed

+52
-14
lines changed

4 files changed

+52
-14
lines changed

src/diffusers/pipelines/easyanimate/pipeline_easyanimate.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,21 @@ def get_resize_crop_region_for_grid(src, tgt_width, tgt_height):
100100

101101
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.rescale_noise_cfg
102102
def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
103-
"""
104-
Rescale `noise_cfg` according to `guidance_rescale`. Based on findings of [Common Diffusion Noise Schedules and
105-
Sample Steps are Flawed](https://arxiv.org/pdf/2305.08891.pdf). See Section 3.4
103+
r"""
104+
Rescales `noise_cfg` tensor based on `guidance_rescale` to improve image quality and fix overexposure. Based on
105+
Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are
106+
Flawed](https://arxiv.org/pdf/2305.08891.pdf).
107+
108+
Args:
109+
noise_cfg (`torch.Tensor`):
110+
The predicted noise tensor for the guided diffusion process.
111+
noise_pred_text (`torch.Tensor`):
112+
The predicted noise tensor for the text-guided diffusion process.
113+
guidance_rescale (`float`, *optional*, defaults to 0.0):
114+
A rescale factor applied to the noise predictions.
115+
116+
Returns:
117+
noise_cfg (`torch.Tensor`): The rescaled noise prediction tensor.
106118
"""
107119
std_text = noise_pred_text.std(dim=list(range(1, noise_pred_text.ndim)), keepdim=True)
108120
std_cfg = noise_cfg.std(dim=list(range(1, noise_cfg.ndim)), keepdim=True)
@@ -122,7 +134,7 @@ def retrieve_timesteps(
122134
sigmas: Optional[List[float]] = None,
123135
**kwargs,
124136
):
125-
"""
137+
r"""
126138
Calls the scheduler's `set_timesteps` method and retrieves timesteps from the scheduler after the call. Handles
127139
custom timesteps. Any kwargs will be supplied to `scheduler.set_timesteps`.
128140

src/diffusers/pipelines/easyanimate/pipeline_easyanimate_control.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,21 @@ def get_resize_crop_region_for_grid(src, tgt_width, tgt_height):
176176

177177
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.rescale_noise_cfg
178178
def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
179-
"""
180-
Rescale `noise_cfg` according to `guidance_rescale`. Based on findings of [Common Diffusion Noise Schedules and
181-
Sample Steps are Flawed](https://arxiv.org/pdf/2305.08891.pdf). See Section 3.4
179+
r"""
180+
Rescales `noise_cfg` tensor based on `guidance_rescale` to improve image quality and fix overexposure. Based on
181+
Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are
182+
Flawed](https://arxiv.org/pdf/2305.08891.pdf).
183+
184+
Args:
185+
noise_cfg (`torch.Tensor`):
186+
The predicted noise tensor for the guided diffusion process.
187+
noise_pred_text (`torch.Tensor`):
188+
The predicted noise tensor for the text-guided diffusion process.
189+
guidance_rescale (`float`, *optional*, defaults to 0.0):
190+
A rescale factor applied to the noise predictions.
191+
192+
Returns:
193+
noise_cfg (`torch.Tensor`): The rescaled noise prediction tensor.
182194
"""
183195
std_text = noise_pred_text.std(dim=list(range(1, noise_pred_text.ndim)), keepdim=True)
184196
std_cfg = noise_cfg.std(dim=list(range(1, noise_cfg.ndim)), keepdim=True)
@@ -224,7 +236,7 @@ def retrieve_timesteps(
224236
sigmas: Optional[List[float]] = None,
225237
**kwargs,
226238
):
227-
"""
239+
r"""
228240
Calls the scheduler's `set_timesteps` method and retrieves timesteps from the scheduler after the call. Handles
229241
custom timesteps. Any kwargs will be supplied to `scheduler.set_timesteps`.
230242

src/diffusers/pipelines/easyanimate/pipeline_easyanimate_inpaint.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,21 @@ def get_resize_crop_region_for_grid(src, tgt_width, tgt_height):
198198

199199
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.rescale_noise_cfg
200200
def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
201-
"""
202-
Rescale `noise_cfg` according to `guidance_rescale`. Based on findings of [Common Diffusion Noise Schedules and
203-
Sample Steps are Flawed](https://arxiv.org/pdf/2305.08891.pdf). See Section 3.4
201+
r"""
202+
Rescales `noise_cfg` tensor based on `guidance_rescale` to improve image quality and fix overexposure. Based on
203+
Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are
204+
Flawed](https://arxiv.org/pdf/2305.08891.pdf).
205+
206+
Args:
207+
noise_cfg (`torch.Tensor`):
208+
The predicted noise tensor for the guided diffusion process.
209+
noise_pred_text (`torch.Tensor`):
210+
The predicted noise tensor for the text-guided diffusion process.
211+
guidance_rescale (`float`, *optional*, defaults to 0.0):
212+
A rescale factor applied to the noise predictions.
213+
214+
Returns:
215+
noise_cfg (`torch.Tensor`): The rescaled noise prediction tensor.
204216
"""
205217
std_text = noise_pred_text.std(dim=list(range(1, noise_pred_text.ndim)), keepdim=True)
206218
std_cfg = noise_cfg.std(dim=list(range(1, noise_cfg.ndim)), keepdim=True)
@@ -266,7 +278,7 @@ def retrieve_timesteps(
266278
sigmas: Optional[List[float]] = None,
267279
**kwargs,
268280
):
269-
"""
281+
r"""
270282
Calls the scheduler's `set_timesteps` method and retrieves timesteps from the scheduler after the call. Handles
271283
custom timesteps. Any kwargs will be supplied to `scheduler.set_timesteps`.
272284
@@ -770,6 +782,8 @@ def get_timesteps(self, num_inference_steps, strength, device):
770782

771783
t_start = max(num_inference_steps - init_timestep, 0)
772784
timesteps = self.scheduler.timesteps[t_start * self.scheduler.order :]
785+
if hasattr(self.scheduler, "set_begin_index"):
786+
self.scheduler.set_begin_index(t_start * self.scheduler.order)
773787

774788
return timesteps, num_inference_steps - t_start
775789

src/diffusers/utils/dummy_torch_and_transformers_objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def from_pretrained(cls, *args, **kwargs):
407407
requires_backends(cls, ["torch", "transformers"])
408408

409409

410-
class EasyAnimatePipeline(metaclass=DummyObject):
410+
class EasyAnimateControlPipeline(metaclass=DummyObject):
411411
_backends = ["torch", "transformers"]
412412

413413
def __init__(self, *args, **kwargs):
@@ -437,7 +437,7 @@ def from_pretrained(cls, *args, **kwargs):
437437
requires_backends(cls, ["torch", "transformers"])
438438

439439

440-
class EasyAnimateControlPipeline(metaclass=DummyObject):
440+
class EasyAnimatePipeline(metaclass=DummyObject):
441441
_backends = ["torch", "transformers"]
442442

443443
def __init__(self, *args, **kwargs):

0 commit comments

Comments
 (0)