diff --git a/src/diffusers/pipelines/pipeline_loading_utils.py b/src/diffusers/pipelines/pipeline_loading_utils.py index c16bd8ac2069..5eba1952e608 100644 --- a/src/diffusers/pipelines/pipeline_loading_utils.py +++ b/src/diffusers/pipelines/pipeline_loading_utils.py @@ -118,6 +118,10 @@ def is_safetensors_compatible(filenames, passed_components=None, folder_names=No components.setdefault(component, []) components[component].append(component_filename) + # If there are no component folders check the main directory for safetensors files + if not components: + return any(".safetensors" in filename for filename in filenames) + # iterate over all files of a component # check if safetensor files exist for that component # if variant is provided check if the variant of the safetensors exists diff --git a/tests/pipelines/test_pipeline_utils.py b/tests/pipelines/test_pipeline_utils.py index 5eedd393c8f8..bb3bdc273cc4 100644 --- a/tests/pipelines/test_pipeline_utils.py +++ b/tests/pipelines/test_pipeline_utils.py @@ -197,6 +197,18 @@ def test_diffusers_is_compatible_only_variants(self): ] self.assertTrue(is_safetensors_compatible(filenames)) + def test_diffusers_is_compatible_no_components(self): + filenames = [ + "diffusion_pytorch_model.bin", + ] + self.assertFalse(is_safetensors_compatible(filenames)) + + def test_diffusers_is_compatible_no_components_only_variants(self): + filenames = [ + "diffusion_pytorch_model.fp16.bin", + ] + self.assertFalse(is_safetensors_compatible(filenames)) + class ProgressBarTests(unittest.TestCase): def get_dummy_components_image_generation(self):