jarondon82 commited on
Commit
e54b83d
·
1 Parent(s): 6bf3da5

Agregar descarga automática de modelos al directorio raíz

Browse files
Files changed (2) hide show
  1. app.py +19 -0
  2. 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/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt",
30
- "path": os.path.join(models_dir, "deploy.prototxt")
31
  },
32
  {
33
- "url": "https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel",
34
- "path": os.path.join(models_dir, "res10_300x300_ssd_iter_140000.caffemodel")
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