Spaces:
Sleeping
Sleeping
Muhammad Haris
commited on
Commit
•
bd7581a
1
Parent(s):
6dfc745
Update app.py
Browse files
app.py
CHANGED
@@ -80,33 +80,27 @@ def inference(model_path):
|
|
80 |
shoplifting_prediction = ShopliftingPrediction(model_path, 64, 64, 30)
|
81 |
shoplifting_prediction.load_model()
|
82 |
|
83 |
-
def process_video(
|
84 |
frames_queue = []
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
cap = cv2.VideoCapture(0) # Change to 1, 2, etc. for different cameras
|
89 |
-
|
90 |
-
if not cap.isOpened():
|
91 |
-
raise ValueError("Unable to open video source")
|
92 |
-
|
93 |
-
ret, previous = cap.read()
|
94 |
-
while ret:
|
95 |
-
ret, frame = cap.read()
|
96 |
-
if not ret:
|
97 |
-
break
|
98 |
-
frame, frames_queue, message = shoplifting_prediction.process_frame(frame, frames_queue, previous)
|
99 |
-
previous = frame
|
100 |
-
yield frame
|
101 |
|
102 |
return process_video
|
103 |
|
104 |
model_path = 'lrcn_160S_90_90Q.h5'
|
105 |
process_video = inference(model_path)
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
iface.launch()
|
|
|
80 |
shoplifting_prediction = ShopliftingPrediction(model_path, 64, 64, 30)
|
81 |
shoplifting_prediction.load_model()
|
82 |
|
83 |
+
def process_video(video_frame):
|
84 |
frames_queue = []
|
85 |
+
previous = video_frame
|
86 |
+
frame, frames_queue, message = shoplifting_prediction.process_frame(video_frame, frames_queue, previous)
|
87 |
+
return frame, message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
return process_video
|
90 |
|
91 |
model_path = 'lrcn_160S_90_90Q.h5'
|
92 |
process_video = inference(model_path)
|
93 |
|
94 |
+
def process_output(video):
|
95 |
+
for frame in video:
|
96 |
+
frame, message = process_video(frame)
|
97 |
+
yield frame, message
|
98 |
+
|
99 |
+
iface = gr.Interface(
|
100 |
+
fn=process_output,
|
101 |
+
inputs=gr.Video(),
|
102 |
+
outputs=["video", "text"],
|
103 |
+
live=True
|
104 |
+
)
|
105 |
|
106 |
iface.launch()
|