Skip to content
Open
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
6 changes: 6 additions & 0 deletions src/diffusers/utils/dynamic_modules_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ def get_cached_module_file(
f"Pass `trust_remote_code=True` to allow loading remote code modules."
)
elif is_community_pipeline:
if not trust_remote_code:
raise ValueError(
f"Loading community pipeline '{pretrained_model_name_or_path}' requires executing code "
f"from the diffusers/community-pipelines-mirror dataset.\n"
f"Pass `trust_remote_code=True` to allow loading community pipeline code modules."
)
available_versions = get_diffusers_versions()
# cut ".dev0"
latest_version = "v" + ".".join(__version__.split(".")[:3])
Expand Down
13 changes: 11 additions & 2 deletions tests/pipelines/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,17 @@ def test_global_disable_remote_code(self):
)

def test_load_custom_github(self):
with self.assertRaises(ValueError) as cm:
DiffusionPipeline.from_pretrained(
"google/ddpm-cifar10-32", custom_pipeline="one_step_unet", custom_revision="main"
)
self.assertIn(
"Pass `trust_remote_code=True` to allow loading community pipeline code modules.",
str(cm.exception),
)

pipeline = DiffusionPipeline.from_pretrained(
"google/ddpm-cifar10-32", custom_pipeline="one_step_unet", custom_revision="main"
"google/ddpm-cifar10-32", custom_pipeline="one_step_unet", custom_revision="main", trust_remote_code=True
)

# make sure that on "main" pipeline gives only ones because of: https://github.com/huggingface/diffusers/pull/1690
Expand All @@ -1079,7 +1088,7 @@ def test_load_custom_github(self):
del sys.modules["diffusers_modules.git.one_step_unet"]

pipeline = DiffusionPipeline.from_pretrained(
"google/ddpm-cifar10-32", custom_pipeline="one_step_unet", custom_revision="0.10.2"
"google/ddpm-cifar10-32", custom_pipeline="one_step_unet", custom_revision="0.10.2", trust_remote_code=True
)
with torch.no_grad():
output = pipeline()
Expand Down
Loading