Spaces:
Sleeping
Sleeping
Commit
•
91a155f
1
Parent(s):
a776cb5
raise exception for invalid token
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ import pandas as pd
|
|
10 |
import os
|
11 |
import backoff
|
12 |
from functools import lru_cache
|
13 |
-
from huggingface_hub import list_models, ModelFilter
|
14 |
|
15 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
16 |
|
@@ -78,7 +78,10 @@ def predict_subset(model_id, token):
|
|
78 |
raise gr.Error(
|
79 |
f"model_id {model_id} is not a valid image classification model id"
|
80 |
)
|
81 |
-
|
|
|
|
|
|
|
82 |
API_URL = f"https://api-inference.huggingface.co/models/{model_id}"
|
83 |
headers = {"Authorization": f"Bearer {token}"}
|
84 |
|
|
|
10 |
import os
|
11 |
import backoff
|
12 |
from functools import lru_cache
|
13 |
+
from huggingface_hub import list_models, ModelFilter, login
|
14 |
|
15 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
16 |
|
|
|
78 |
raise gr.Error(
|
79 |
f"model_id {model_id} is not a valid image classification model id"
|
80 |
)
|
81 |
+
try:
|
82 |
+
login(token)
|
83 |
+
except ValueError:
|
84 |
+
raise gr.Error("Invalid Hub token")
|
85 |
API_URL = f"https://api-inference.huggingface.co/models/{model_id}"
|
86 |
headers = {"Authorization": f"Bearer {token}"}
|
87 |
|