Spaces:
Build error
Build error
metadata v6
Browse files
app.py
CHANGED
@@ -48,21 +48,21 @@ def build_database():
|
|
48 |
for j, item in enumerate(batch):
|
49 |
try:
|
50 |
img_data = item["image"]
|
51 |
-
|
52 |
-
#
|
53 |
-
if isinstance(img_data,
|
|
|
|
|
54 |
response = requests.get(img_data, timeout=10)
|
55 |
response.raise_for_status()
|
56 |
-
img = Image.open(BytesIO(response.content))
|
57 |
-
|
58 |
-
# Usar imagen si ya viene decodificada
|
59 |
elif isinstance(img_data, Image.Image):
|
60 |
img = img_data
|
61 |
-
|
62 |
else:
|
63 |
print(f"β Formato desconocido en imagen {i+j}: {type(img_data)}")
|
64 |
continue
|
65 |
|
|
|
66 |
img_processed = preprocess_image(img)
|
67 |
embedding = DeepFace.represent(
|
68 |
img_path=img_processed,
|
|
|
48 |
for j, item in enumerate(batch):
|
49 |
try:
|
50 |
img_data = item["image"]
|
51 |
+
|
52 |
+
# Convertir a PIL Image si es necesario
|
53 |
+
if isinstance(img_data, dict) and "bytes" in img_data:
|
54 |
+
img = Image.open(BytesIO(img_data["bytes"]))
|
55 |
+
elif isinstance(img_data, str) and img_data.startswith("http"):
|
56 |
response = requests.get(img_data, timeout=10)
|
57 |
response.raise_for_status()
|
58 |
+
img = Image.open(BytesIO(response.content))
|
|
|
|
|
59 |
elif isinstance(img_data, Image.Image):
|
60 |
img = img_data
|
|
|
61 |
else:
|
62 |
print(f"β Formato desconocido en imagen {i+j}: {type(img_data)}")
|
63 |
continue
|
64 |
|
65 |
+
img = img.convert("RGB")
|
66 |
img_processed = preprocess_image(img)
|
67 |
embedding = DeepFace.represent(
|
68 |
img_path=img_processed,
|