Skip to content

Commit

Permalink
make style
Browse files Browse the repository at this point in the history
  • Loading branch information
JingyaHuang committed Sep 9, 2024
1 parent 813af33 commit 9781263
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion optimum/neuron/pipelines/diffusers/pipeline_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,11 @@ def __call__(
)
else:
for i, scale in enumerate(cond_scale):
new_scale = torch.tensor([scale]).repeat(2) if self.data_parallel_mode == "unet" else torch.tensor(scale)
new_scale = (
torch.tensor([scale]).repeat(2)
if self.data_parallel_mode == "unet"
else torch.tensor(scale)
)
cond_scale[i] = new_scale

down_block_res_samples, mid_block_res_sample = self.controlnet(
Expand Down
12 changes: 6 additions & 6 deletions tests/inference/test_stable_diffusion_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
)
from optimum.neuron.modeling_diffusion import (
NeuronControlNetModel,
NeuronMultiControlNetModel,
NeuronModelTextEncoder,
NeuronModelUnet,
NeuronModelVaeDecoder,
NeuronModelVaeEncoder,
NeuronMultiControlNetModel,
)
from optimum.neuron.utils.testing_utils import is_inferentia_test, requires_neuronx
from optimum.utils import logging
Expand Down Expand Up @@ -225,9 +225,9 @@ def prepare_canny_image(image_url=None):
image = image[:, :, None]
image = np.concatenate([image, image, image], axis=2)
canny_image = PIL.Image.fromarray(image)
return canny_image

return canny_image

@parameterized.expand(SUPPORTED_ARCHITECTURES, skip_on_empty=True)
def test_export_and_inference_with_single_controlnet(self, model_arch):
input_shapes = copy.deepcopy(self.STATIC_INPUTS_SHAPES)
Expand All @@ -251,13 +251,13 @@ def test_export_and_inference_with_single_controlnet(self, model_arch):
image = neuron_pipeline(prompt, image=canny_image).images[0]
neuron_pipeline.scheduler = UniPCMultistepScheduler.from_config(neuron_pipeline.scheduler.config)
self.assertIsInstance(image, PIL.Image.Image)

@parameterized.expand(SUPPORTED_ARCHITECTURES, skip_on_empty=True)
def test_export_and_inference_with_multiple_controlnet(self, model_arch):
input_shapes = copy.deepcopy(self.STATIC_INPUTS_SHAPES)
input_shapes.update({"num_images_per_prompt": 1})
controlnet_id = "hf-internal-testing/tiny-controlnet"

neuron_pipeline = NeuronStableDiffusionControlNetPipeline.from_pretrained(
MODEL_NAMES[model_arch],
controlnet_ids=[controlnet_id, controlnet_id],
Expand Down

0 comments on commit 9781263

Please sign in to comment.