Skip to content

Commit 7d89137

Browse files
committed
stylize according to diffusers requirement
1 parent 7a47d10 commit 7d89137

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

src/diffusers/pipelines/flux/pipeline_flux.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,10 @@ def check_inputs(
386386
callback_on_step_end_tensor_inputs=None,
387387
max_sequence_length=None,
388388
):
389-
if height % 8 != 0 or width % 8 != 0:
390-
raise ValueError(f"`height` and `width` have to be divisible by 8 but are {height} and {width}.")
389+
if height % self.vae_scale_factor != 0 or width % self.vae_scale_factor != 0:
390+
raise ValueError(
391+
f"`height` and `width` have to be divisible by {self.vae_scale_factor} but are {height} and {width}."
392+
)
391393

392394
if callback_on_step_end_tensor_inputs is not None and not all(
393395
k in self._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs

src/diffusers/pipelines/flux/pipeline_flux_controlnet.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,10 @@ def check_inputs(
410410
callback_on_step_end_tensor_inputs=None,
411411
max_sequence_length=None,
412412
):
413-
if height % 8 != 0 or width % 8 != 0:
414-
raise ValueError(f"`height` and `width` have to be divisible by 8 but are {height} and {width}.")
413+
if height % self.vae_scale_factor != 0 or width % self.vae_scale_factor != 0:
414+
raise ValueError(
415+
f"`height` and `width` have to be divisible by {self.vae_scale_factor} but are {height} and {width}."
416+
)
415417

416418
if callback_on_step_end_tensor_inputs is not None and not all(
417419
k in self._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs
@@ -504,7 +506,7 @@ def prepare_latents(
504506
shape = (batch_size, num_channels_latents, height, width)
505507

506508
if latents is not None:
507-
latent_image_ids = self._prepare_latent_image_ids(batch_size, height // 2, width // 2, device, dtype)
509+
latent_image_ids = self._prepare_latent_image_ids(batch_size, height, width, device, dtype)
508510
return latents.to(device=device, dtype=dtype), latent_image_ids
509511

510512
if isinstance(generator, list) and len(generator) != batch_size:

src/diffusers/pipelines/flux/pipeline_flux_controlnet_image_to_image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,10 @@ def check_inputs(
453453
if strength < 0 or strength > 1:
454454
raise ValueError(f"The value of strength should in [0.0, 1.0] but is {strength}")
455455

456-
if height % 8 != 0 or width % 8 != 0:
457-
raise ValueError(f"`height` and `width` have to be divisible by 8 but are {height} and {width}.")
456+
if height % self.vae_scale_factor != 0 or width % self.vae_scale_factor != 0:
457+
raise ValueError(
458+
f"`height` and `width` have to be divisible by {self.vae_scale_factor} but are {height} and {width}."
459+
)
458460

459461
if callback_on_step_end_tensor_inputs is not None and not all(
460462
k in self._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs

src/diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,10 @@ def check_inputs(
467467
if strength < 0 or strength > 1:
468468
raise ValueError(f"The value of strength should in [0.0, 1.0] but is {strength}")
469469

470-
if height % 8 != 0 or width % 8 != 0:
471-
raise ValueError(f"`height` and `width` have to be divisible by 8 but are {height} and {width}.")
470+
if height % self.vae_scale_factor != 0 or width % self.vae_scale_factor != 0:
471+
raise ValueError(
472+
f"`height` and `width` have to be divisible by {self.vae_scale_factor} but are {height} and {width}."
473+
)
472474

473475
if callback_on_step_end_tensor_inputs is not None and not all(
474476
k in self._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs
@@ -996,7 +998,9 @@ def __call__(
996998
# 6. Prepare timesteps
997999

9981000
sigmas = np.linspace(1.0, 1 / num_inference_steps, num_inference_steps)
999-
image_seq_len = (int(global_height) // self.vae_scale_factor // 2) * (int(global_width) // self.vae_scale_factor // 2)
1001+
image_seq_len = (int(global_height) // self.vae_scale_factor // 2) * (
1002+
int(global_width) // self.vae_scale_factor // 2
1003+
)
10001004
mu = calculate_shift(
10011005
image_seq_len,
10021006
self.scheduler.config.base_image_seq_len,

src/diffusers/pipelines/flux/pipeline_flux_img2img.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,10 @@ def check_inputs(
437437
if strength < 0 or strength > 1:
438438
raise ValueError(f"The value of strength should in [0.0, 1.0] but is {strength}")
439439

440-
if height % 8 != 0 or width % 8 != 0:
441-
raise ValueError(f"`height` and `width` have to be divisible by 8 but are {height} and {width}.")
440+
if height % self.vae_scale_factor != 0 or width % self.vae_scale_factor != 0:
441+
raise ValueError(
442+
f"`height` and `width` have to be divisible by {self.vae_scale_factor} but are {height} and {width}."
443+
)
442444

443445
if callback_on_step_end_tensor_inputs is not None and not all(
444446
k in self._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs

src/diffusers/pipelines/flux/pipeline_flux_inpaint.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,10 @@ def check_inputs(
445445
if strength < 0 or strength > 1:
446446
raise ValueError(f"The value of strength should in [0.0, 1.0] but is {strength}")
447447

448-
if height % 8 != 0 or width % 8 != 0:
449-
raise ValueError(f"`height` and `width` have to be divisible by 8 but are {height} and {width}.")
448+
if height % self.vae_scale_factor != 0 or width % self.vae_scale_factor != 0:
449+
raise ValueError(
450+
f"`height` and `width` have to be divisible by {self.vae_scale_factor} but are {height} and {width}."
451+
)
450452

451453
if callback_on_step_end_tensor_inputs is not None and not all(
452454
k in self._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs

0 commit comments

Comments
 (0)