|
|
|
@ -113,7 +113,8 @@ YOLOv8 can process different types of input sources for inference, as shown in t |
|
|
|
|
| OpenCV | `cv2.imread('im.jpg')` | `np.ndarray` | HWC format with BGR channels `uint8 (0-255)`. | |
|
|
|
|
| numpy | `np.zeros((640,1280,3))` | `np.ndarray` | HWC format with BGR channels `uint8 (0-255)`. | |
|
|
|
|
| torch | `torch.zeros(16,3,320,640)` | `torch.Tensor` | BCHW format with RGB channels `float32 (0.0-1.0)`. | |
|
|
|
|
| txt | `'sources.txt'` | `str` or `Path` | txt file containing paths to images, videos, or directories. | |
|
|
|
|
| CSV | `'sources.csv'` | `str` or `Path` | CSV file containing paths to images, videos, or directories. |
|
|
|
|
| TXT | `'sources.txt'` | `str` or `Path` | TXT file containing paths to images, videos, or directories. | |
|
|
|
|
| video ✅ | `'video.mp4'` | `str` or `Path` | Video file in formats like MP4, AVI, etc. | |
|
|
|
|
| directory ✅ | `'path/'` | `str` or `Path` | Path to a directory containing images or videos. | |
|
|
|
|
| glob ✅ | `'path/*.jpg'` | `str` | Glob pattern to match multiple files. Use the `*` character as a wildcard. | |
|
|
|
@ -245,16 +246,31 @@ Below are code examples for using each source type: |
|
|
|
|
results = model(source) # list of Results objects |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
=== "txt" |
|
|
|
|
=== "CSV" |
|
|
|
|
|
|
|
|
|
Run inference on a collection of images, videos and directories listed in a txt file. |
|
|
|
|
Run inference on a collection of images, videos and directories listed in a CSV file. |
|
|
|
|
```python |
|
|
|
|
from ultralytics import YOLO |
|
|
|
|
|
|
|
|
|
# Load a pretrained YOLOv8n model |
|
|
|
|
model = YOLO("yolov8n.pt") |
|
|
|
|
|
|
|
|
|
# Define a path to a txt file with images, videos and directories |
|
|
|
|
# Define a path to a CSV file with images, videos and directories |
|
|
|
|
source = "path/to/file.csv" |
|
|
|
|
|
|
|
|
|
# Run inference on the source |
|
|
|
|
results = model(source) # list of Results objects |
|
|
|
|
|
|
|
|
|
=== "TXT" |
|
|
|
|
|
|
|
|
|
Run inference on a collection of images, videos and directories listed in a TXT file. |
|
|
|
|
```python |
|
|
|
|
from ultralytics import YOLO |
|
|
|
|
|
|
|
|
|
# Load a pretrained YOLOv8n model |
|
|
|
|
model = YOLO("yolov8n.pt") |
|
|
|
|
|
|
|
|
|
# Define a path to a TXT file with images, videos and directories |
|
|
|
|
source = "path/to/file.txt" |
|
|
|
|
|
|
|
|
|
# Run inference on the source |
|
|
|
|