Skip to content

Inference on Videos #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
simurgh7 opened this issue Oct 27, 2021 · 1 comment
Open

Inference on Videos #23

simurgh7 opened this issue Oct 27, 2021 · 1 comment

Comments

@simurgh7
Copy link

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.

@dineshreddy91
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants