'Keypoints' object has no attribute 'astype'. See valid attributes below.
【C1】YOLOV8预训练模型预测-Python API-图像.ipynb
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/ultralytics/utils/init.py in getattr(self, attr) 151 """Custom attribute access error message with helpful information.""" 152 name = self.class.name --> 153 raise AttributeError(f"'{name}' object has no attribute '{attr}'. See valid attributes below.\n{self.doc}") 154 155
AttributeError: 'Keypoints' object has no attribute 'astype'. See valid attributes below.
A class for storing and manipulating detection keypoints.
Attributes:
xy (torch.Tensor): A collection of keypoints containing x, y coordinates for each detection.
xyn (torch.Tensor): A normalized version of xy with coordinates in the range [0, 1].
conf (torch.Tensor): Confidence values associated with keypoints if available, otherwise None.
Methods:
cpu(): Returns a copy of the keypoints tensor on CPU memory.
numpy(): Returns a copy of the keypoints tensor as a numpy array.
cuda(): Returns a copy of the keypoints tensor on GPU memory.
to(device, dtype): Returns a copy of the keypoints tensor with the specified device and dtype.
keypoints后面加个.data就可以了 bboxes_keypoints = results[0].keypoints.data.cpu().numpy().astype('uint32')