angelo9830 commited on
Commit
86a57ec
1 Parent(s): 9d8c2ad

Upload 5 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ mivideo.mp4 filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import gradio as gr
3
+
4
+ def process_video(video):
5
+ face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
6
+ eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
7
+ estadoanterior = ""
8
+ estadoactual = ""
9
+ output_frames = []
10
+
11
+ cap = cv2.VideoCapture(video)
12
+ while cap.isOpened():
13
+ ret, frame = cap.read()
14
+ if frame is None:
15
+ break
16
+ gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
17
+ hh, ww = gray.shape
18
+ faces = face_cascade.detectMultiScale(gray, 1.3, 5)
19
+ for (x, y, w, h) in faces:
20
+ cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 2)
21
+ cv2.line(frame, (int(ww / 2), 0), (int(ww / 2), hh), (0, 0, 255), 2)
22
+ if x <= ww / 2:
23
+ estadoactual = "I"
24
+ if estadoactual != estadoanterior:
25
+ estadoanterior = estadoactual
26
+ else:
27
+ estadoactual = "D"
28
+ if estadoactual != estadoanterior:
29
+ estadoanterior = estadoactual
30
+
31
+ output_frames.append(frame)
32
+
33
+ cap.release()
34
+ return output_frames
35
+
36
+ # Gradio Interface
37
+ demo = gr.Interface(
38
+ fn=process_video,
39
+ inputs=gr.Video(label="Sube tu video"),
40
+ outputs=gr.Video(label="Video procesado"),
41
+ title="Detección de Rostros y Ojos",
42
+ description="Este espacio detecta rostros y ojos en un video subido.",
43
+ )
44
+
45
+ if __name__ == "__main__":
46
+ demo.launch()
haarcascade_eye.xml ADDED
The diff for this file is too large to render. See raw diff
 
haarcascade_frontalface_default.xml ADDED
The diff for this file is too large to render. See raw diff
 
mivideo.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c8b03caab67ff8328e3ad9aaa13b5538a733008fdc63454fcf8c713a471f2ed
3
+ size 28341120
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ opencv-python
3
+ opencv-python-headless