| `cpu()` | Method | Returns a copy of the probs tensor on CPU memory. |
| `numpy()` | Method | Returns a copy of the probs tensor as a numpy array. |
| `cuda()` | Method | Returns a copy of the probs tensor on GPU memory. |
| `to()` | Method | Returns a copy of the probs tensor with the specified device and dtype. |
| `top1` | Property (`int`) | Index of the top 1 class. |
| `top5` | Property (`list[int]`) | Indices of the top 5 classes. |
| `top1conf` | Property (`torch.Tensor`) | Confidence of the top 1 class. |
| `top5conf` | Property (`torch.Tensor`) | Confidences of the top 5 classes. |
For more details see the `Probs` class [documentation](../reference/engine/results.md#probs).
For more details see the `Probs` class [documentation](../reference/engine/results.md).
## Plotting Results
You can the `plot()` method of a `Result` objects to plot predictions. It plots all prediction types (boxes, masks, keypoints, probabilities, etc.) contained in the `Results` object.
You can use the `plot()` method of a `Result` objects to visualize predictions. It plots all prediction types (boxes, masks, keypoints, probabilities, etc.) contained in the `Results` object onto a numpy array that can then be shown or saved.
!!! example "Plotting"
@ -570,8 +570,10 @@ You can the `plot()` method of a `Result` objects to plot predictions. It plots
# Show the results
for r in results:
im = r.plot() # plot a BGR numpy array of predictions
Image.fromarray(im[..., ::-1]).show() # show RGB image
im_array = r.plot() # plot a BGR numpy array of predictions
im = Image.fromarray(im[..., ::-1]) # RGB PIL image
im.show() # show image
im.save('results.jpg') # save image
```
The `plot()` method has the following arguments available:
@ -636,4 +638,4 @@ Here's a Python script using OpenCV (`cv2`) and YOLOv8 to run inference on video
cv2.destroyAllWindows()
```
This script will run predictions on each frame of the video, visualize the results, and display them in a window. The loop can be exited by pressing 'q'.
This script will run predictions on each frame of the video, visualize the results, and display them in a window. The loop can be exited by pressing 'q'.