Occlusion_Net icon indicating copy to clipboard operation
Occlusion_Net copied to clipboard

Inference on Videos

Open simurgh7 opened this issue 3 years ago • 1 comments

Hi, Thanks a lot for creating this repository. I was trying to run inference on this code by using video data and modifying the scripts. However, after a few frames later it runs into error like this - Traceback (most recent call last): File "infer_video.py", line 168, in main() File "infer_video.py", line 111, in main result = coco_demo.overlay_keypoints_graph(img, top_predictions,vis_color ,target='car') File "/code/lib/predictor.py", line 317, in overlay_keypoints_graph keypoints = predictions.get_field("keypoints") File "/maskrcnn-benchmark/maskrcnn_benchmark/structures/bounding_box.py", line 43, in get_field return self.extra_fields[field] KeyError: 'keypoints'

The modified snippet looks like this - cap = cv2.VideoCapture(url_list[0]) fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter(output_dir + "/"+ now+"out.avi", fourcc, 30.0, (640, 480)) count = 0 while(True): ret, img = cap.read() if ret: predictions = coco_demo.compute_prediction(img) top_predictions = coco_demo.select_top_predictions(predictions) result = coco_demo.overlay_keypoints_graph(img, top_predictions,vis_color ,target='car') out.write(result) #cv2.imshow('result',result) count += 1 else: break cap.release() out.release() print(now) now = datetime.datetime.now().strftime("%Y-%m-%d%H-%M-%S") print(now)

Any idea how to get around this one? Thank you.

simurgh7 avatar Oct 27 '21 16:10 simurgh7

this might be an issue with no bounding box detected in the video frame. I would suggest adding a check to verify if the frame in the video has any detection if not just to continue.

dineshreddy91 avatar Oct 27 '21 21:10 dineshreddy91