From 1d5fb39ade5c36adab8e7bf58ea4f89df8da13d4 Mon Sep 17 00:00:00 2001 From: Ella Charlaix Date: Thu, 26 Oct 2023 10:51:51 +0200 Subject: [PATCH] format --- optimum/intel/__init__.py | 4 ++-- optimum/intel/openvino/__init__.py | 2 +- optimum/intel/openvino/modeling_diffusion.py | 4 +--- .../intel/utils/dummy_openvino_and_diffusers_objects.py | 2 -- tests/openvino/test_stable_diffusion.py | 9 +++------ 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/optimum/intel/__init__.py b/optimum/intel/__init__.py index cd93a68c66..5fe65dcd41 100644 --- a/optimum/intel/__init__.py +++ b/optimum/intel/__init__.py @@ -160,20 +160,20 @@ raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from .utils.dummy_openvino_and_diffusers_objects import ( + OVLatentConsistencyModelPipeline, OVStableDiffusionImg2ImgPipeline, OVStableDiffusionInpaintPipeline, OVStableDiffusionPipeline, OVStableDiffusionXLImg2ImgPipeline, - OVLatentConsistencyModelPipeline, OVStableDiffusionXLPipeline, ) else: from .openvino import ( + OVLatentConsistencyModelPipeline, OVStableDiffusionImg2ImgPipeline, OVStableDiffusionInpaintPipeline, OVStableDiffusionPipeline, OVStableDiffusionXLImg2ImgPipeline, - OVLatentConsistencyModelPipeline, OVStableDiffusionXLPipeline, ) diff --git a/optimum/intel/openvino/__init__.py b/optimum/intel/openvino/__init__.py index a7bcbfbce0..7ed550ceb0 100644 --- a/optimum/intel/openvino/__init__.py +++ b/optimum/intel/openvino/__init__.py @@ -51,10 +51,10 @@ if is_diffusers_available(): from .modeling_diffusion import ( + OVLatentConsistencyModelPipeline, OVStableDiffusionImg2ImgPipeline, OVStableDiffusionInpaintPipeline, OVStableDiffusionPipeline, OVStableDiffusionXLImg2ImgPipeline, OVStableDiffusionXLPipeline, - OVLatentConsistencyModelPipeline, ) diff --git a/optimum/intel/openvino/modeling_diffusion.py b/optimum/intel/openvino/modeling_diffusion.py index bc63268bdb..2d0a31b428 100644 --- a/optimum/intel/openvino/modeling_diffusion.py +++ b/optimum/intel/openvino/modeling_diffusion.py @@ -37,13 +37,12 @@ from openvino.runtime import Core from transformers import CLIPFeatureExtractor, CLIPTokenizer +from optimum.pipelines.diffusers.pipeline_latent_consistency import LatentConsistencyPipelineMixin from optimum.pipelines.diffusers.pipeline_stable_diffusion import StableDiffusionPipelineMixin from optimum.pipelines.diffusers.pipeline_stable_diffusion_img2img import StableDiffusionImg2ImgPipelineMixin from optimum.pipelines.diffusers.pipeline_stable_diffusion_inpaint import StableDiffusionInpaintPipelineMixin from optimum.pipelines.diffusers.pipeline_stable_diffusion_xl import StableDiffusionXLPipelineMixin from optimum.pipelines.diffusers.pipeline_stable_diffusion_xl_img2img import StableDiffusionXLImg2ImgPipelineMixin -from optimum.pipelines.diffusers.pipeline_latent_consistency import LatentConsistencyPipelineMixin - from optimum.pipelines.diffusers.pipeline_utils import VaeImageProcessor from optimum.utils import ( DIFFUSION_MODEL_TEXT_ENCODER_2_SUBFOLDER, @@ -274,7 +273,6 @@ def _from_pretrained( return cls(unet=unet, config=config, model_save_dir=model_save_dir, **components, **kwargs) - @classmethod def _from_transformers( cls, diff --git a/optimum/intel/utils/dummy_openvino_and_diffusers_objects.py b/optimum/intel/utils/dummy_openvino_and_diffusers_objects.py index 0b108cc5f7..78016ea71c 100644 --- a/optimum/intel/utils/dummy_openvino_and_diffusers_objects.py +++ b/optimum/intel/utils/dummy_openvino_and_diffusers_objects.py @@ -70,7 +70,6 @@ def from_pretrained(cls, *args, **kwargs): requires_backends(cls, ["openvino", "diffusers"]) - class OVLatentConsistencyModelPipeline(metaclass=DummyObject): _backends = ["openvino", "diffusers"] @@ -80,4 +79,3 @@ def __init__(self, *args, **kwargs): @classmethod def from_pretrained(cls, *args, **kwargs): requires_backends(cls, ["openvino", "diffusers"]) - diff --git a/tests/openvino/test_stable_diffusion.py b/tests/openvino/test_stable_diffusion.py index 5e25a7eb48..1fce7c3fc8 100644 --- a/tests/openvino/test_stable_diffusion.py +++ b/tests/openvino/test_stable_diffusion.py @@ -25,22 +25,21 @@ StableDiffusionXLImg2ImgPipeline, StableDiffusionXLPipeline, ) -from packaging.version import Version, parse from diffusers.utils import load_image from diffusers.utils.testing_utils import floats_tensor from openvino.runtime.ie_api import CompiledModel +from packaging.version import Version, parse from parameterized import parameterized from utils_tests import MODEL_NAMES, SEED from optimum.intel import ( + OVLatentConsistencyModelPipeline, OVStableDiffusionImg2ImgPipeline, OVStableDiffusionInpaintPipeline, OVStableDiffusionPipeline, OVStableDiffusionXLImg2ImgPipeline, OVStableDiffusionXLPipeline, - OVLatentConsistencyModelPipeline, ) -from optimum.utils.import_utils import _diffusers_version from optimum.intel.openvino.modeling_diffusion import ( OVModelTextEncoder, OVModelUnet, @@ -53,6 +52,7 @@ ORTStableDiffusionXLImg2ImgPipeline, ORTStableDiffusionXLPipeline, ) +from optimum.utils.import_utils import _diffusers_version def _generate_inputs(batch_size=1): @@ -528,7 +528,6 @@ def test_compare_to_diffusers(self, model_arch: str): # Compare model devices self.assertEqual(pipeline.device.type, ov_pipeline.device) - @parameterized.expand(SUPPORTED_ARCHITECTURES) @unittest.skipIf(parse(_diffusers_version) <= Version("0.21.4"), "not supported with this diffusers version") def test_num_images_per_prompt_static_model(self, model_arch: str): @@ -544,5 +543,3 @@ def test_num_images_per_prompt_static_model(self, model_arch: str): inputs = _generate_inputs(batch_size) outputs = pipeline(**inputs, num_images_per_prompt=num_images, height=_height, width=width).images self.assertEqual(outputs.shape, (batch_size * num_images, height, width, 3)) - -