Hi,
I have this error showing up in my python code!
Traceback (most recent call last):
File "/home/kl/Documents/AI bball/data_preparation.py", line 35, in <module>
x, y, w, h = result["bbox"]
File "/usr/local/lib/python3.10/dist-packages/roboflow/util/prediction.py", line 259, in __getitem__
return self.json_prediction[key]
KeyError: 'bbox'
The python code looks like this:
Read until video is completed
while cap.isOpened():
# Capture frame-by-frame
ret, frame = cap.read()
if ret:
# Apply object detection on the frame
results = model.predict(frame)
# Draw the bounding boxes and labels on the frame
for result in results:
label = result["class"]
confidence = result["confidence"]
x, y, w, h = result["bbox"]
cv2.rectangle(frame, (int(x), int(y)), (int(x + w), int(y + h)), (0, 255, 0), 2)
text = f"{label}: {confidence:.2f}"
cv2.putText(frame, text, (int(x), int(y) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
# Write the frame into the file 'output.avi'
out.write(frame)
# Display the resulting frame
cv2.imshow('Frame', frame)
# Press Q on the keyboard to exit
if cv2.waitKey(25) & 0xFF == ord('q'):
break
And the data looks like this
filename,width,height,class,xmin,ymin,xmax,ymax
-265-Australia-vs-Germany-_-Condensed-Game-_-FIBA-Basketball-World-Cup-2023-YouTube-Google-Chrome-2023-08-30-08-21-01_mp4-63_jpg.rf.097f99a23e6a7825d40e10d887df4df3.jpg,640,640,german-obst,585,323,640,553
-265-Australia-vs-Germany-_-Condensed-Game-_-FIBA-Basketball-World-Cup-2023-YouTube-Google-Chrome-2023-08-30-08-21-01_mp4-63_jpg.rf.097f99a23e6a7825d40e10d887df4df3.jpg,640,640,australia-kay,455,217,479,395
-265-Australia-vs-Germany-_-Condensed-Game-_-FIBA-Basketball-World-Cup-2023-YouTube-Google-Chrome-2023-08-30-08-21-01_mp4-63_jpg.rf.097f99a23e6a7825d40e10d887df4df3.jpg,640,640,australia-mills,444,262,458,391
-265-Australia-vs-Germany-_-Condensed-Game-_-FIBA-Basketball-World-Cup-2023-YouTube-Google-Chrome-2023-08-30-08-21-01_mp4-63_jpg.rf.097f99a23e6a7825d40e10d887df4df3.jpg,640,640,australia-giddey,241,307,282,470
-265-Australia-vs-Germany-_-Condensed-Game-_-FIBA-Basketball-World-Cup-2023-YouTube-Google-Chrome-2023-08-30-08-21-01_mp4-63_jpg.rf.097f99a23e6a7825d40e10d887df4df3.jpg,640,640,australia-thybulle,93,244,129,451
-265-Australia-vs-Germany-_-Condensed-Game-_-FIBA-Basketball-World-Cup-2023-YouTube-Google-Chrome-2023-08-30-08-21-01_mp4-63_jpg.rf.097f99a23e6a7825d40e10d887df4df3.jpg,640,640,australia-reath,137,204,168,361
-265-Australia-vs-Germany-_-Condensed-Game-_-FIBA-Basketball-World-Cup-2023-YouTube-Google-Chrome-2023-08-30-08-21-01_mp4-63_jpg.rf.097f99a23e6a7825d40e10d887df4df3.jpg,640,640,germain-voigtmann-7,224,226,256,314
The model I am using is here = australia-germany Object Detection Dataset and Pre-Trained Model by Ken Lee
I hope someone can tell me where I have gone wrong and how to move forward with this.
Cheers,
Ken.