Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bitextor/bicleaner-ai.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZJaume <jzaragoza@prompsit.com>2022-07-22 15:48:55 +0300
committerJaume Zaragoza <ZJaume@users.noreply.github.com>2022-07-27 15:20:55 +0300
commitfa3cc29abbe3c602f29dbdb388d77e1e16b11eea (patch)
treefb363d33450e47383440f0bd91a49d3cb15c3a42
parentcc5fafd97c03b9b55513abc5568c45391d527939 (diff)
Be more informative when model not found
-rwxr-xr-xbicleaner_ai/bicleaner_ai_classifier.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bicleaner_ai/bicleaner_ai_classifier.py b/bicleaner_ai/bicleaner_ai_classifier.py
index 3311613..ba57d5f 100755
--- a/bicleaner_ai/bicleaner_ai_classifier.py
+++ b/bicleaner_ai/bicleaner_ai_classifier.py
@@ -50,6 +50,7 @@ def initialization():
args.processes = max(1, cpu_count()-1)
# Try to download the model if not a valid path
+ hub_not_found = False
if not args.offline:
from huggingface_hub import snapshot_download, model_info
from huggingface_hub.utils import RepositoryNotFoundError
@@ -58,8 +59,7 @@ def initialization():
# Check if it exists at the HF Hub
model_info(args.model, token=args.auth_token)
except RepositoryNotFoundError:
- logging.debug(
- f"Model {args.model} not found at HF Hub, trying local storage")
+ hub_not_found = True
args.metadata = args.model + '/metadata.yaml'
else:
logging.info(f"Downloading the model {args.model}")
@@ -71,6 +71,12 @@ def initialization():
else:
args.metadata = args.model + '/metadata.yaml'
+ if not os.path.isfile(args.metadata):
+ if hub_not_found:
+ logging.error(
+ f"Model {args.model} not found at HF Hub")
+ raise FileNotFoundError(f"model {args.model} no such file")
+
# Load metadata YAML
args = load_metadata(args, parser)