Skip to content

Commit 6a163c7

Browse files
committed
error out when custom pipeline is passed with dduf_file.
1 parent 0fbea9a commit 6a163c7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/diffusers/pipelines/pipeline_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
728728
" dispatching. Please make sure to set `low_cpu_mem_usage=True`."
729729
)
730730

731+
if dduf_file and custom_pipeline:
732+
raise NotImplementedError("Custom pipelines are not supported with DDUF at the moment.")
733+
731734
# 1. Download the checkpoints and configs
732735
# use snapshot download here to get it working from from_pretrained
733736
if not os.path.isdir(pretrained_model_name_or_path):
@@ -1325,6 +1328,9 @@ def download(cls, pretrained_model_name, **kwargs) -> Union[str, os.PathLike]:
13251328
trust_remote_code = kwargs.pop("trust_remote_code", False)
13261329
dduf_file: Optional[Dict[str, DDUFEntry]] = kwargs.pop("dduf_file", None)
13271330

1331+
if dduf_file and custom_pipeline:
1332+
raise NotImplementedError("Custom pipelines are not supported with DDUF at the moment.")
1333+
13281334
allow_pickle = False
13291335
if use_safetensors is None:
13301336
use_safetensors = True
@@ -1488,7 +1494,7 @@ def download(cls, pretrained_model_name, **kwargs) -> Union[str, os.PathLike]:
14881494
return snapshot_folder
14891495

14901496
user_agent = {"pipeline_class": cls.__name__}
1491-
if not dduf_file and custom_pipeline is not None and not custom_pipeline.endswith(".py"):
1497+
if custom_pipeline is not None and not custom_pipeline.endswith(".py"):
14921498
user_agent["custom_pipeline"] = custom_pipeline
14931499

14941500
# download all allow_patterns - ignore_patterns

tests/pipelines/test_pipelines.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,12 @@ def test_download_ignore_files(self):
983983
assert not any(f in ["vae/diffusion_pytorch_model.bin", "text_encoder/config.json"] for f in files)
984984
assert len(files) == 14
985985

986+
def test_download_dduf_with_custom_pipeline_raises_error(self):
987+
with self.assertRaises(NotImplementedError):
988+
_ = DiffusionPipeline.download(
989+
"DDUF/tiny-flux-dev-pipe-dduf", dduf_file="fluxpipeline.dduf", custom_pipeline="my_pipeline"
990+
)
991+
986992
def test_get_pipeline_class_from_flax(self):
987993
flax_config = {"_class_name": "FlaxStableDiffusionPipeline"}
988994
config = {"_class_name": "StableDiffusionPipeline"}
@@ -1823,6 +1829,14 @@ def test_load_dduf_from_hub(self, dtype):
18231829

18241830
self.assertTrue(np.allclose(out_1, out_2, atol=1e-4, rtol=1e-4))
18251831

1832+
@require_hf_hub_version_greater("0.26.5")
1833+
@require_transformers_version_greater("4.47.1")
1834+
def test_dduf_raises_error_with_custom_pipeline(self):
1835+
with self.assertRaises(NotImplementedError):
1836+
_ = DiffusionPipeline.from_pretrained(
1837+
"DDUF/tiny-flux-dev-pipe-dduf", dduf_file="fluxpipeline.dduf", custom_pipeline="my_pipeline"
1838+
)
1839+
18261840
def test_wrong_model(self):
18271841
tokenizer = CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip")
18281842
with self.assertRaises(ValueError) as error_context:

0 commit comments

Comments
 (0)