You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the Roboflow Notebooks issues and found no similar bug report.
Notebook name
GOOGLE COLLAB
Bug
I am getting the 'Key Error'='annotations'
And Type of Error: Detections._Getitem not supported for index of type <class 'numpy.ndarray'>....
Please Do guide me with the following error how can i come up with it.
Will really appreciate it.
Environment
Google Colab
Minimal Reproducible Example
import random
import cv2
import numpy as np
import pandas as pd
utils
categories = TEST_DATASET.coco.cats
id2label = {k: v['name'] for k,v in categories.items()}
box_annotator = sv.BoxAnnotator()
👋 Hello @SalmanFarsiM, thank you for leaving an issue on Roboflow Notebooks.
🐞 Bug reports
If you are filing a bug report, please be as detailed as possible. This will help us more easily diagnose and resolve the problem you are facing. To learn more about contributing, check out our Contributing Guidelines.
If you require support with custom code that is not part of Roboflow Notebooks, please reach out on the Roboflow Forum or on the GitHub Discussions page associated with this repository.
💬 Get in touch
Do you have more questions about Roboflow that we haven't responded to yet? Feel free to ask them on the Roboflow Discuss forum. Our developer advocates and community team actively respond to questions there.
To ask questions about Notebooks, head over to the GitHub Discussions section of this repository.
Search before asking
Notebook name
GOOGLE COLLAB
Bug
I am getting the 'Key Error'='annotations'
And Type of Error: Detections._Getitem not supported for index of type <class 'numpy.ndarray'>....
Please Do guide me with the following error how can i come up with it.
Will really appreciate it.
Environment
Google Colab
Minimal Reproducible Example
import random
import cv2
import numpy as np
import pandas as pd
utils
categories = TEST_DATASET.coco.cats
id2label = {k: v['name'] for k,v in categories.items()}
box_annotator = sv.BoxAnnotator()
select random image
image_ids = TEST_DATASET.coco.getImgIds()
image_id = random.choice(image_ids)
print('Image #{}'.format(image_id))
load image and annotatons
image = TEST_DATASET.coco.loadImgs(image_id)[0]
annotations = TEST_DATASET.coco.imgToAnns[image_id]
image_path = os.path.join(TEST_DATASET.root, image['file_name'])
image = cv2.imread(image_path)
annotate
detections = sv.Detections.from_coco_annotations(coco_annotation=annotations)
labels = [f"{id2label[class_id]}" for _, _, class_id, _ in detections]
frame = box_annotator.annotate(scene=image.copy(), detections=detections, labels=labels)
print('ground truth')
%matplotlib inline
sv.show_frame_in_notebook(frame, (16, 16))
inference
with torch.no_grad():
annotate
detections_obj = sv.Detections.from_transformers(transformers_results=results).with_nms(threshold=0.5)
detections = detections_obj.get_data()
labels = [f"{id2label[class_id]} {confidence:.2f}" for _, confidence, class_id, _ in detections]
frame = box_annotator.annotate(scene=image.copy(), detections=detections_obj, labels=labels)
print(type(detections))
%matplotlib inline
sv.show_frame_in_notebook(frame, (16, 16))
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: