jarondon82 commited on
Commit
dbdefa8
·
1 Parent(s): bc06501

Corregir visualización de miniaturas y modelos en la tabla de caras registradas

Browse files
Files changed (1) hide show
  1. streamlit_app.py +21 -9
streamlit_app.py CHANGED
@@ -1751,10 +1751,11 @@ def main():
1751
  for name, info in st.session_state.face_database.items():
1752
  # Extract face image if available
1753
  face_img = None
1754
- if 'image' in info and info['image'] is not None:
 
1755
  try:
1756
- if is_valid_image(info['image']):
1757
- face_img = info['image']
1758
  else:
1759
  print(f"Invalid face image for {name}")
1760
  except Exception as e:
@@ -1764,18 +1765,29 @@ def main():
1764
  num_embeddings = 0
1765
  models_used = []
1766
 
1767
- if 'embeddings' in info and info['embeddings']:
 
1768
  num_embeddings = len(info['embeddings'])
1769
- # Extract models from embeddings
1770
- for emb in info['embeddings']:
1771
- if 'model' in emb and emb['model'] not in models_used:
1772
- models_used.append(emb['model'])
 
 
 
 
 
 
 
 
 
 
1773
 
1774
  # Add row to data
1775
  data.append({
1776
  "Name": name,
1777
  "Face": face_img,
1778
- "Images": 1 if face_img is not None else 0,
1779
  "Embeddings": num_embeddings,
1780
  "Models": ", ".join(models_used) if models_used else "None"
1781
  })
 
1751
  for name, info in st.session_state.face_database.items():
1752
  # Extract face image if available
1753
  face_img = None
1754
+ # Primero verificar si existe 'face_image' (formato nuevo)
1755
+ if 'face_image' in info and info['face_image'] is not None:
1756
  try:
1757
+ if is_valid_image(info['face_image']):
1758
+ face_img = info['face_image']
1759
  else:
1760
  print(f"Invalid face image for {name}")
1761
  except Exception as e:
 
1765
  num_embeddings = 0
1766
  models_used = []
1767
 
1768
+ # Verificar si la estructura usa el formato nuevo con listas
1769
+ if 'embeddings' in info and isinstance(info['embeddings'], list):
1770
  num_embeddings = len(info['embeddings'])
1771
+
1772
+ # Si hay una lista de modelos, usarla
1773
+ if 'models' in info and isinstance(info['models'], list):
1774
+ models_used = info['models']
1775
+ else:
1776
+ # Si no, intentar extraer modelos de los embeddings si tienen formato de diccionario
1777
+ for i, emb in enumerate(info['embeddings']):
1778
+ if isinstance(emb, dict) and 'model' in emb:
1779
+ if emb['model'] not in models_used:
1780
+ models_used.append(emb['model'])
1781
+ else:
1782
+ # Si no tiene formato de diccionario, usar un nombre genérico
1783
+ if f"Model {i+1}" not in models_used:
1784
+ models_used.append(f"Model {i+1}")
1785
 
1786
  # Add row to data
1787
  data.append({
1788
  "Name": name,
1789
  "Face": face_img,
1790
+ "Images": info.get('count', 1) if face_img is not None else 0,
1791
  "Embeddings": num_embeddings,
1792
  "Models": ", ".join(models_used) if models_used else "None"
1793
  })