You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: paddlex/inference/utils/official_models.py
+25-8Lines changed: 25 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@
31
31
from ...utilsimportlogging
32
32
from ...utils.cacheimportCACHE_DIR
33
33
from ...utils.downloadimportdownload_and_extract
34
-
from ...utils.flagsimportMODEL_SOURCE
34
+
from ...utils.flagsimportDISABLE_MODEL_SOURCE_CHECK, MODEL_SOURCE
35
35
36
36
ALL_MODELS= [
37
37
"ResNet18",
@@ -541,18 +541,35 @@ def _clone(local_dir):
541
541
class_ModelManager:
542
542
model_list=ALL_MODELS
543
543
_save_dir=Path(CACHE_DIR) /"official_models"
544
+
hoster_candidates= [
545
+
_HuggingFaceModelHoster,
546
+
_AIStudioModelHoster,
547
+
_ModelScopeModelHoster,
548
+
_BosModelHoster,
549
+
]
544
550
545
551
def__init__(self) ->None:
546
552
self._hosters=self._build_hosters()
547
553
548
554
def_build_hosters(self):
555
+
556
+
ifDISABLE_MODEL_SOURCE_CHECK:
557
+
logging.warning(
558
+
f"Connectivity check to the model hoster has been skipped because `DISABLE_MODEL_SOURCE_CHECK` is enabled."
559
+
)
560
+
hosters= []
561
+
forhoster_clsinself.hoster_candidates:
562
+
ifhoster_cls.alias==MODEL_SOURCE:
563
+
hosters.insert(0, hoster_cls(self._save_dir))
564
+
else:
565
+
hosters.append(hoster_cls(self._save_dir))
566
+
returnhosters
567
+
568
+
logging.warning(
569
+
f"Checking connectivity to the model hosters, this may take a while. To bypass this check, set `DISABLE_MODEL_SOURCE_CHECK` to `True`."
570
+
)
549
571
hosters= []
550
-
forhoster_clsin [
551
-
_HuggingFaceModelHoster,
552
-
_AIStudioModelHoster,
553
-
_ModelScopeModelHoster,
554
-
_BosModelHoster,
555
-
]:
572
+
forhoster_clsinself.hoster_candidates:
556
573
ifhoster_cls.alias==MODEL_SOURCE:
557
574
ifhoster_cls.is_available():
558
575
hosters.insert(0, hoster_cls(self._save_dir))
@@ -561,7 +578,7 @@ def _build_hosters(self):
561
578
hosters.append(hoster_cls(self._save_dir))
562
579
iflen(hosters) ==0:
563
580
logging.warning(
564
-
f"No model hoster is available! Please check your network connection to one of the following model hosts: HuggingFace ({_HuggingFaceModelHoster.healthcheck_url}), ModelScope ({_ModelScopeModelHoster.healthcheck_url}), AIStudio ({_AIStudioModelHoster.healthcheck_url}), or BOS ({_BosModelHoster.healthcheck_url}). Otherwise, only local models can be used."
581
+
f"No model hoster is available! Please check your network connection to one of the following model hoster: HuggingFace ({_HuggingFaceModelHoster.healthcheck_url}), ModelScope ({_ModelScopeModelHoster.healthcheck_url}), AIStudio ({_AIStudioModelHoster.healthcheck_url}), or BOS ({_BosModelHoster.healthcheck_url}). Otherwise, only local models can be used."
0 commit comments