Skip to content

Commit fb2397f

Browse files
committed
up
1 parent 71843a0 commit fb2397f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/diffusers/utils/hub_utils.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -405,20 +405,21 @@ def _get_checkpoint_shard_files(
405405
ignore_patterns = ["*.json", "*.md"]
406406
# `model_info` call must guarded with the above condition.
407407
local = False
408-
try:
409-
model_files_info = model_info(pretrained_model_name_or_path, revision=revision, token=token)
410-
except ConnectionError as e:
411-
if local_files_only:
412-
temp_dir = snapshot_download(
413-
repo_id=pretrained_model_name_or_path, cache_dir=cache_dir, local_files_only=local_files_only
414-
)
415-
model_files_info = _get_filepaths_for_folder(temp_dir)
416-
local = True
417-
else:
408+
if local_files_only:
409+
temp_dir = snapshot_download(
410+
repo_id=pretrained_model_name_or_path, cache_dir=cache_dir, local_files_only=local_files_only
411+
)
412+
model_files_info = _get_filepaths_for_folder(temp_dir)
413+
local = True
414+
else:
415+
try:
416+
model_files_info = model_info(pretrained_model_name_or_path, revision=revision, token=token)
417+
except ConnectionError as e:
418418
raise EnvironmentError(
419419
f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {pretrained_model_name_or_path}. You should try"
420420
" again after checking your internet connection."
421421
) from e
422+
422423
for shard_file in original_shard_filenames:
423424
if local:
424425
shard_file_present = any(shard_file in k for k in model_files_info)

0 commit comments

Comments
 (0)