Spaces:
Running
Running
Commit
·
e54b83d
1
Parent(s):
6bf3da5
Agregar descarga automática de modelos al directorio raíz
Browse files- app.py +19 -0
- download_models.py +4 -10
app.py
CHANGED
|
@@ -1,6 +1,25 @@
|
|
| 1 |
# Simple app.py for Face Detection
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
try:
|
| 5 |
# Importar la aplicación principal
|
| 6 |
print("Starting Face Detection Application...")
|
|
|
|
| 1 |
# Simple app.py for Face Detection
|
| 2 |
+
import os
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
+
# Comprobar y descargar modelos necesarios
|
| 6 |
+
try:
|
| 7 |
+
# Verificar si los archivos de modelo existen
|
| 8 |
+
model_files = [
|
| 9 |
+
"deploy.prototxt.txt",
|
| 10 |
+
"res10_300x300_ssd_iter_140000.caffemodel"
|
| 11 |
+
]
|
| 12 |
+
|
| 13 |
+
missing_files = [f for f in model_files if not os.path.exists(f)]
|
| 14 |
+
|
| 15 |
+
if missing_files:
|
| 16 |
+
st.warning("Faltan archivos de modelo. Descargando...")
|
| 17 |
+
import download_models
|
| 18 |
+
download_models.main()
|
| 19 |
+
st.success("¡Archivos de modelo descargados correctamente!")
|
| 20 |
+
except Exception as e:
|
| 21 |
+
st.error(f"Error al comprobar/descargar modelos: {e}")
|
| 22 |
+
|
| 23 |
try:
|
| 24 |
# Importar la aplicación principal
|
| 25 |
print("Starting Face Detection Application...")
|
download_models.py
CHANGED
|
@@ -17,21 +17,15 @@ def download_file(url, save_path):
|
|
| 17 |
return False
|
| 18 |
|
| 19 |
def main():
|
| 20 |
-
# Crear directorio para modelos si no existe
|
| 21 |
-
models_dir = "models"
|
| 22 |
-
if not os.path.exists(models_dir):
|
| 23 |
-
os.makedirs(models_dir)
|
| 24 |
-
print(f"Directorio creado: {models_dir}")
|
| 25 |
-
|
| 26 |
# URLs y rutas para los modelos necesarios
|
| 27 |
models = [
|
| 28 |
{
|
| 29 |
-
"url": "https://raw.githubusercontent.com/
|
| 30 |
-
"path":
|
| 31 |
},
|
| 32 |
{
|
| 33 |
-
"url": "https://raw.githubusercontent.com/
|
| 34 |
-
"path":
|
| 35 |
}
|
| 36 |
]
|
| 37 |
|
|
|
|
| 17 |
return False
|
| 18 |
|
| 19 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# URLs y rutas para los modelos necesarios
|
| 21 |
models = [
|
| 22 |
{
|
| 23 |
+
"url": "https://raw.githubusercontent.com/sr6033/face-detection-with-OpenCV-and-DNN/master/deploy.prototxt.txt",
|
| 24 |
+
"path": "deploy.prototxt.txt"
|
| 25 |
},
|
| 26 |
{
|
| 27 |
+
"url": "https://raw.githubusercontent.com/sr6033/face-detection-with-OpenCV-and-DNN/master/res10_300x300_ssd_iter_140000.caffemodel",
|
| 28 |
+
"path": "res10_300x300_ssd_iter_140000.caffemodel"
|
| 29 |
}
|
| 30 |
]
|
| 31 |
|