Skip to content

Commit a2ecce2

Browse files
authored
Fix Copying Mechanism typo/bug (#8232)
* Fix copying mechanism typos * fix copying mecha * Revert, since they are in TODO * Fix copying mechanism
1 parent 9e00b72 commit a2ecce2

File tree

10 files changed

+31
-31
lines changed

10 files changed

+31
-31
lines changed

examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def initialize_new_tokens(self, inserting_toks: List[str]):
758758

759759
idx += 1
760760

761-
# copied from train_dreambooth_lora_sdxl_advanced.py
761+
# Copied from train_dreambooth_lora_sdxl_advanced.py
762762
def save_embeddings(self, file_path: str):
763763
assert self.train_ids is not None, "Initialize new tokens before saving embeddings."
764764
tensors = {}

examples/community/llm_grounded_diffusion.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,35 +1524,35 @@ def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32
15241524
assert emb.shape == (w.shape[0], embedding_dim)
15251525
return emb
15261526

1527-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.guidance_scale
15281527
@property
1528+
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.guidance_scale
15291529
def guidance_scale(self):
15301530
return self._guidance_scale
15311531

1532-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.guidance_rescale
15331532
@property
1533+
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.guidance_rescale
15341534
def guidance_rescale(self):
15351535
return self._guidance_rescale
15361536

1537-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.clip_skip
15381537
@property
1538+
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.clip_skip
15391539
def clip_skip(self):
15401540
return self._clip_skip
15411541

15421542
# here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
15431543
# of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
15441544
# corresponds to doing no classifier free guidance.
1545-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.do_classifier_free_guidance
15461545
@property
1546+
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.do_classifier_free_guidance
15471547
def do_classifier_free_guidance(self):
15481548
return self._guidance_scale > 1 and self.unet.config.time_cond_proj_dim is None
15491549

1550-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.cross_attention_kwargs
15511550
@property
1551+
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.cross_attention_kwargs
15521552
def cross_attention_kwargs(self):
15531553
return self._cross_attention_kwargs
15541554

1555-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.num_timesteps
15561555
@property
1556+
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.num_timesteps
15571557
def num_timesteps(self):
15581558
return self._num_timesteps

src/diffusers/models/controlnet_xs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ def _set_gradient_checkpointing(self, module, value=False):
851851
if hasattr(module, "gradient_checkpointing"):
852852
module.gradient_checkpointing = value
853853

854-
# copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel
855854
@property
855+
# Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.attn_processors
856856
def attn_processors(self) -> Dict[str, AttentionProcessor]:
857857
r"""
858858
Returns:
@@ -911,7 +911,7 @@ def fn_recursive_attn_processor(name: str, module: torch.nn.Module, processor):
911911
for name, module in self.named_children():
912912
fn_recursive_attn_processor(name, module, processor)
913913

914-
# copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.set_default_attn_processor
914+
# Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.set_default_attn_processor
915915
def set_default_attn_processor(self):
916916
"""
917917
Disables custom attention processors and sets the default attention implementation.
@@ -927,7 +927,7 @@ def set_default_attn_processor(self):
927927

928928
self.set_attn_processor(processor)
929929

930-
# copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.enable_freeu
930+
# Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.enable_freeu
931931
def enable_freeu(self, s1: float, s2: float, b1: float, b2: float):
932932
r"""Enables the FreeU mechanism from https://arxiv.org/abs/2309.11497.
933933
@@ -952,7 +952,7 @@ def enable_freeu(self, s1: float, s2: float, b1: float, b2: float):
952952
setattr(upsample_block, "b1", b1)
953953
setattr(upsample_block, "b2", b2)
954954

955-
# copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.disable_freeu
955+
# Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.disable_freeu
956956
def disable_freeu(self):
957957
"""Disables the FreeU mechanism."""
958958
freeu_keys = {"s1", "s2", "b1", "b2"}
@@ -961,7 +961,7 @@ def disable_freeu(self):
961961
if hasattr(upsample_block, k) or getattr(upsample_block, k, None) is not None:
962962
setattr(upsample_block, k, None)
963963

964-
# copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.fuse_qkv_projections
964+
# Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.fuse_qkv_projections
965965
def fuse_qkv_projections(self):
966966
"""
967967
Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query, key, value)
@@ -985,7 +985,7 @@ def fuse_qkv_projections(self):
985985
if isinstance(module, Attention):
986986
module.fuse_projections(fuse=True)
987987

988-
# copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.unfuse_qkv_projections
988+
# Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.unfuse_qkv_projections
989989
def unfuse_qkv_projections(self):
990990
"""Disables the fused QKV projection if enabled.
991991

src/diffusers/pipelines/deepfloyd_if/watermark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self):
1717
self.watermark_image_as_pil = None
1818

1919
def apply_watermark(self, images: List[PIL.Image.Image], sample_size=None):
20-
# copied from https://github.com/deep-floyd/IF/blob/b77482e36ca2031cb94dbca1001fc1e6400bf4ab/deepfloyd_if/modules/base.py#L287
20+
# Copied from https://github.com/deep-floyd/IF/blob/b77482e36ca2031cb94dbca1001fc1e6400bf4ab/deepfloyd_if/modules/base.py#L287
2121

2222
h = images[0].height
2323
w = images[0].width

src/diffusers/schedulers/scheduling_dpmsolver_sde.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def t_fn(_sigma):
370370
timesteps = np.array([self._sigma_to_t(sigma, log_sigmas) for sigma in sig_proposed])
371371
return timesteps
372372

373-
# copied from diffusers.schedulers.scheduling_euler_discrete._sigma_to_t
373+
# Copied from diffusers.schedulers.scheduling_euler_discrete.EulerDiscreteScheduler._sigma_to_t
374374
def _sigma_to_t(self, sigma, log_sigmas):
375375
# get log sigma
376376
log_sigma = np.log(np.maximum(sigma, 1e-10))
@@ -394,7 +394,7 @@ def _sigma_to_t(self, sigma, log_sigmas):
394394
t = t.reshape(sigma.shape)
395395
return t
396396

397-
# copied from diffusers.schedulers.scheduling_euler_discrete._convert_to_karras
397+
# copied from diffusers.schedulers.scheduling_euler_discrete.EulerDiscreteScheduler._convert_to_karras
398398
def _convert_to_karras(self, in_sigmas: torch.Tensor) -> torch.Tensor:
399399
"""Constructs the noise schedule of Karras et al. (2022)."""
400400

src/diffusers/schedulers/scheduling_lms_discrete.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def _init_step_index(self, timestep):
324324
else:
325325
self._step_index = self._begin_index
326326

327-
# copied from diffusers.schedulers.scheduling_euler_discrete._sigma_to_t
327+
# Copied from diffusers.schedulers.scheduling_euler_discrete.EulerDiscreteScheduler._sigma_to_t
328328
def _sigma_to_t(self, sigma, log_sigmas):
329329
# get log sigma
330330
log_sigma = np.log(np.maximum(sigma, 1e-10))
@@ -348,7 +348,7 @@ def _sigma_to_t(self, sigma, log_sigmas):
348348
t = t.reshape(sigma.shape)
349349
return t
350350

351-
# copied from diffusers.schedulers.scheduling_euler_discrete._convert_to_karras
351+
# copied from diffusers.schedulers.scheduling_euler_discrete.EulerDiscreteScheduler._convert_to_karras
352352
def _convert_to_karras(self, in_sigmas: torch.Tensor) -> torch.Tensor:
353353
"""Constructs the noise schedule of Karras et al. (2022)."""
354354

tests/lora/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def get_dummy_inputs(self, with_generator=True):
156156

157157
return noise, input_ids, pipeline_inputs
158158

159-
# copied from: https://colab.research.google.com/gist/sayakpaul/df2ef6e1ae6d8c10a49d859883b10860/scratchpad.ipynb
159+
# Copied from: https://colab.research.google.com/gist/sayakpaul/df2ef6e1ae6d8c10a49d859883b10860/scratchpad.ipynb
160160
def get_dummy_tokens(self):
161161
max_seq_length = 77
162162

tests/pipelines/controlnet/test_controlnet_sdxl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def test_stable_diffusion_xl_multi_prompts(self):
294294
# ensure the results are not equal
295295
assert np.abs(image_slice_1.flatten() - image_slice_3.flatten()).max() > 1e-4
296296

297-
# copied from test_stable_diffusion_xl.py
297+
# Copied from test_stable_diffusion_xl.py
298298
def test_stable_diffusion_xl_prompt_embeds(self):
299299
components = self.get_dummy_components()
300300
sd_pipe = self.pipeline_class(**components)
@@ -375,7 +375,7 @@ def test_controlnet_sdxl_lcm(self):
375375

376376
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2
377377

378-
# copied from test_stable_diffusion_xl.py:test_stable_diffusion_two_xl_mixture_of_denoiser_fast
378+
# Copied from test_stable_diffusion_xl.py:test_stable_diffusion_two_xl_mixture_of_denoiser_fast
379379
# with `StableDiffusionXLControlNetPipeline` instead of `StableDiffusionXLPipeline`
380380
def test_controlnet_sdxl_two_mixture_of_denoiser_fast(self):
381381
components = self.get_dummy_components()

tests/pipelines/controlnet/test_controlnet_sdxl_img2img.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def test_stable_diffusion_xl_multi_prompts(self):
322322
# ensure the results are not equal
323323
assert np.abs(image_slice_1.flatten() - image_slice_3.flatten()).max() > 1e-4
324324

325-
# copied from test_stable_diffusion_xl.py
325+
# Copied from test_stable_diffusion_xl.py
326326
def test_stable_diffusion_xl_prompt_embeds(self):
327327
components = self.get_dummy_components()
328328
sd_pipe = self.pipeline_class(**components)

tests/pipelines/controlnet_xs/test_controlnetxs_sdxl.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def get_dummy_components(self):
151151
}
152152
return components
153153

154-
# copied from test_controlnet_sdxl.py
154+
# Copied from test_controlnet_sdxl.py
155155
def get_dummy_inputs(self, device, seed=0):
156156
if str(device).startswith("mps"):
157157
generator = torch.manual_seed(seed)
@@ -176,24 +176,24 @@ def get_dummy_inputs(self, device, seed=0):
176176

177177
return inputs
178178

179-
# copied from test_controlnet_sdxl.py
179+
# Copied from test_controlnet_sdxl.py
180180
def test_attention_slicing_forward_pass(self):
181181
return self._test_attention_slicing_forward_pass(expected_max_diff=2e-3)
182182

183-
# copied from test_controlnet_sdxl.py
184183
@unittest.skipIf(
185184
torch_device != "cuda" or not is_xformers_available(),
186185
reason="XFormers attention is only available with CUDA and `xformers` installed",
187186
)
187+
# Copied from test_controlnet_sdxl.py
188188
def test_xformers_attention_forwardGenerator_pass(self):
189189
self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=2e-3)
190190

191-
# copied from test_controlnet_sdxl.py
191+
# Copied from test_controlnet_sdxl.py
192192
def test_inference_batch_single_identical(self):
193193
self._test_inference_batch_single_identical(expected_max_diff=2e-3)
194194

195-
# copied from test_controlnet_sdxl.py
196195
@require_torch_gpu
196+
# Copied from test_controlnet_sdxl.py
197197
def test_stable_diffusion_xl_offloads(self):
198198
pipes = []
199199
components = self.get_dummy_components()
@@ -222,7 +222,7 @@ def test_stable_diffusion_xl_offloads(self):
222222
assert np.abs(image_slices[0] - image_slices[1]).max() < 1e-3
223223
assert np.abs(image_slices[0] - image_slices[2]).max() < 1e-3
224224

225-
# copied from test_controlnet_sdxl.py
225+
# Copied from test_controlnet_sdxl.py
226226
def test_stable_diffusion_xl_multi_prompts(self):
227227
components = self.get_dummy_components()
228228
sd_pipe = self.pipeline_class(**components).to(torch_device)
@@ -276,7 +276,7 @@ def test_stable_diffusion_xl_multi_prompts(self):
276276
# ensure the results are not equal
277277
assert np.abs(image_slice_1.flatten() - image_slice_3.flatten()).max() > 1e-4
278278

279-
# copied from test_stable_diffusion_xl.py
279+
# Copied from test_stable_diffusion_xl.py
280280
def test_stable_diffusion_xl_prompt_embeds(self):
281281
components = self.get_dummy_components()
282282
sd_pipe = self.pipeline_class(**components)
@@ -315,11 +315,11 @@ def test_stable_diffusion_xl_prompt_embeds(self):
315315
# make sure that it's equal
316316
assert np.abs(image_slice_1.flatten() - image_slice_2.flatten()).max() < 1.1e-4
317317

318-
# copied from test_stable_diffusion_xl.py
318+
# Copied from test_stable_diffusion_xl.py
319319
def test_save_load_optional_components(self):
320320
self._test_save_load_optional_components()
321321

322-
# copied from test_controlnetxs.py
322+
# Copied from test_controlnetxs.py
323323
def test_to_dtype(self):
324324
components = self.get_dummy_components()
325325
pipe = self.pipeline_class(**components)

0 commit comments

Comments
 (0)