import  cv2
from  ultralytics import  YOLO
model =  YOLO( model= 'yolov8n.pt' ) 
results =  model( source= 'animal.jpg' ) result =  results[ 0 ] 
img =  result. plot( ) 
from  matplotlib import  pyplot as  plt
plt. imshow( X= img[ : , : , : : - 1 ] ) 
 
result. boxes"""
# 类别
cls: tensor([22., 20., 23., 20., 20.])
# 置信度 也就是概率
conf: tensor([0.8806, 0.8598, 0.5866, 0.5551, 0.3515])
data: tensor([[2.4926e+01, 5.1402e+02, 3.7411e+02, 7.9772e+02, 8.8055e-01, 2.2000e+01],[3.2387e+02, 3.8592e+02, 7.2567e+02, 8.0409e+02, 8.5977e-01, 2.0000e+01],[5.9173e+02, 2.6204e+02, 8.0608e+02, 7.7721e+02, 5.8656e-01, 2.3000e+01],[7.1596e+02, 6.3707e+02, 9.0578e+02, 8.5622e+02, 5.5513e-01, 2.0000e+01],[7.2943e+02, 5.2940e+02, 1.1668e+03, 7.8796e+02, 3.5151e-01, 2.0000e+01]])
id: None
is_track: False
orig_shape: (897, 1200)
shape: torch.Size([5, 6])
# 中心点坐标 (x,y) ,w宽 h高  n是规范化以后的数据,所有跟x相关的除以宽度,所有与y相关的除以高度,相当于归一化了 (相对坐标是用的比较多的)
xywh: tensor([[199.5182, 655.8711, 349.1838, 283.6943],[524.7690, 595.0039, 401.7979, 418.1656],[698.9015, 519.6245, 214.3517, 515.1679],[810.8722, 746.6467, 189.8149, 219.1466],[948.1376, 658.6791, 437.4136, 258.5655]])
xywhn: tensor([[0.1663, 0.7312, 0.2910, 0.3163],[0.4373, 0.6633, 0.3348, 0.4662],[0.5824, 0.5793, 0.1786, 0.5743],[0.6757, 0.8324, 0.1582, 0.2443],[0.7901, 0.7343, 0.3645, 0.2883]])
# 这个是左上角坐标(x,y)和右下角坐标(x,y)        
xyxy: tensor([[  24.9263,  514.0239,  374.1101,  797.7183],[ 323.8700,  385.9211,  725.6679,  804.0867],[ 591.7256,  262.0406,  806.0774,  777.2085],[ 715.9648,  637.0734,  905.7797,  856.2200],[ 729.4308,  529.3964, 1166.8444,  787.9619]])
xyxyn: tensor([[0.0208, 0.5730, 0.3118, 0.8893],[0.2699, 0.4302, 0.6047, 0.8964],[0.4931, 0.2921, 0.6717, 0.8665],[0.5966, 0.7102, 0.7548, 0.9545],[0.6079, 0.5902, 0.9724, 0.8784]])
"""