Skip to content

Commit 20311cf

Browse files
committed
fix(pipelines): pass revision/precision for community pipelines too
1 parent 4c7e32e commit 20311cf

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

api/app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,13 @@ def sendStatus():
270270
pipeline_name = "StableDiffusionPipeline"
271271
result["$meta"].update({"PIPELINE": pipeline_name})
272272

273-
pipeline = getPipelineForModel(pipeline_name, model, normalized_model_id)
273+
pipeline = getPipelineForModel(
274+
pipeline_name,
275+
model,
276+
normalized_model_id,
277+
model_revision=model_revision if RUNTIME_DOWNLOADS else MODEL_REVISION,
278+
model_precision=model_precision if RUNTIME_DOWNLOADS else MODEL_PRECISION,
279+
)
274280
if not pipeline:
275281
return {
276282
"$error": {

api/getPipeline.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
DiffusionPipeline,
55
pipelines as diffusers_pipelines,
66
)
7+
from precision import torch_dtype_from_precision
78

89
HOME = os.path.expanduser("~")
910
MODELS_DIR = os.path.join(HOME, ".cache", "diffusers-api")
@@ -47,7 +48,9 @@ def clearPipelines():
4748
_pipelines = {}
4849

4950

50-
def getPipelineForModel(pipeline_name: str, model, model_id):
51+
def getPipelineForModel(
52+
pipeline_name: str, model, model_id, model_revision, model_precision
53+
):
5154
"""
5255
Inits a new pipeline, re-using components from a previously loaded
5356
model. The pipeline is cached and future calls with the same
@@ -82,8 +85,8 @@ def getPipelineForModel(pipeline_name: str, model, model_id):
8285

8386
pipeline = DiffusionPipeline.from_pretrained(
8487
model_dir or model_id,
85-
# revision=revision,
86-
# torch_dtype=torch_dtype,
88+
revision=model_revision,
89+
torch_dtype=torch_dtype_from_precision(model_precision),
8790
custom_pipeline="./diffusers/examples/community/" + pipeline_name + ".py",
8891
local_files_only=True,
8992
**model.components,

0 commit comments

Comments
 (0)