Spaces:
Sleeping
Sleeping
Manejo de errores OK!
Browse files- funciones.py +14 -32
- orange.png → no-result.png +0 -0
funciones.py
CHANGED
|
@@ -16,8 +16,7 @@ def mass(input1, input2):
|
|
| 16 |
|
| 17 |
path_video = input2
|
| 18 |
print("Path_video es:", path_video)
|
| 19 |
-
|
| 20 |
-
|
| 21 |
if modo == "video":
|
| 22 |
|
| 23 |
if plataforma == "local":
|
|
@@ -60,7 +59,7 @@ def mass(input1, input2):
|
|
| 60 |
#El source siempre es una imagen.
|
| 61 |
source_path = "source.png"
|
| 62 |
target_path = "target." + extension
|
| 63 |
-
result_path = "
|
| 64 |
|
| 65 |
#La primera siempre será una imagen, por eso no entra en el modo selector.
|
| 66 |
source_image = Image.fromarray(input1)
|
|
@@ -97,39 +96,22 @@ def mass(input1, input2):
|
|
| 97 |
print("Terminó la impresión del output...")
|
| 98 |
|
| 99 |
if "No face in source path detected" in output:
|
| 100 |
-
#
|
|
|
|
| 101 |
print("No se detectó ninguna cara en la ruta de origen.")
|
|
|
|
| 102 |
|
| 103 |
else:
|
| 104 |
print("Si se detecto un rostro...")
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
print("Éste es el momento en el que se creo result, revisar...")
|
| 109 |
-
time.sleep(1)
|
| 110 |
-
|
| 111 |
-
try:
|
| 112 |
-
print("Ésta vez no crearemos archivo zip.")
|
| 113 |
-
|
| 114 |
-
except Exception as e:
|
| 115 |
-
# código que se ejecutará si se produce la excepción
|
| 116 |
-
print(e)
|
| 117 |
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
return path
|
| 127 |
-
else:
|
| 128 |
-
#Para imagen
|
| 129 |
-
path = pathlib.Path(result_path)
|
| 130 |
-
path_abs = os.path.abspath(path)
|
| 131 |
-
print("Éste es el path para imagen:", path)
|
| 132 |
-
print("Y su ruta absoluta es: ", path_abs)
|
| 133 |
-
return path
|
| 134 |
|
| 135 |
-
|
|
|
|
| 16 |
|
| 17 |
path_video = input2
|
| 18 |
print("Path_video es:", path_video)
|
| 19 |
+
|
|
|
|
| 20 |
if modo == "video":
|
| 21 |
|
| 22 |
if plataforma == "local":
|
|
|
|
| 59 |
#El source siempre es una imagen.
|
| 60 |
source_path = "source.png"
|
| 61 |
target_path = "target." + extension
|
| 62 |
+
result_path = "result." + extension
|
| 63 |
|
| 64 |
#La primera siempre será una imagen, por eso no entra en el modo selector.
|
| 65 |
source_image = Image.fromarray(input1)
|
|
|
|
| 96 |
print("Terminó la impresión del output...")
|
| 97 |
|
| 98 |
if "No face in source path detected" in output:
|
| 99 |
+
#Si no se detecta un rostro, pondremos un placeholder, ésto evita que se despliegue el último result obtenido antes...
|
| 100 |
+
#...de la operación fallida.
|
| 101 |
print("No se detectó ninguna cara en la ruta de origen.")
|
| 102 |
+
result_path = "orange.png"
|
| 103 |
|
| 104 |
else:
|
| 105 |
print("Si se detecto un rostro...")
|
| 106 |
+
#Si sí se detectó un rostro, sigue su camino normal.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
print("Éste es el momento en el que se creo result, revisar...")
|
| 109 |
|
| 110 |
+
path = pathlib.Path(result_path)
|
| 111 |
+
path_abs = os.path.abspath(path)
|
| 112 |
+
print("Éste es el path:", path)
|
| 113 |
+
print("Y su ruta absoluta es: ", path_abs)
|
| 114 |
+
print("Listo! Gracias!")
|
| 115 |
+
return path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
+
|
orange.png → no-result.png
RENAMED
|
File without changes
|