Spaces:
Build error
Build error
Commit
·
fecfd49
1
Parent(s):
730a9c7
Actualizar configuración para detección facial en tiempo real
Browse files- __pycache__/online_demo.cpython-310.pyc +0 -0
- __pycache__/streamlit_app.cpython-310.pyc +0 -0
- fix_indentation.py +32 -0
- fix_resize_error.py +54 -0
- fix_script.py +27 -0
- streamlit_app.py.backup +0 -0
- streamlit_app.py.bak +0 -0
- streamlit_app_corrected.py +0 -0
- streamlit_app_fix.py +2 -0
- temp_fix.py +0 -0
__pycache__/online_demo.cpython-310.pyc
ADDED
|
Binary file (2.75 kB). View file
|
|
|
__pycache__/streamlit_app.cpython-310.pyc
ADDED
|
Binary file (43.5 kB). View file
|
|
|
fix_indentation.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
# Leer el archivo
|
| 4 |
+
with open('streamlit_app.py', 'r', encoding='utf-8') as file:
|
| 5 |
+
lines = file.readlines()
|
| 6 |
+
|
| 7 |
+
# Corregir la indentación - buscar la función stop_feature_camera y asegurarse de que tenga cuerpo
|
| 8 |
+
fixed_lines = []
|
| 9 |
+
added_body = False
|
| 10 |
+
i = 0
|
| 11 |
+
|
| 12 |
+
while i < len(lines):
|
| 13 |
+
line = lines[i]
|
| 14 |
+
fixed_lines.append(line)
|
| 15 |
+
|
| 16 |
+
# Verificar si es la definición de la función stop_feature_camera
|
| 17 |
+
if line.strip() == 'def stop_feature_camera():':
|
| 18 |
+
# Verificar si la siguiente línea tiene indentación correcta
|
| 19 |
+
if i + 1 < len(lines) and not lines[i + 1].startswith(' ' * 8):
|
| 20 |
+
# No tiene indentación correcta, añadir el cuerpo de la función
|
| 21 |
+
fixed_lines.append(' ' * 8 + 'st.session_state.feature_camera_running = False\n')
|
| 22 |
+
fixed_lines.append(' ' * 8 + 'st.session_state.feature_camera_stopped = True\n')
|
| 23 |
+
fixed_lines.append('\n')
|
| 24 |
+
added_body = True
|
| 25 |
+
|
| 26 |
+
i += 1
|
| 27 |
+
|
| 28 |
+
# Guardar el archivo corregido
|
| 29 |
+
with open('streamlit_app.py', 'w', encoding='utf-8') as file:
|
| 30 |
+
file.writelines(fixed_lines)
|
| 31 |
+
|
| 32 |
+
print("Archivo corregido con éxito. Se ha arreglado la indentación de la función stop_feature_camera()")
|
fix_resize_error.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
# Definir nuestras funciones auxiliares para verificación de imágenes
|
| 4 |
+
helper_functions = '''
|
| 5 |
+
# Función auxiliar para verificar si una imagen es válida antes de redimensionar
|
| 6 |
+
def is_valid_image(img):
|
| 7 |
+
if img is None:
|
| 8 |
+
return False
|
| 9 |
+
try:
|
| 10 |
+
# Verificar que la imagen tenga dimensiones válidas y datos
|
| 11 |
+
return img.size > 0 and len(img.shape) >= 2 and img.shape[0] > 0 and img.shape[1] > 0
|
| 12 |
+
except:
|
| 13 |
+
return False
|
| 14 |
+
|
| 15 |
+
# Función auxiliar para redimensionar de forma segura
|
| 16 |
+
def safe_resize(img, target_size):
|
| 17 |
+
if is_valid_image(img):
|
| 18 |
+
try:
|
| 19 |
+
return cv2.resize(img, target_size)
|
| 20 |
+
except Exception as e:
|
| 21 |
+
print(f"Error al redimensionar: {str(e)}")
|
| 22 |
+
return None
|
| 23 |
+
return None
|
| 24 |
+
'''
|
| 25 |
+
|
| 26 |
+
# Modificar código para usar funciones seguras
|
| 27 |
+
with open('streamlit_app.py', 'r', encoding='utf-8') as file:
|
| 28 |
+
content = file.read()
|
| 29 |
+
|
| 30 |
+
# Buscar la definición de la función stop_feature_camera
|
| 31 |
+
if 'def stop_feature_camera' in content:
|
| 32 |
+
# Añadir nuestras funciones auxiliares después de esta función
|
| 33 |
+
content = content.replace(
|
| 34 |
+
'def stop_feature_camera():',
|
| 35 |
+
'def stop_feature_camera():' + helper_functions
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
# Buscar y reemplazar los usos de cv2.resize
|
| 39 |
+
content = content.replace(
|
| 40 |
+
'thumbnail = cv2.resize(info[\'image\'], (w//4, h//4))',
|
| 41 |
+
'thumbnail = safe_resize(info[\'image\'], (w//4, h//4))\n if thumbnail is not None'
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
# También reemplazar otros posibles usos de resize en el procesamiento de video
|
| 45 |
+
content = content.replace(
|
| 46 |
+
'small_img = cv2.resize(img, (int(w * scale_factor), int(h * scale_factor)))',
|
| 47 |
+
'small_img = safe_resize(img, (int(w * scale_factor), int(h * scale_factor)))\n if small_img is None:\n return frame'
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
# Escribir el contenido modificado al archivo
|
| 51 |
+
with open('streamlit_app.py', 'w', encoding='utf-8') as file:
|
| 52 |
+
file.write(content)
|
| 53 |
+
|
| 54 |
+
print("Archivo actualizado correctamente con verificaciones de imágenes seguras.")
|
fix_script.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Script para corregir el error de sintaxis en streamlit_app.py
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
# Leemos el archivo original
|
| 6 |
+
with open('streamlit_app.py', 'r', encoding='utf-8') as file:
|
| 7 |
+
lines = file.readlines()
|
| 8 |
+
|
| 9 |
+
# Creamos un nuevo contenido sin las líneas problemáticas
|
| 10 |
+
new_lines = []
|
| 11 |
+
skip_next = False
|
| 12 |
+
for i, line in enumerate(lines):
|
| 13 |
+
# Índice 1563 corresponde a la línea 1564
|
| 14 |
+
if i == 1563: # Línea con "else:"
|
| 15 |
+
skip_next = True
|
| 16 |
+
continue
|
| 17 |
+
elif i == 1564 and skip_next: # Siguiente línea después del else
|
| 18 |
+
# La indentación está bien, mantenemos esta línea pero con indentación adecuada
|
| 19 |
+
skip_next = False
|
| 20 |
+
continue
|
| 21 |
+
new_lines.append(line)
|
| 22 |
+
|
| 23 |
+
# Escribimos el contenido corregido a un nuevo archivo
|
| 24 |
+
with open('streamlit_app_corrected.py', 'w', encoding='utf-8') as file:
|
| 25 |
+
file.writelines(new_lines)
|
| 26 |
+
|
| 27 |
+
print("Archivo corregido guardado como 'streamlit_app_corrected.py'")
|
streamlit_app.py.backup
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
streamlit_app.py.bak
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
streamlit_app_corrected.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
streamlit_app_fix.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Mostrar tabla de rostros registrados
|
| 2 |
+
st.subheader("Registered Faces")
|
temp_fix.py
ADDED
|
Binary file (396 Bytes). View file
|
|
|