Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions tests/pipelines/controlnet_flux/test_controlnet_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_dummy_inputs(self, device, seed=0):
(1, 3, 32, 32),
generator=generator,
device=torch.device(device),
dtype=torch.float16,
dtype=torch.float32,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: there's another dtype=torch.float16 at line 201 in test_flux_image_output_shape that wasn't updated. The pipe in that test defaults to float32, so the control_image will be float16 while the rest of the pipeline is float32. It probably doesn't break anything since that test only checks output shape, but for consistency it should likely be torch.float32 as well.

)

controlnet_conditioning_scale = 0.5
Expand All @@ -163,7 +163,7 @@ def get_dummy_inputs(self, device, seed=0):
def test_controlnet_flux(self):
components = self.get_dummy_components()
flux_pipe = FluxControlNetPipeline(**components)
flux_pipe = flux_pipe.to(torch_device, dtype=torch.float16)
flux_pipe = flux_pipe.to(torch_device, dtype=torch.float32)
flux_pipe.set_progress_bar_config(disable=None)

inputs = self.get_dummy_inputs(torch_device)
Expand All @@ -174,9 +174,7 @@ def test_controlnet_flux(self):

assert image.shape == (1, 32, 32, 3)

expected_slice = np.array(
[0.47387695, 0.63134766, 0.5605469, 0.61621094, 0.7207031, 0.7089844, 0.70410156, 0.6113281, 0.64160156]
)
expected_slice = np.array([0.6677, 0.6138, 0.5296, 0.6109, 0.5672, 0.6373, 0.5463, 0.6068, 0.5569])

assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2, (
f"Expected: {expected_slice}, got: {image_slice.flatten()}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_dummy_inputs(self, device, seed=0):
(1, 3, 16, 16),
generator=generator,
device=torch.device(device),
dtype=torch.float16,
dtype=torch.float32,
)

controlnet_conditioning_scale = 0.5
Expand All @@ -146,7 +146,7 @@ def get_dummy_inputs(self, device, seed=0):
def test_controlnet_hunyuandit(self):
components = self.get_dummy_components()
pipe = HunyuanDiTControlNetPipeline(**components)
pipe = pipe.to(torch_device, dtype=torch.float16)
pipe = pipe.to(torch_device, dtype=torch.float32)
pipe.set_progress_bar_config(disable=None)

inputs = self.get_dummy_inputs(torch_device)
Expand All @@ -156,14 +156,7 @@ def test_controlnet_hunyuandit(self):
image_slice = image[0, -3:, -3:, -1]
assert image.shape == (1, 16, 16, 3)

if torch_device == "xpu":
expected_slice = np.array(
[0.6948242, 0.89160156, 0.59375, 0.5078125, 0.57910156, 0.6035156, 0.58447266, 0.53564453, 0.52246094]
)
else:
expected_slice = np.array(
[0.6953125, 0.89208984, 0.59375, 0.5078125, 0.5786133, 0.6035156, 0.5839844, 0.53564453, 0.52246094]
)
expected_slice = np.array([0.5925, 0.5392, 0.4450, 0.7140, 0.3954, 0.3553, 0.3842, 0.5994, 0.3765])

assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2, (
f"Expected: {expected_slice}, got: {image_slice.flatten()}"
Expand Down
10 changes: 4 additions & 6 deletions tests/pipelines/controlnet_sd3/test_controlnet_inpaint_sd3.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ def get_dummy_inputs(self, device, seed=0):
(1, 3, 32, 32),
generator=generator,
device=torch.device(device),
dtype=torch.float16,
dtype=torch.float32,
)

control_mask = randn_tensor(
(1, 1, 32, 32),
generator=generator,
device=torch.device(device),
dtype=torch.float16,
dtype=torch.float32,
)

controlnet_conditioning_scale = 0.95
Expand All @@ -184,7 +184,7 @@ def get_dummy_inputs(self, device, seed=0):
def test_controlnet_inpaint_sd3(self):
components = self.get_dummy_components()
sd_pipe = StableDiffusion3ControlNetInpaintingPipeline(**components)
sd_pipe = sd_pipe.to(torch_device, dtype=torch.float16)
sd_pipe = sd_pipe.to(torch_device, dtype=torch.float32)
sd_pipe.set_progress_bar_config(disable=None)

inputs = self.get_dummy_inputs(torch_device)
Expand All @@ -195,9 +195,7 @@ def test_controlnet_inpaint_sd3(self):

assert image.shape == (1, 32, 32, 3)

expected_slice = np.array(
[0.51708984, 0.7421875, 0.4580078, 0.6435547, 0.65625, 0.43603516, 0.5151367, 0.65722656, 0.60839844]
)
expected_slice = np.array([0.2875, 0.3173, 0.4028, 0.7248, 0.6338, 0.4238, 0.1730, 0.4609, 0.5424])

assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2, (
f"Expected: {expected_slice}, got: {image_slice.flatten()}"
Expand Down
8 changes: 4 additions & 4 deletions tests/pipelines/controlnet_sd3/test_controlnet_sd3.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def get_dummy_inputs(self, device, seed=0):
(1, 3, 32, 32),
generator=generator,
device=torch.device(device),
dtype=torch.float16,
dtype=torch.float32,
)

controlnet_conditioning_scale = 0.5
Expand All @@ -192,7 +192,7 @@ def get_dummy_inputs(self, device, seed=0):

def run_pipe(self, components, use_sd35=False):
sd_pipe = StableDiffusion3ControlNetPipeline(**components)
sd_pipe = sd_pipe.to(torch_device, dtype=torch.float16)
sd_pipe = sd_pipe.to(torch_device, dtype=torch.float32)
sd_pipe.set_progress_bar_config(disable=None)

inputs = self.get_dummy_inputs(torch_device)
Expand All @@ -204,9 +204,9 @@ def run_pipe(self, components, use_sd35=False):
assert image.shape == (1, 32, 32, 3)

if not use_sd35:
expected_slice = np.array([0.5767, 0.7100, 0.5981, 0.5674, 0.5952, 0.4102, 0.5093, 0.5044, 0.6030])
expected_slice = np.array([0.4578, 0.3582, 0.4046, 0.0953, 0.6878, 0.5821, 0.5541, 0.5888, 0.4651])
else:
expected_slice = np.array([1.0000, 0.9072, 0.4209, 0.2744, 0.5737, 0.3840, 0.6113, 0.6250, 0.6328])
expected_slice = np.array([0.3721, 0.5626, 0.4657, 0.2845, 0.5241, 0.5917, 0.6265, 0.6955, 0.3969])

assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2, (
f"Expected: {expected_slice}, got: {image_slice.flatten()}"
Expand Down
Loading