Skip to content

Commit 82ba6cd

Browse files
committed
fix subfolder
1 parent a7cfa5d commit 82ba6cd

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

optimum/intel/openvino/modeling_base.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,9 @@ def from_pretrained(
608608
)
609609

610610
if export is None:
611-
export = cls._check_export_status(model_id, revision, subfolder, cache_dir, local_files_only or HF_HUB_OFFLINE)
612-
611+
export = cls._check_export_status(
612+
model_id, revision, subfolder, cache_dir, local_files_only or HF_HUB_OFFLINE
613+
)
613614
if not export and trust_remote_code:
614615
logger.warning(
615616
"The argument `trust_remote_code` is to be used along with export=True. It will be ignored."
@@ -642,15 +643,15 @@ def _check_export_status(
642643
local_files_only: bool = HF_HUB_OFFLINE,
643644
):
644645
model_dir = Path(model_id)
645-
if subfolder is not None:
646+
if subfolder:
646647
model_dir = model_dir / subfolder
647648
if model_dir.is_dir():
648649
return (
649650
not (model_dir / OV_XML_FILE_NAME).exists()
650651
or not (model_dir / OV_XML_FILE_NAME.replace(".xml", ".bin")).exists()
651652
)
652-
normalized_subfolder = None if subfolder is None else Path(subfolder).as_posix()
653-
ov_model_path = OV_XML_FILE_NAME if subfolder is None else f"{normalized_subfolder}/{OV_XML_FILE_NAME}"
653+
normalized_subfolder = None if not subfolder else Path(subfolder).as_posix()
654+
ov_model_path = OV_XML_FILE_NAME if not subfolder else f"{normalized_subfolder}/{OV_XML_FILE_NAME}"
654655
cache_model_path = try_to_load_from_cache(
655656
model_id, ov_model_path, cache_dir=cache_dir, revision=revision or "main", repo_type="model"
656657
)

optimum/intel/openvino/modeling_base_seq2seq.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,14 @@ def _check_export_status(
406406
hf_api = HfApi()
407407
try:
408408
model_info = hf_api.model_info(model_id, revision=revision or "main")
409-
normalized_subfolder = None if subfolder is None else Path(subfolder).as_posix()
409+
normalized_subfolder = None if not subfolder else Path(subfolder).as_posix()
410410
model_files = [
411411
file.rfilename
412412
for file in model_info.siblings
413413
if normalized_subfolder is None or file.rfilename.startswith(normalized_subfolder)
414414
]
415415
for model_name in [OV_ENCODER_NAME, OV_DECODER_NAME]:
416-
ov_model_path = model_name if subfolder is None else f"{normalized_subfolder}/{model_name}"
416+
ov_model_path = model_name if not subfolder else f"{normalized_subfolder}/{model_name}"
417417
if ov_model_path not in model_files or ov_model_path.replace(".xml", ".bin") not in model_files:
418418
return True
419419
return False

optimum/intel/openvino/modeling_diffusion.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -424,16 +424,16 @@ def _check_export_status(
424424

425425
def check_model_part_status(model_id, subfolder, revision):
426426
model_dir = Path(model_id)
427-
if subfolder is not None:
427+
if subfolder:
428428
model_dir = model_dir / subfolder
429429
if model_dir.is_dir():
430430
return (
431431
not (model_dir / OV_XML_FILE_NAME).exists()
432432
or not (model_dir / OV_XML_FILE_NAME.replace(".xml", ".bin")).exists()
433433
)
434434

435-
normalized_subfolder = None if subfolder is None else Path(subfolder).as_posix()
436-
ov_model_path = OV_XML_FILE_NAME if subfolder is None else f"{normalized_subfolder}/{OV_XML_FILE_NAME}"
435+
normalized_subfolder = None if not subfolder else Path(subfolder).as_posix()
436+
ov_model_path = OV_XML_FILE_NAME if not subfolder else f"{normalized_subfolder}/{OV_XML_FILE_NAME}"
437437
cache_model_path = try_to_load_from_cache(
438438
model_id, ov_model_path, cache_dir=cache_dir, revision=revision or "main", repo_type="model"
439439
)
@@ -455,9 +455,7 @@ def check_model_part_status(model_id, subfolder, revision):
455455
for file in model_info.siblings
456456
if normalized_subfolder is None or file.rfilename.startswith(normalized_subfolder)
457457
]
458-
ov_model_path = (
459-
OV_XML_FILE_NAME if subfolder is None else f"{normalized_subfolder}/{OV_XML_FILE_NAME}"
460-
)
458+
ov_model_path = OV_XML_FILE_NAME if not subfolder else f"{normalized_subfolder}/{OV_XML_FILE_NAME}"
461459
return ov_model_path not in model_files or ov_model_path.replace(".xml", ".bin") not in model_files
462460
except Exception:
463461
return True

0 commit comments

Comments
 (0)