YOLO11 Tasks, Modes, Usage, Macros and Solutions Updates (#16593)
Signed-off-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
3093fc9ec2
commit
51e93d6111
31 changed files with 541 additions and 541 deletions
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
comments: true
|
||||
description: Harness the power of Ultralytics YOLOv8 for real-time, high-speed inference on various data sources. Learn about predict mode, key features, and practical applications.
|
||||
keywords: Ultralytics, YOLOv8, model prediction, inference, predict mode, real-time inference, computer vision, machine learning, streaming, high performance
|
||||
description: Harness the power of Ultralytics YOLO11 for real-time, high-speed inference on various data sources. Learn about predict mode, key features, and practical applications.
|
||||
keywords: Ultralytics, YOLO11, model prediction, inference, predict mode, real-time inference, computer vision, machine learning, streaming, high performance
|
||||
---
|
||||
|
||||
# Model Prediction with Ultralytics YOLO
|
||||
|
|
@ -10,7 +10,7 @@ keywords: Ultralytics, YOLOv8, model prediction, inference, predict mode, real-t
|
|||
|
||||
## Introduction
|
||||
|
||||
In the world of [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv), the process of making sense out of visual data is called 'inference' or 'prediction'. Ultralytics YOLOv8 offers a powerful feature known as **predict mode** that is tailored for high-performance, real-time inference on a wide range of data sources.
|
||||
In the world of [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) and [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv), the process of making sense out of visual data is called 'inference' or 'prediction'. Ultralytics YOLO11 offers a powerful feature known as **predict mode** that is tailored for high-performance, real-time inference on a wide range of data sources.
|
||||
|
||||
<p align="center">
|
||||
<br>
|
||||
|
|
@ -32,7 +32,7 @@ In the world of [machine learning](https://www.ultralytics.com/glossary/machine-
|
|||
|
||||
## Why Use Ultralytics YOLO for Inference?
|
||||
|
||||
Here's why you should consider YOLOv8's predict mode for your various inference needs:
|
||||
Here's why you should consider YOLO11's predict mode for your various inference needs:
|
||||
|
||||
- **Versatility:** Capable of making inferences on images, videos, and even live streams.
|
||||
- **Performance:** Engineered for real-time, high-speed processing without sacrificing [accuracy](https://www.ultralytics.com/glossary/accuracy).
|
||||
|
|
@ -41,7 +41,7 @@ Here's why you should consider YOLOv8's predict mode for your various inference
|
|||
|
||||
### Key Features of Predict Mode
|
||||
|
||||
YOLOv8's predict mode is designed to be robust and versatile, featuring:
|
||||
YOLO11's predict mode is designed to be robust and versatile, featuring:
|
||||
|
||||
- **Multiple Data Source Compatibility:** Whether your data is in the form of individual images, a collection of images, video files, or real-time video streams, predict mode has you covered.
|
||||
- **Streaming Mode:** Use the streaming feature to generate a memory-efficient generator of `Results` objects. Enable this by setting `stream=True` in the predictor's call method.
|
||||
|
|
@ -58,7 +58,7 @@ Ultralytics YOLO models return either a Python list of `Results` objects, or a m
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # pretrained YOLOv8n model
|
||||
model = YOLO("yolo11n.pt") # pretrained YOLO11n model
|
||||
|
||||
# Run batched inference on a list of images
|
||||
results = model(["image1.jpg", "image2.jpg"]) # return a list of Results objects
|
||||
|
|
@ -80,7 +80,7 @@ Ultralytics YOLO models return either a Python list of `Results` objects, or a m
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # pretrained YOLOv8n model
|
||||
model = YOLO("yolo11n.pt") # pretrained YOLO11n model
|
||||
|
||||
# Run batched inference on a list of images
|
||||
results = model(["image1.jpg", "image2.jpg"], stream=True) # return a generator of Results objects
|
||||
|
|
@ -98,7 +98,7 @@ Ultralytics YOLO models return either a Python list of `Results` objects, or a m
|
|||
|
||||
## Inference Sources
|
||||
|
||||
YOLOv8 can process different types of input sources for inference, as shown in the table below. The sources include static images, video streams, and various data formats. The table also indicates whether each source can be used in streaming mode with the argument `stream=True` ✅. Streaming mode is beneficial for processing videos or live streams as it creates a generator of results instead of loading all frames into memory.
|
||||
YOLO11 can process different types of input sources for inference, as shown in the table below. The sources include static images, video streams, and various data formats. The table also indicates whether each source can be used in streaming mode with the argument `stream=True` ✅. Streaming mode is beneficial for processing videos or live streams as it creates a generator of results instead of loading all frames into memory.
|
||||
|
||||
!!! tip
|
||||
|
||||
|
|
@ -131,8 +131,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Define path to the image file
|
||||
source = "path/to/image.jpg"
|
||||
|
|
@ -147,8 +147,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Define current screenshot as source
|
||||
source = "screen"
|
||||
|
|
@ -163,8 +163,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Define remote image or video URL
|
||||
source = "https://ultralytics.com/images/bus.jpg"
|
||||
|
|
@ -181,8 +181,8 @@ Below are code examples for using each source type:
|
|||
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Open an image using PIL
|
||||
source = Image.open("path/to/image.jpg")
|
||||
|
|
@ -199,8 +199,8 @@ Below are code examples for using each source type:
|
|||
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Read an image using OpenCV
|
||||
source = cv2.imread("path/to/image.jpg")
|
||||
|
|
@ -217,8 +217,8 @@ Below are code examples for using each source type:
|
|||
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Create a random numpy array of HWC shape (640, 640, 3) with values in range [0, 255] and type uint8
|
||||
source = np.random.randint(low=0, high=255, size=(640, 640, 3), dtype="uint8")
|
||||
|
|
@ -235,8 +235,8 @@ Below are code examples for using each source type:
|
|||
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Create a random torch tensor of BCHW shape (1, 3, 640, 640) with values in range [0, 1] and type float32
|
||||
source = torch.rand(1, 3, 640, 640, dtype=torch.float32)
|
||||
|
|
@ -251,8 +251,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Define a path to a CSV file with images, URLs, videos and directories
|
||||
source = "path/to/file.csv"
|
||||
|
|
@ -267,8 +267,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Define path to video file
|
||||
source = "path/to/video.mp4"
|
||||
|
|
@ -283,8 +283,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Define path to directory containing images and videos for inference
|
||||
source = "path/to/dir"
|
||||
|
|
@ -299,8 +299,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Define a glob search for all JPG files in a directory
|
||||
source = "path/to/dir/*.jpg"
|
||||
|
|
@ -318,8 +318,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Define source as YouTube video URL
|
||||
source = "https://youtu.be/LNwODJXcvt4"
|
||||
|
|
@ -335,8 +335,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Single stream with batch-size 1 inference
|
||||
source = "rtsp://example.com/media.mp4" # RTSP, RTMP, TCP, or IP streaming address
|
||||
|
|
@ -354,8 +354,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Multiple streams with batched inference (e.g., batch-size 8 for 8 streams)
|
||||
source = "path/to/list.streams" # *.streams text file with one streaming address per line
|
||||
|
|
@ -385,8 +385,8 @@ Below are code examples for using each source type:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Run inference on 'bus.jpg' with arguments
|
||||
model.predict("bus.jpg", save=True, imgsz=320, conf=0.5)
|
||||
|
|
@ -402,7 +402,7 @@ Visualization arguments:
|
|||
|
||||
## Image and Video Formats
|
||||
|
||||
YOLOv8 supports various image and video formats, as specified in [ultralytics/data/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/utils.py). See the tables below for the valid suffixes and example predict commands.
|
||||
YOLO11 supports various image and video formats, as specified in [ultralytics/data/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/utils.py). See the tables below for the valid suffixes and example predict commands.
|
||||
|
||||
### Images
|
||||
|
||||
|
|
@ -449,8 +449,8 @@ All Ultralytics `predict()` calls will return a list of `Results` objects:
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Run inference on an image
|
||||
results = model("bus.jpg") # list of 1 Results object
|
||||
|
|
@ -501,8 +501,8 @@ For more details see the [`Results` class documentation](../reference/engine/res
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Run inference on an image
|
||||
results = model("bus.jpg") # results list
|
||||
|
|
@ -540,7 +540,7 @@ For more details see the [`Boxes` class documentation](../reference/engine/resul
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n-seg Segment model
|
||||
model = YOLO("yolov8n-seg.pt")
|
||||
model = YOLO("yolo11n-seg.pt")
|
||||
|
||||
# Run inference on an image
|
||||
results = model("bus.jpg") # results list
|
||||
|
|
@ -573,7 +573,7 @@ For more details see the [`Masks` class documentation](../reference/engine/resul
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n-pose Pose model
|
||||
model = YOLO("yolov8n-pose.pt")
|
||||
model = YOLO("yolo11n-pose.pt")
|
||||
|
||||
# Run inference on an image
|
||||
results = model("bus.jpg") # results list
|
||||
|
|
@ -607,7 +607,7 @@ For more details see the [`Keypoints` class documentation](../reference/engine/r
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n-cls Classify model
|
||||
model = YOLO("yolov8n-cls.pt")
|
||||
model = YOLO("yolo11n-cls.pt")
|
||||
|
||||
# Run inference on an image
|
||||
results = model("bus.jpg") # results list
|
||||
|
|
@ -642,7 +642,7 @@ For more details see the [`Probs` class documentation](../reference/engine/resul
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n-obb.pt")
|
||||
model = YOLO("yolo11n-obb.pt")
|
||||
|
||||
# Run inference on an image
|
||||
results = model("bus.jpg") # results list
|
||||
|
|
@ -682,7 +682,7 @@ The `plot()` method in `Results` objects facilitates visualization of prediction
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a pretrained YOLOv8n model
|
||||
model = YOLO("yolov8n.pt")
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Run inference on 'bus.jpg'
|
||||
results = model(["bus.jpg", "zidane.jpg"]) # results list
|
||||
|
|
@ -747,8 +747,8 @@ When using YOLO models in a multi-threaded application, it's important to instan
|
|||
|
||||
|
||||
# Starting threads that each have their own model instance
|
||||
Thread(target=thread_safe_predict, args=("yolov8n.pt", "image1.jpg")).start()
|
||||
Thread(target=thread_safe_predict, args=("yolov8n.pt", "image2.jpg")).start()
|
||||
Thread(target=thread_safe_predict, args=("yolo11n.pt", "image1.jpg")).start()
|
||||
Thread(target=thread_safe_predict, args=("yolo11n.pt", "image2.jpg")).start()
|
||||
```
|
||||
|
||||
For an in-depth look at thread-safe inference with YOLO models and step-by-step instructions, please refer to our [YOLO Thread-Safe Inference Guide](../guides/yolo-thread-safe-inference.md). This guide will provide you with all the necessary information to avoid common pitfalls and ensure that your multi-threaded inference runs smoothly.
|
||||
|
|
@ -765,7 +765,7 @@ Here's a Python script using OpenCV (`cv2`) and YOLOv8 to run inference on video
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load the YOLOv8 model
|
||||
model = YOLO("yolov8n.pt")
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Open the video file
|
||||
video_path = "path/to/your/video/file.mp4"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue