Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -158,25 +158,26 @@ class BasicAgent:
|
|
158 |
|
159 |
|
160 |
def get_or_download_image(file_name: str) -> Image.Image:
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
165 |
file_path = os.path.join("data", file_name)
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
if not os.path.exists(file_path):
|
168 |
print(f"[INFO] File {file_name} non trovato in /data, lo scarico...")
|
169 |
-
#url = f"https://huggingface.co/datasets/gaia-benchmark/GAIA/resolve/main/2023/validation/{file_name}"
|
170 |
-
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
full_url = f"{base_url}/{commit_hash}/2023/validation/{file_name}"
|
175 |
|
176 |
-
|
177 |
-
|
178 |
try:
|
179 |
-
response = requests.get(
|
180 |
response.raise_for_status()
|
181 |
with open(file_path, "wb") as f:
|
182 |
f.write(response.content)
|
|
|
158 |
|
159 |
|
160 |
def get_or_download_image(file_name: str) -> Image.Image:
|
161 |
+
import os
|
162 |
+
import requests
|
163 |
+
from PIL import Image
|
164 |
+
from io import BytesIO
|
165 |
+
|
166 |
file_path = os.path.join("data", file_name)
|
167 |
+
hf_token = os.getenv("HF_TOKEN_READ")
|
168 |
+
|
169 |
+
if not hf_token:
|
170 |
+
print("[ERRORE] HF_TOKEN_READ non trovato. Imposta la variabile d'ambiente HF_TOKEN_READ.")
|
171 |
+
return None
|
172 |
|
173 |
if not os.path.exists(file_path):
|
174 |
print(f"[INFO] File {file_name} non trovato in /data, lo scarico...")
|
|
|
|
|
175 |
|
176 |
+
url = f"https://huggingface.co/datasets/gaia-benchmark/GAIA/resolve/main/2023/validation/{file_name}"
|
177 |
+
headers = {"Authorization": f"Bearer {hf_token}"}
|
|
|
178 |
|
|
|
|
|
179 |
try:
|
180 |
+
response = requests.get(url, headers=headers)
|
181 |
response.raise_for_status()
|
182 |
with open(file_path, "wb") as f:
|
183 |
f.write(response.content)
|