AttributeError: 'Results' object has no attribute 'obb' #826
-
Search before asking
Bugi was testing the example provided in the documentation, but i get this error when i run the code, you can see it prints the detection results but still i get this error after it Error: 0: 256x640 1 person, 2 bicycles, 2 skateboards, 1 potted plant, 64.0ms
Speed: 34.0ms preprocess, 64.0ms inference, 32.1ms postprocess per image at shape (1, 3, 256, 640)
Traceback (most recent call last):
File "a:\Main\CODE\GUI\GradeVision-QT-material - TESTVERSION\supervis.py", line 8, in <module>
detections = sv.Detections.from_ultralytics(results)
File "C:\Users\alimo\miniconda3\envs\guienv\lib\site-packages\supervision\detection\core.py", line 181, in from_ultralytics
if ultralytics_results.obb is not None:
File "C:\Users\alimo\miniconda3\envs\guienv\lib\site-packages\ultralytics\utils\__init__.py", line 153, in __getattr__
raise AttributeError(f"'{name}' object has no attribute '{attr}'. See valid attributes below.\n{self.__doc__}")
AttributeError: 'Results' object has no attribute 'obb'. See valid attributes below.
A class for storing and manipulating inference results.
Args:
orig_img (numpy.ndarray): The original image as a numpy array.
path (str): The path to the image file.
names (dict): A dictionary of class names.
boxes (torch.tensor, optional): A 2D tensor of bounding box coordinates for each detection.
masks (torch.tensor, optional): A 3D tensor of detection masks, where each mask is a binary image.
probs (torch.tensor, optional): A 1D tensor of probabilities of each class for classification task.
keypoints (List[List[float]], optional): A list of detected keypoints for each object.
Attributes:
orig_img (numpy.ndarray): The original image as a numpy array.
orig_shape (tuple): The original image shape in (height, width) format.
boxes (Boxes, optional): A Boxes object containing the detection bounding boxes.
masks (Masks, optional): A Masks object containing the detection masks.
probs (Probs, optional): A Probs object containing probabilities of each class for classification task.
keypoints (Keypoints, optional): A Keypoints object containing detected keypoints for each object.
speed (dict): A dictionary of preprocess, inference, and postprocess speeds in milliseconds per image.
names (dict): A dictionary of class names.
path (str): The path to the image file.
_keys (tuple): A tuple of attribute names for non-empty attributes. Environmentpython 3.10 Minimal Reproducible Exampleimport cv2
import supervision as sv
from ultralytics import YOLO
model = YOLO("yolov8s.pt")
image = cv2.imread('image_00\data/0000000047.png')
results = model(image)[0]
detections = sv.Detections.from_ultralytics(results)
bounding_box_annotator = sv.BoundingBoxAnnotator()
label_annotator = sv.LabelAnnotator()
labels = [
model.model.names[class_id]
for class_id
in detections.class_id
]
annotated_image = bounding_box_annotator.annotate(
scene=image, detections=detections)
annotated_image = label_annotator.annotate(
scene=annotated_image, detections=detections, labels=labels) Additionalim not running it in a ipynb file Are you willing to submit a PR?
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
@onuralpszr, could you take a look at this? |
Beta Was this translation helpful? Give feedback.
-
@AliMostafaRadwan based on model you share you using normal yolov8s not obb one and I made collab for you test it. https://colab.research.google.com/drive/1yDFFJLohvqAPgg3F4i5E655aobin14OW?usp=sharing I tried to trigger error but I was unable to trigger it. Also I was make sure it does usable for non obb annotators as well. I tried with small model and obb small model which boths works. Please check out the collab and If possible please share full collab of yours so I can re-test it. |
Beta Was this translation helpful? Give feedback.
-
I also notice you are using ultralytics==8.0.229. and obb released in 8.1 so you also need to change that too. |
Beta Was this translation helpful? Give feedback.
-
im testing it now |
Beta Was this translation helpful? Give feedback.
-
yep that was the cause of the error, just updated the package and it works fine now thx |
Beta Was this translation helpful? Give feedback.
-
You are welcome and have fun :)) |
Beta Was this translation helpful? Give feedback.
I also notice you are using ultralytics==8.0.229. and obb released in 8.1 so you also need to change that too.