Spaces:
No application file
No application file
angelo9830
commited on
Commit
•
63adffc
1
Parent(s):
86a57ec
Update app.py
Browse files
app.py
CHANGED
@@ -1,46 +1,9 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
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()
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def hello(name):
|
4 |
+
return f"Hello, {name}!"
|
5 |
+
|
6 |
+
demo = gr.Interface(fn=hello, inputs="text", outputs="text")
|
7 |
+
|
8 |
+
if __name__ == "__main__":
|
9 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|