Update app.py
Browse files
app.py
CHANGED
@@ -8,19 +8,29 @@ import time
|
|
8 |
import base64
|
9 |
import google.auth
|
10 |
import google.auth.transport.requests
|
11 |
-
|
|
|
12 |
|
13 |
# --- 1. Configuration and Authentication (Unchanged) ---
|
14 |
GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID")
|
15 |
GCP_LOCATION = os.environ.get("GCP_LOCATION")
|
16 |
|
17 |
# --- Authentication and Sanity Checks Block (Unchanged) ---
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
creds_json_str = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS_JSON")
|
26 |
|
|
|
8 |
import base64
|
9 |
import google.auth
|
10 |
import google.auth.transport.requests
|
11 |
+
import spaces
|
12 |
+
from huggingface_hub import login, hf_hub_download
|
13 |
|
14 |
# --- 1. Configuration and Authentication (Unchanged) ---
|
15 |
GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID")
|
16 |
GCP_LOCATION = os.environ.get("GCP_LOCATION")
|
17 |
|
18 |
# --- Authentication and Sanity Checks Block (Unchanged) ---
|
19 |
+
|
20 |
+
|
21 |
+
# Set up HF_TOKEN for Hugging Face Hub authentication
|
22 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
23 |
+
if not HF_TOKEN:
|
24 |
+
raise EnvironmentError(
|
25 |
+
"HF_TOKEN environment variable not found. Please set it in the Hugging Face Space secrets"
|
26 |
+
)
|
27 |
+
|
28 |
+
try:
|
29 |
+
login(token=HF_TOKEN)
|
30 |
+
except Exception as e:
|
31 |
+
raise EnvironmentError(
|
32 |
+
f"Failed to authenticate with HF_TOKEN. Ensure the token has read access."
|
33 |
+
)
|
34 |
|
35 |
creds_json_str = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS_JSON")
|
36 |
|