Skip to content

Commit b7af511

Browse files
committed
reviewer feedback.
1 parent 01784c3 commit b7af511

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/diffusers/utils/hub_utils.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
ModelCardData,
3131
create_repo,
3232
hf_hub_download,
33-
model_info,
3433
snapshot_download,
3534
upload_folder,
3635
)
@@ -403,28 +402,19 @@ def _get_checkpoint_shard_files(
403402
allow_patterns = [os.path.join(subfolder, p) for p in allow_patterns]
404403

405404
ignore_patterns = ["*.json", "*.md"]
406-
# `model_info` call must guarded with the above condition.
407-
local = False
408-
if local_files_only:
405+
try:
409406
temp_dir = snapshot_download(
410407
repo_id=pretrained_model_name_or_path, cache_dir=cache_dir, local_files_only=local_files_only
411408
)
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:
418-
raise EnvironmentError(
419-
f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {pretrained_model_name_or_path}. You should try"
420-
" again after checking your internet connection."
421-
) from e
409+
except ConnectionError as e:
410+
raise EnvironmentError(
411+
f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {pretrained_model_name_or_path}. You should try"
412+
" again after checking your internet connection."
413+
) from e
422414

415+
model_files_info = _get_filepaths_for_folder(temp_dir)
423416
for shard_file in original_shard_filenames:
424-
if local:
425-
shard_file_present = any(shard_file in k for k in model_files_info)
426-
else:
427-
shard_file_present = any(shard_file in k.rfilename for k in model_files_info.siblings)
417+
shard_file_present = any(shard_file in k for k in model_files_info)
428418
if not shard_file_present:
429419
raise EnvironmentError(
430420
f"{shards_path} does not appear to have a file named {shard_file} which is "

0 commit comments

Comments
 (0)