Muhammad Haris commited on
Commit
bde74e3
1 Parent(s): bd7581a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -74,33 +74,27 @@ class ShopliftingPrediction:
74
 
75
  cv2.rectangle(frame, (0, 0), (640, 40), (255, 255, 255), -1)
76
  cv2.putText(frame, self.message, (1, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1, cv2.LINE_AA)
77
- return frame, frames_queue, self.message
78
 
79
  def inference(model_path):
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()
 
74
 
75
  cv2.rectangle(frame, (0, 0), (640, 40), (255, 255, 255), -1)
76
  cv2.putText(frame, self.message, (1, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1, cv2.LINE_AA)
77
+ return frame
78
 
79
  def inference(model_path):
80
  shoplifting_prediction = ShopliftingPrediction(model_path, 64, 64, 30)
81
  shoplifting_prediction.load_model()
82
 
83
  def process_video(video_frame):
84
+ frame = shoplifting_prediction.process_frame(video_frame, [], video_frame)
85
+ return frame
 
 
86
 
87
  return process_video
88
 
89
  model_path = 'lrcn_160S_90_90Q.h5'
90
  process_video = inference(model_path)
91
 
 
 
 
 
 
92
  iface = gr.Interface(
93
+ fn=process_video,
94
+ inputs=gr.inputs.Video(type="numpy"),
95
+ outputs="video",
96
+ live=True,
97
+ capture_session=True # Ensures the video stream is captured properly
98
  )
99
 
100
  iface.launch()