Segizu commited on
Commit
510e6ef
Β·
1 Parent(s): 1194d1c

metadata v6

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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
- # πŸ“₯ Descargar imagen si es una URL
53
- if isinstance(img_data, str) and img_data.startswith("http"):
 
 
54
  response = requests.get(img_data, timeout=10)
55
  response.raise_for_status()
56
- img = Image.open(BytesIO(response.content)).convert("RGB")
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,