Spaces:
Build error
Build error
metadata v9
Browse files
app.py
CHANGED
@@ -51,36 +51,10 @@ def build_database():
|
|
51 |
|
52 |
for j, item in enumerate(batch):
|
53 |
try:
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
# Handle different image data formats
|
59 |
-
if hasattr(img_data, 'numpy'):
|
60 |
-
# If it's a tensor/array, convert to PIL
|
61 |
-
img = Image.fromarray(img_data.numpy())
|
62 |
-
elif isinstance(img_data, dict):
|
63 |
-
# If it's a dictionary, try to get the image data
|
64 |
-
if "bytes" in img_data:
|
65 |
-
img = Image.open(BytesIO(img_data["bytes"]))
|
66 |
-
elif "path" in img_data:
|
67 |
-
img = Image.open(img_data["path"])
|
68 |
-
else:
|
69 |
-
print(f"❌ Formato de diccionario no soportado: {img_data.keys()}")
|
70 |
-
continue
|
71 |
-
elif isinstance(img_data, str):
|
72 |
-
if img_data.startswith("http"):
|
73 |
-
response = requests.get(img_data, timeout=10)
|
74 |
-
response.raise_for_status()
|
75 |
-
img = Image.open(BytesIO(response.content))
|
76 |
-
else:
|
77 |
-
img = Image.open(img_data)
|
78 |
-
elif isinstance(img_data, Image.Image):
|
79 |
-
img = img_data
|
80 |
-
else:
|
81 |
-
print(f"❌ Formato desconocido en imagen {i+j}: {type(img_data)}")
|
82 |
-
continue
|
83 |
-
|
84 |
img = img.convert("RGB")
|
85 |
img_processed = preprocess_image(img)
|
86 |
embedding = DeepFace.represent(
|
@@ -95,9 +69,6 @@ def build_database():
|
|
95 |
del img_processed
|
96 |
gc.collect()
|
97 |
|
98 |
-
except (requests.RequestException, UnidentifiedImageError) as e:
|
99 |
-
print(f"❌ Falló descarga/lectura de imagen {i+j}: {e}")
|
100 |
-
continue
|
101 |
except Exception as e:
|
102 |
print(f"❌ No se pudo procesar imagen {i+j}: {str(e)}")
|
103 |
print(f"Error details: {type(e).__name__}")
|
|
|
51 |
|
52 |
for j, item in enumerate(batch):
|
53 |
try:
|
54 |
+
# The image is already a PIL Image object
|
55 |
+
img = item["image"]
|
56 |
+
|
57 |
+
# Ensure image is in RGB mode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
img = img.convert("RGB")
|
59 |
img_processed = preprocess_image(img)
|
60 |
embedding = DeepFace.represent(
|
|
|
69 |
del img_processed
|
70 |
gc.collect()
|
71 |
|
|
|
|
|
|
|
72 |
except Exception as e:
|
73 |
print(f"❌ No se pudo procesar imagen {i+j}: {str(e)}")
|
74 |
print(f"Error details: {type(e).__name__}")
|