Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use StableDiffusionXLPipeline_HPU #1300

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
12 changes: 12 additions & 0 deletions examples/stable-diffusion/text_to_image_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ def main():
action="store_true",
help="Enable deterministic generation using CPU Generator",
)
parser.add_argument(
"--mlperf",
action="store_true",
help="Use StableDiffusionXLPipeline_HPU",
)
args = parser.parse_args()

# Select stable diffuson pipeline based on input
Expand All @@ -279,6 +284,7 @@ def main():
sd3 = True if any(model in args.model_name_or_path for model in sd3_models) else False
controlnet = True if args.control_image is not None else False
inpainting = True if (args.base_image is not None) and (args.mask_image is not None) else False
mlperf = True if (args.mlperf is not None) and (args.mlperf is not None) else False

# Set the scheduler
kwargs = {"timestep_spacing": args.timestep_spacing}
Expand Down Expand Up @@ -401,6 +407,12 @@ def main():

pipeline = AutoPipelineForInpainting.from_pretrained(args.model_name_or_path, **kwargs)

elif mlperf:
# Import SDXL HPU pipeline
from optimum.habana.diffusers import StableDiffusionXLPipeline_HPU

pipeline = StableDiffusionXLPipeline_HPU.from_pretrained(args.model_name_or_path, **kwargs)

else:
# Import SDXL pipeline
from optimum.habana.diffusers import GaudiStableDiffusionXLPipeline
Expand Down
1 change: 1 addition & 0 deletions optimum/habana/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .pipelines.stable_diffusion.pipeline_stable_diffusion_upscale import GaudiStableDiffusionUpscalePipeline
from .pipelines.stable_diffusion_3.pipeline_stable_diffusion_3 import GaudiStableDiffusion3Pipeline
from .pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl import GaudiStableDiffusionXLPipeline
from .pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl_mlperf import StableDiffusionXLPipeline_HPU
from .pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl_img2img import GaudiStableDiffusionXLImg2ImgPipeline
from .pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl_inpaint import GaudiStableDiffusionXLInpaintPipeline
from .pipelines.stable_video_diffusion.pipeline_stable_video_diffusion import GaudiStableVideoDiffusionPipeline
Expand Down