Spaces:
Build error
Build error
metadata v12
Browse files
app.py
CHANGED
@@ -15,6 +15,13 @@ EMBEDDINGS_DIR = Path("embeddings")
|
|
15 |
EMBEDDINGS_DIR.mkdir(exist_ok=True)
|
16 |
EMBEDDINGS_FILE = EMBEDDINGS_DIR / "embeddings.pkl"
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# ✅ Cargar el dataset remoto desde Hugging Face Datasets con metadata.csv
|
19 |
dataset = load_dataset(
|
20 |
"csv",
|
@@ -58,7 +65,7 @@ def build_database():
|
|
58 |
print(f"⚠️ Saltando item {i + j} - URL inválida: {image_url}")
|
59 |
continue
|
60 |
|
61 |
-
response = requests.get(image_url, timeout=10)
|
62 |
response.raise_for_status()
|
63 |
img = Image.open(BytesIO(response.content)).convert("RGB")
|
64 |
|
|
|
15 |
EMBEDDINGS_DIR.mkdir(exist_ok=True)
|
16 |
EMBEDDINGS_FILE = EMBEDDINGS_DIR / "embeddings.pkl"
|
17 |
|
18 |
+
headers = {}
|
19 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
20 |
+
if HF_TOKEN:
|
21 |
+
headers["Authorization"] = f"Bearer {HF_TOKEN}"
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
# ✅ Cargar el dataset remoto desde Hugging Face Datasets con metadata.csv
|
26 |
dataset = load_dataset(
|
27 |
"csv",
|
|
|
65 |
print(f"⚠️ Saltando item {i + j} - URL inválida: {image_url}")
|
66 |
continue
|
67 |
|
68 |
+
response = requests.get(image_url, headers=headers, timeout=10)
|
69 |
response.raise_for_status()
|
70 |
img = Image.open(BytesIO(response.content)).convert("RGB")
|
71 |
|