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
|
|
@ -60,7 +60,7 @@ The default tracker is BoT-SORT.
|
|||
|
||||
If object confidence score will be low, i.e lower than [`track_high_thresh`](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/trackers/bytetrack.yaml#L5), then there will be no tracks successfully returned and updated.
|
||||
|
||||
To run the tracker on video streams, use a trained Detect, Segment or Pose model such as YOLOv8n, YOLOv8n-seg and YOLOv8n-pose.
|
||||
To run the tracker on video streams, use a trained Detect, Segment or Pose model such as YOLO11n, YOLO11n-seg and YOLO11n-pose.
|
||||
|
||||
!!! example
|
||||
|
||||
|
|
@ -70,9 +70,9 @@ To run the tracker on video streams, use a trained Detect, Segment or Pose model
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load an official or custom model
|
||||
model = YOLO("yolov8n.pt") # Load an official Detect model
|
||||
model = YOLO("yolov8n-seg.pt") # Load an official Segment model
|
||||
model = YOLO("yolov8n-pose.pt") # Load an official Pose model
|
||||
model = YOLO("yolo11n.pt") # Load an official Detect model
|
||||
model = YOLO("yolo11n-seg.pt") # Load an official Segment model
|
||||
model = YOLO("yolo11n-pose.pt") # Load an official Pose model
|
||||
model = YOLO("path/to/best.pt") # Load a custom trained model
|
||||
|
||||
# Perform tracking with the model
|
||||
|
|
@ -84,9 +84,9 @@ To run the tracker on video streams, use a trained Detect, Segment or Pose model
|
|||
|
||||
```bash
|
||||
# Perform tracking with various models using the command line interface
|
||||
yolo track model=yolov8n.pt source="https://youtu.be/LNwODJXcvt4" # Official Detect model
|
||||
yolo track model=yolov8n-seg.pt source="https://youtu.be/LNwODJXcvt4" # Official Segment model
|
||||
yolo track model=yolov8n-pose.pt source="https://youtu.be/LNwODJXcvt4" # Official Pose model
|
||||
yolo track model=yolo11n.pt source="https://youtu.be/LNwODJXcvt4" # Official Detect model
|
||||
yolo track model=yolo11n-seg.pt source="https://youtu.be/LNwODJXcvt4" # Official Segment model
|
||||
yolo track model=yolo11n-pose.pt source="https://youtu.be/LNwODJXcvt4" # Official Pose model
|
||||
yolo track model=path/to/best.pt source="https://youtu.be/LNwODJXcvt4" # Custom trained model
|
||||
|
||||
# Track using ByteTrack tracker
|
||||
|
|
@ -113,7 +113,7 @@ Tracking configuration shares properties with Predict mode, such as `conf`, `iou
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Configure the tracking parameters and run the tracker
|
||||
model = YOLO("yolov8n.pt")
|
||||
model = YOLO("yolo11n.pt")
|
||||
results = model.track(source="https://youtu.be/LNwODJXcvt4", conf=0.3, iou=0.5, show=True)
|
||||
```
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ Tracking configuration shares properties with Predict mode, such as `conf`, `iou
|
|||
|
||||
```bash
|
||||
# Configure tracking parameters and run the tracker using the command line interface
|
||||
yolo track model=yolov8n.pt source="https://youtu.be/LNwODJXcvt4" conf=0.3, iou=0.5 show
|
||||
yolo track model=yolo11n.pt source="https://youtu.be/LNwODJXcvt4" conf=0.3, iou=0.5 show
|
||||
```
|
||||
|
||||
### Tracker Selection
|
||||
|
|
@ -136,7 +136,7 @@ Ultralytics also allows you to use a modified tracker configuration file. To do
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load the model and run the tracker with a custom configuration file
|
||||
model = YOLO("yolov8n.pt")
|
||||
model = YOLO("yolo11n.pt")
|
||||
results = model.track(source="https://youtu.be/LNwODJXcvt4", tracker="custom_tracker.yaml")
|
||||
```
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ Ultralytics also allows you to use a modified tracker configuration file. To do
|
|||
|
||||
```bash
|
||||
# Load the model and run the tracker with a custom configuration file using the command line interface
|
||||
yolo track model=yolov8n.pt source="https://youtu.be/LNwODJXcvt4" tracker='custom_tracker.yaml'
|
||||
yolo track model=yolo11n.pt source="https://youtu.be/LNwODJXcvt4" tracker='custom_tracker.yaml'
|
||||
```
|
||||
|
||||
For a comprehensive list of tracking arguments, refer to the [ultralytics/cfg/trackers](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/trackers) page.
|
||||
|
|
@ -153,7 +153,7 @@ For a comprehensive list of tracking arguments, refer to the [ultralytics/cfg/tr
|
|||
|
||||
### Persisting Tracks Loop
|
||||
|
||||
Here is a Python script using [OpenCV](https://www.ultralytics.com/glossary/opencv) (`cv2`) and YOLOv8 to run object tracking on video frames. This script still assumes you have already installed the necessary packages (`opencv-python` and `ultralytics`). The `persist=True` argument tells the tracker that the current image or frame is the next in a sequence and to expect tracks from the previous image in the current image.
|
||||
Here is a Python script using [OpenCV](https://www.ultralytics.com/glossary/opencv) (`cv2`) and YOLO11 to run object tracking on video frames. This script still assumes you have already installed the necessary packages (`opencv-python` and `ultralytics`). The `persist=True` argument tells the tracker that the current image or frame is the next in a sequence and to expect tracks from the previous image in the current image.
|
||||
|
||||
!!! example "Streaming for-loop with tracking"
|
||||
|
||||
|
|
@ -162,8 +162,8 @@ Here is a Python script using [OpenCV](https://www.ultralytics.com/glossary/open
|
|||
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load the YOLOv8 model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load the YOLO11 model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Open the video file
|
||||
video_path = "path/to/video.mp4"
|
||||
|
|
@ -175,14 +175,14 @@ Here is a Python script using [OpenCV](https://www.ultralytics.com/glossary/open
|
|||
success, frame = cap.read()
|
||||
|
||||
if success:
|
||||
# Run YOLOv8 tracking on the frame, persisting tracks between frames
|
||||
# Run YOLO11 tracking on the frame, persisting tracks between frames
|
||||
results = model.track(frame, persist=True)
|
||||
|
||||
# Visualize the results on the frame
|
||||
annotated_frame = results[0].plot()
|
||||
|
||||
# Display the annotated frame
|
||||
cv2.imshow("YOLOv8 Tracking", annotated_frame)
|
||||
cv2.imshow("YOLO11 Tracking", annotated_frame)
|
||||
|
||||
# Break the loop if 'q' is pressed
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
|
|
@ -200,9 +200,9 @@ Please note the change from `model(frame)` to `model.track(frame)`, which enable
|
|||
|
||||
### Plotting Tracks Over Time
|
||||
|
||||
Visualizing object tracks over consecutive frames can provide valuable insights into the movement patterns and behavior of detected objects within a video. With Ultralytics YOLOv8, plotting these tracks is a seamless and efficient process.
|
||||
Visualizing object tracks over consecutive frames can provide valuable insights into the movement patterns and behavior of detected objects within a video. With Ultralytics YOLO11, plotting these tracks is a seamless and efficient process.
|
||||
|
||||
In the following example, we demonstrate how to utilize YOLOv8's tracking capabilities to plot the movement of detected objects across multiple video frames. This script involves opening a video file, reading it frame by frame, and utilizing the YOLO model to identify and track various objects. By retaining the center points of the detected bounding boxes and connecting them, we can draw lines that represent the paths followed by the tracked objects.
|
||||
In the following example, we demonstrate how to utilize YOLO11's tracking capabilities to plot the movement of detected objects across multiple video frames. This script involves opening a video file, reading it frame by frame, and utilizing the YOLO model to identify and track various objects. By retaining the center points of the detected bounding boxes and connecting them, we can draw lines that represent the paths followed by the tracked objects.
|
||||
|
||||
!!! example "Plotting tracks over multiple video frames"
|
||||
|
||||
|
|
@ -214,8 +214,8 @@ In the following example, we demonstrate how to utilize YOLOv8's tracking capabi
|
|||
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load the YOLOv8 model
|
||||
model = YOLO("yolov8n.pt")
|
||||
# Load the YOLO11 model
|
||||
model = YOLO("yolo11n.pt")
|
||||
|
||||
# Open the video file
|
||||
video_path = "path/to/video.mp4"
|
||||
|
|
@ -230,7 +230,7 @@ In the following example, we demonstrate how to utilize YOLOv8's tracking capabi
|
|||
success, frame = cap.read()
|
||||
|
||||
if success:
|
||||
# Run YOLOv8 tracking on the frame, persisting tracks between frames
|
||||
# Run YOLO11 tracking on the frame, persisting tracks between frames
|
||||
results = model.track(frame, persist=True)
|
||||
|
||||
# Get the boxes and track IDs
|
||||
|
|
@ -253,7 +253,7 @@ In the following example, we demonstrate how to utilize YOLOv8's tracking capabi
|
|||
cv2.polylines(annotated_frame, [points], isClosed=False, color=(230, 230, 230), thickness=10)
|
||||
|
||||
# Display the annotated frame
|
||||
cv2.imshow("YOLOv8 Tracking", annotated_frame)
|
||||
cv2.imshow("YOLO11 Tracking", annotated_frame)
|
||||
|
||||
# Break the loop if 'q' is pressed
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
|
|
@ -275,7 +275,7 @@ In the provided Python script, we make use of Python's `threading` module to run
|
|||
|
||||
To ensure that each thread receives the correct parameters (the video file, the model to use and the file index), we define a function `run_tracker_in_thread` that accepts these parameters and contains the main tracking loop. This function reads the video frame by frame, runs the tracker, and displays the results.
|
||||
|
||||
Two different models are used in this example: `yolov8n.pt` and `yolov8n-seg.pt`, each tracking objects in a different video file. The video files are specified in `video_file1` and `video_file2`.
|
||||
Two different models are used in this example: `yolo11n.pt` and `yolo11n-seg.pt`, each tracking objects in a different video file. The video files are specified in `video_file1` and `video_file2`.
|
||||
|
||||
The `daemon=True` parameter in `threading.Thread` means that these threads will be closed as soon as the main program finishes. We then start the threads with `start()` and use `join()` to make the main thread wait until both tracker threads have finished.
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ Finally, after all threads have completed their task, the windows displaying the
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Define model names and video sources
|
||||
MODEL_NAMES = ["yolov8n.pt", "yolov8n-seg.pt"]
|
||||
MODEL_NAMES = ["yolo11n.pt", "yolo11n-seg.pt"]
|
||||
SOURCES = ["path/to/video.mp4", "0"] # local video, 0 for webcam
|
||||
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ Finally, after all threads have completed their task, the windows displaying the
|
|||
Run YOLO tracker in its own thread for concurrent processing.
|
||||
|
||||
Args:
|
||||
model_name (str): The YOLOv8 model object.
|
||||
model_name (str): The YOLO11 model object.
|
||||
filename (str): The path to the video file or the identifier for the webcam/external camera source.
|
||||
"""
|
||||
model = YOLO(model_name)
|
||||
|
|
@ -357,14 +357,14 @@ You can configure a custom tracker by copying an existing tracker configuration
|
|||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO("yolov8n.pt")
|
||||
model = YOLO("yolo11n.pt")
|
||||
results = model.track(source="https://youtu.be/LNwODJXcvt4", tracker="custom_tracker.yaml")
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
||||
```bash
|
||||
yolo track model=yolov8n.pt source="https://youtu.be/LNwODJXcvt4" tracker='custom_tracker.yaml'
|
||||
yolo track model=yolo11n.pt source="https://youtu.be/LNwODJXcvt4" tracker='custom_tracker.yaml'
|
||||
```
|
||||
|
||||
### How can I run object tracking on multiple video streams simultaneously?
|
||||
|
|
@ -381,7 +381,7 @@ To run object tracking on multiple video streams simultaneously, you can use Pyt
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Define model names and video sources
|
||||
MODEL_NAMES = ["yolov8n.pt", "yolov8n-seg.pt"]
|
||||
MODEL_NAMES = ["yolo11n.pt", "yolo11n-seg.pt"]
|
||||
SOURCES = ["path/to/video.mp4", "0"] # local video, 0 for webcam
|
||||
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ To run object tracking on multiple video streams simultaneously, you can use Pyt
|
|||
Run YOLO tracker in its own thread for concurrent processing.
|
||||
|
||||
Args:
|
||||
model_name (str): The YOLOv8 model object.
|
||||
model_name (str): The YOLO11 model object.
|
||||
filename (str): The path to the video file or the identifier for the webcam/external camera source.
|
||||
"""
|
||||
model = YOLO(model_name)
|
||||
|
|
@ -438,7 +438,7 @@ To visualize object tracks over multiple video frames, you can use the YOLO mode
|
|||
|
||||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO("yolov8n.pt")
|
||||
model = YOLO("yolo11n.pt")
|
||||
video_path = "path/to/video.mp4"
|
||||
cap = cv2.VideoCapture(video_path)
|
||||
track_history = defaultdict(lambda: [])
|
||||
|
|
@ -458,7 +458,7 @@ To visualize object tracks over multiple video frames, you can use the YOLO mode
|
|||
track.pop(0)
|
||||
points = np.hstack(track).astype(np.int32).reshape((-1, 1, 2))
|
||||
cv2.polylines(annotated_frame, [points], isClosed=False, color=(230, 230, 230), thickness=10)
|
||||
cv2.imshow("YOLOv8 Tracking", annotated_frame)
|
||||
cv2.imshow("YOLO11 Tracking", annotated_frame)
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
break
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue