Anti-hero commited on
Commit
0263d84
1 Parent(s): cd18a38

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +2 -8
handler.py CHANGED
@@ -11,12 +11,6 @@ class EndpointHandler():
11
  self.classes_1 = ["RoadAccidents", "Fighting", "NormalVideos"]
12
  self.locations = ['Miami', 'Smouha', 'Mandara', 'Sporting', 'Montazah']
13
 
14
- def preprocess_frame(self, frame):
15
- frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
16
- frame = cv2.resize(frame, (224, 224))
17
- frame = frame.astype('float32') / 255.0
18
- frame = np.expand_dims(frame, axis=0)
19
- return frame
20
 
21
  def get_top_k(self, probs, k=1, label_map=None):
22
  if label_map is None:
@@ -28,8 +22,8 @@ class EndpointHandler():
28
  return top_labels[0]
29
 
30
  def perform_action_recognition(self, frame, k=1):
31
- preprocessed_frame = self.preprocess_frame(frame)
32
- outputs = self.model.signatures['serving_default'](image=preprocessed_frame)
33
  probs = tf.nn.softmax(outputs['classifier_head_1'])
34
  return self.get_top_k(probs[0], k=k)
35
 
 
11
  self.classes_1 = ["RoadAccidents", "Fighting", "NormalVideos"]
12
  self.locations = ['Miami', 'Smouha', 'Mandara', 'Sporting', 'Montazah']
13
 
 
 
 
 
 
 
14
 
15
  def get_top_k(self, probs, k=1, label_map=None):
16
  if label_map is None:
 
22
  return top_labels[0]
23
 
24
  def perform_action_recognition(self, frame, k=1):
25
+
26
+ outputs = self.model.signatures['serving_default'](image=frame)
27
  probs = tf.nn.softmax(outputs['classifier_head_1'])
28
  return self.get_top_k(probs[0], k=k)
29