Open SalmanFarsiM opened 1 year ago
👋 Hello @SalmanFarsiM, thank you for leaving an issue on Roboflow Notebooks.
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.
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.
i have bug that "AttributeError: type object 'Detections' has no attribute 'from_coco_annotations'" thank you
i have bug that "AttributeError: type object 'Detections' has no attribute 'from_coco_annotations'" thank you
I'm having the same error on Jupyter Notebooks
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[classid]}" for , _, classid, 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[classid]} {confidence:.2f}" for , confidence, classid, 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?