Skip to content

Commit ad62f41

Browse files
feat: support stable diffusion 2-1 with openvino & qnn (microsoft#374)
Co-authored-by: Ziyuan Guo (WE TEAM) <ziyuanguo@microsoft.com>
1 parent a12eac2 commit ad62f41

42 files changed

Lines changed: 4743 additions & 256 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.aitk/configs/checks.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"configCheck": 163,
3-
"copyCheck": 177,
2+
"configCheck": 165,
3+
"copyCheck": 180,
44
"extensionCheck": 2,
5-
"gitignoreCheck": 41,
5+
"gitignoreCheck": 42,
66
"inferenceModelCheck": 25,
7-
"ipynbCheck": 40,
8-
"licenseCheck": 38,
9-
"modelProjectCheck": 43,
7+
"ipynbCheck": 42,
8+
"licenseCheck": 39,
9+
"modelProjectCheck": 44,
1010
"oliveCheck": 60,
11-
"oliveJsonCheck": 163,
12-
"pathCheck": 1372,
11+
"oliveJsonCheck": 165,
12+
"pathCheck": 1397,
1313
"requirementsCheck": 37,
1414
"templateCheck": 3,
1515
"venvRequirementsCheck": 16

.aitk/configs/model_list.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,24 @@
800800
"text-generation"
801801
]
802802
},
803+
{
804+
"displayName": "sd2-community/stable-diffusion-2-1",
805+
"icon": "HuggingFace",
806+
"modelLink": "https://huggingface.co/sd2-community/stable-diffusion-2-1",
807+
"id": "huggingface/sd2-community/stable-diffusion-2-1",
808+
"runtimes": [
809+
"QNN",
810+
"IntelCPU",
811+
"IntelGPU"
812+
],
813+
"architecture": "Transformer",
814+
"status": "Hide",
815+
"relativePath": "sd2-community-stable-diffusion-2-1/aitk",
816+
"version": 1,
817+
"pipeline_tags": [
818+
"text-to-image"
819+
]
820+
},
803821
{
804822
"displayName": "stable-diffusion-v1-5/stable-diffusion-v1-5",
805823
"icon": "HuggingFace",

.aitk/scripts/project_processor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def fetch_pipeline_tags(model_link: str) -> Optional[List[str]]:
5454
# TODO add
5555
"OFA-Sys": IconEnum.HuggingFace,
5656
"stable-diffusion-v1-5": IconEnum.HuggingFace,
57+
"sd2-community": IconEnum.HuggingFace,
5758
}
5859

5960

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"copies": [
3+
{
4+
"src": "../../intel-bert-base-uncased-mrpc/aitk/winml.py",
5+
"dst": "winml.py"
6+
}
7+
]
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"copies": [
3+
{
4+
"src": "../../intel-bert-base-uncased-mrpc/aitk/winml.py",
5+
"dst": "winml.py"
6+
}
7+
]
8+
}

sd-legacy-stable-diffusion-v1-5/aitk/evaluation.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,8 @@ def main(raw_args=None):
263263
optimized_model_dir = script_dir / "model" / optimized_dir_name / args.model_id
264264

265265
model_dir = unoptimized_model_dir if args.save_data else optimized_model_dir
266-
if args.xl:
267-
from sd_utils.qdq_xl import ORTStableDiffusionXLPipelineWithSave
268266

269-
pipeline = ORTStableDiffusionXLPipelineWithSave.from_pretrained(model_dir, provider=args.provider)
270-
else:
271-
pipeline = OnnxStableDiffusionPipelineWithSave.from_pretrained(model_dir, provider=args.provider)
267+
pipeline = OnnxStableDiffusionPipelineWithSave.from_pretrained(model_dir, provider=args.provider)
272268
pipeline.save_data_dir = None
273269

274270
if args.save_data:

sd-legacy-stable-diffusion-v1-5/aitk/sd_ov_evaluation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def main(raw_args=None):
102102
pipeline = OVStableDiffusionPipeline.from_pretrained(
103103
model_dir, provider=args.execution_provider, sess_options=sess_options, provider_options=provider_options
104104
)
105-
pipeline.save_data_dir = None
106105

107106
text_encoder_latencies = []
108107
unet_latencies = []

sd-legacy-stable-diffusion-v1-5/aitk/sd_qnn_evaluation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def main(raw_args=None):
102102
pipeline = OnnxStableDiffusionPipelineWithSave.from_pretrained(
103103
model_dir, provider=args.execution_provider, sess_options=sess_options, provider_options=provider_options
104104
)
105+
pipeline.save_data_dir = None
105106

106107
text_encoder_latencies = []
107108
unet_latencies = []

sd-legacy-stable-diffusion-v1-5/aitk/sd_utils/qdq_xl.py

Lines changed: 0 additions & 238 deletions
This file was deleted.

sd-legacy-stable-diffusion-v1-5/aitk/stable_diffusion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import argparse
66
import json
77
import shutil
8-
import sys
98
import warnings
109
from pathlib import Path
1110

@@ -384,7 +383,7 @@ def main(raw_args=None):
384383
unoptimized_model_dir = script_dir / "model" / "unoptimized" / model_id
385384
optimized_model_dir = script_dir / "model" / "optimized" / model_id
386385

387-
if common_args.clean_cache:
386+
if common_args.clean_cache and common_args.cache_dir:
388387
shutil.rmtree(common_args.cache_dir, ignore_errors=True)
389388

390389
guidance_scale = common_args.guidance_scale

0 commit comments

Comments
 (0)