Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
echarlaix committed Oct 26, 2023
1 parent ca84adb commit 1d5fb39
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions optimum/intel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
2 changes: 1 addition & 1 deletion optimum/intel/openvino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@

if is_diffusers_available():
from .modeling_diffusion import (
OVLatentConsistencyModelPipeline,
OVStableDiffusionImg2ImgPipeline,
OVStableDiffusionInpaintPipeline,
OVStableDiffusionPipeline,
OVStableDiffusionXLImg2ImgPipeline,
OVStableDiffusionXLPipeline,
OVLatentConsistencyModelPipeline,
)
4 changes: 1 addition & 3 deletions optimum/intel/openvino/modeling_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions optimum/intel/utils/dummy_openvino_and_diffusers_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def from_pretrained(cls, *args, **kwargs):
requires_backends(cls, ["openvino", "diffusers"])



class OVLatentConsistencyModelPipeline(metaclass=DummyObject):
_backends = ["openvino", "diffusers"]

Expand All @@ -80,4 +79,3 @@ def __init__(self, *args, **kwargs):
@classmethod
def from_pretrained(cls, *args, **kwargs):
requires_backends(cls, ["openvino", "diffusers"])

9 changes: 3 additions & 6 deletions tests/openvino/test_stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -53,6 +52,7 @@
ORTStableDiffusionXLImg2ImgPipeline,
ORTStableDiffusionXLPipeline,
)
from optimum.utils.import_utils import _diffusers_version


def _generate_inputs(batch_size=1):
Expand Down Expand Up @@ -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):
Expand All @@ -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))


0 comments on commit 1d5fb39

Please sign in to comment.