Skip to content

Commit c493231

Browse files
committed
check that pipeline exists before trying to init it
1 parent db361f0 commit c493231

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

app.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,21 @@
3535
def createPipelinesFromModel(model):
3636
pipelines = dict()
3737
for pipeline in PIPELINES:
38-
if hasattr(model, "components"):
39-
pipelines[pipeline] = getattr(_pipelines, pipeline)(**model.components)
38+
if hasattr(_pipelines, pipeline):
39+
if hasattr(model, "components"):
40+
pipelines[pipeline] = getattr(_pipelines, pipeline)(**model.components)
41+
else:
42+
pipelines[pipeline] = getattr(_pipelines, pipeline)(
43+
vae=model.vae,
44+
text_encoder=model.text_encoder,
45+
tokenizer=model.tokenizer,
46+
unet=model.unet,
47+
scheduler=model.scheduler,
48+
safety_checker=model.safety_checker,
49+
feature_extractor=model.feature_extractor,
50+
)
4051
else:
41-
pipelines[pipeline] = getattr(_pipelines, pipeline)(
42-
vae=model.vae,
43-
text_encoder=model.text_encoder,
44-
tokenizer=model.tokenizer,
45-
unet=model.unet,
46-
scheduler=model.scheduler,
47-
safety_checker=model.safety_checker,
48-
feature_extractor=model.feature_extractor,
49-
)
52+
print(f'Skipping non-existent pipeline "{PIPELINE}"')
5053
return pipelines
5154

5255

0 commit comments

Comments
 (0)