Closed nasir3843 closed 5 years ago
@nasir3843 According to my test, the reason for the high time consumption is in the part of the detection frame processing. Because this part uses some python for loops(such as filter and nms, and etc) that result in longer processing times, it should be possible to speed things up if the tensors operation are used.
Same issue only with simple image, 2 seconds per image.
I ran into this problem with up to 1200s for only one video frame detection. To speed up the detection processing, I replaced the part (line 39 in yolo_model.py file) :
box_xy = K.get_value(K.sigmoid(out[..., :2]))
box_wh = K.get_value(K.exp(out[..., 2:4]) * anchors_tensor)
box_confidence = K.get_value(K.sigmoid(out[..., 4]))
box_confidence = np.expand_dims(box_confidence, axis=-1)
box_class_probs = K.get_value(K.sigmoid(out[..., 5:]))
By :
box_xy = self._sigmoid(out[..., :2])
box_wh = np.exp(out[..., 2:4]) * anchors_tensor
box_confidence = self._sigmoid(out[..., 4])
box_confidence = np.expand_dims(box_confidence, axis=-1)
box_class_probs = self._sigmoid(out[..., 5:])
I also added the sigmoid function in this class :
@staticmethod
def _sigmoid(X):
return 1 / (1 + np.exp(-X))
The prediction + detection processing goes from 4s to a constant 0.08s per frame on a GTX 970.
I am using this repo to run YoloV3 on a test video. My GPU support is GeForce GTX 1080 Ti. The video is playing with almost 3 sec per frame. I have no idea why it is so slow, even though my GPU is good enough. I have attached a screen-shot of my terminal while running the test video. Any idea or guidance is much appreciated. Thank You