ultralytics 8.0.54
TFLite export improvements and fixes (#1447)
Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -22,11 +22,11 @@ export arguments.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom trained
|
||||
model = YOLO('yolov8n.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom trained
|
||||
|
||||
# Export the model
|
||||
model.export(format="onnx")
|
||||
model.export(format='onnx')
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
|
@ -26,9 +26,9 @@ Use a trained YOLOv8n/YOLOv8n-seg model to run tracker on video streams.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official detection model
|
||||
model = YOLO("yolov8n-seg.pt") # load an official segmentation model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n.pt') # load an official detection model
|
||||
model = YOLO('yolov8n-seg.pt') # load an official segmentation model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Track with the model
|
||||
results = model.track(source="https://youtu.be/Zgi9g1ksQHc", show=True)
|
||||
@ -60,7 +60,7 @@ to [predict page](https://docs.ultralytics.com/modes/predict/).
|
||||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO("yolov8n.pt")
|
||||
model = YOLO('yolov8n.pt')
|
||||
results = model.track(source="https://youtu.be/Zgi9g1ksQHc", conf=0.3, iou=0.5, show=True)
|
||||
```
|
||||
=== "CLI"
|
||||
@ -82,7 +82,7 @@ any configurations(expect the `tracker_type`) you need to.
|
||||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO("yolov8n.pt")
|
||||
model = YOLO('yolov8n.pt')
|
||||
results = model.track(source="https://youtu.be/Zgi9g1ksQHc", tracker='custom_tracker.yaml')
|
||||
```
|
||||
=== "CLI"
|
||||
|
@ -21,16 +21,24 @@ training arguments.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.yaml") # build a new model from scratch
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
model = YOLO('yolov8n.yaml') # build a new model from YAML
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO('yolov8n.yaml').load('yolov8n.pt') # build from YAML and transfer weights
|
||||
|
||||
# Train the model
|
||||
model.train(data="coco128.yaml", epochs=100, imgsz=640)
|
||||
model.train(data='coco128.yaml', epochs=100, imgsz=640)
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
```bash
|
||||
# Build a new model from YAML and start training from scratch
|
||||
yolo detect train data=coco128.yaml model=yolov8n.yaml epochs=100 imgsz=640
|
||||
|
||||
# Start training from a pretrained *.pt model
|
||||
yolo detect train data=coco128.yaml model=yolov8n.pt epochs=100 imgsz=640
|
||||
|
||||
# Build a new model from YAML, transfer pretrained weights to it and start training
|
||||
yolo detect train data=coco128.yaml model=yolov8n.yaml pretrained=yolov8n.pt epochs=100 imgsz=640
|
||||
```
|
||||
|
||||
## Arguments
|
||||
|
@ -21,8 +21,8 @@ training `data` and arguments as model attributes. See Arguments section below f
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Validate the model
|
||||
metrics = model.val() # no arguments needed, dataset and settings remembered
|
||||
|
@ -60,14 +60,14 @@ classification into their Python projects using YOLOv8.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.yaml") # build a new model from scratch
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
model = YOLO('yolov8n.yaml') # build a new model from scratch
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
|
||||
# Use the model
|
||||
results = model.train(data="coco128.yaml", epochs=3) # train the model
|
||||
results = model.train(data='coco128.yaml', epochs=3) # train the model
|
||||
results = model.val() # evaluate model performance on the validation set
|
||||
results = model("https://ultralytics.com/images/bus.jpg") # predict on an image
|
||||
success = model.export(format="onnx") # export the model to ONNX format
|
||||
results = model('https://ultralytics.com/images/bus.jpg') # predict on an image
|
||||
success = model.export(format='onnx') # export the model to ONNX format
|
||||
```
|
||||
|
||||
[Python Guide](usage/python.md){.md-button .md-button--primary}
|
||||
|
@ -26,11 +26,11 @@ see the [Configuration](../usage/cfg.md) page.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n-cls.yaml") # build a new model from scratch
|
||||
model = YOLO("yolov8n-cls.pt") # load a pretrained model (recommended for training)
|
||||
model = YOLO('yolov8n-cls.yaml') # build a new model from scratch
|
||||
model = YOLO('yolov8n-cls.pt') # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
model.train(data="mnist160", epochs=100, imgsz=64)
|
||||
model.train(data='mnist160', epochs=100, imgsz=64)
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
@ -51,8 +51,8 @@ it's training `data` and arguments as model attributes.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n-cls.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n-cls.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Validate the model
|
||||
metrics = model.val() # no arguments needed, dataset and settings remembered
|
||||
@ -78,17 +78,17 @@ Use a trained YOLOv8n-cls model to run predictions on images.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n-cls.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n-cls.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Predict with the model
|
||||
results = model("https://ultralytics.com/images/bus.jpg") # predict on an image
|
||||
results = model('https://ultralytics.com/images/bus.jpg') # predict on an image
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
```bash
|
||||
yolo classify predict model=yolov8n-cls.pt source="https://ultralytics.com/images/bus.jpg" # predict with official model
|
||||
yolo classify predict model=path/to/best.pt source="https://ultralytics.com/images/bus.jpg" # predict with custom model
|
||||
yolo classify predict model=yolov8n-cls.pt source='https://ultralytics.com/images/bus.jpg' # predict with official model
|
||||
yolo classify predict model=path/to/best.pt source='https://ultralytics.com/images/bus.jpg' # predict with custom model
|
||||
```
|
||||
|
||||
Read more details of `predict` in our [Predict](https://docs.ultralytics.com/modes/predict/) page.
|
||||
@ -105,11 +105,11 @@ Export a YOLOv8n-cls model to a different format like ONNX, CoreML, etc.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n-cls.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom trained
|
||||
model = YOLO('yolov8n-cls.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom trained
|
||||
|
||||
# Export the model
|
||||
model.export(format="onnx")
|
||||
model.export(format='onnx')
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
|
@ -26,11 +26,11 @@ the [Configuration](../usage/cfg.md) page.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.yaml") # build a new model from scratch
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
model = YOLO('yolov8n.yaml') # build a new model from scratch
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
model.train(data="coco128.yaml", epochs=100, imgsz=640)
|
||||
model.train(data='coco128.yaml', epochs=100, imgsz=640)
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
@ -51,8 +51,8 @@ training `data` and arguments as model attributes.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Validate the model
|
||||
metrics = model.val() # no arguments needed, dataset and settings remembered
|
||||
@ -80,17 +80,17 @@ Use a trained YOLOv8n model to run predictions on images.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Predict with the model
|
||||
results = model("https://ultralytics.com/images/bus.jpg") # predict on an image
|
||||
results = model('https://ultralytics.com/images/bus.jpg') # predict on an image
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
```bash
|
||||
yolo detect predict model=yolov8n.pt source="https://ultralytics.com/images/bus.jpg" # predict with official model
|
||||
yolo detect predict model=path/to/best.pt source="https://ultralytics.com/images/bus.jpg" # predict with custom model
|
||||
yolo detect predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg' # predict with official model
|
||||
yolo detect predict model=path/to/best.pt source='https://ultralytics.com/images/bus.jpg' # predict with custom model
|
||||
```
|
||||
|
||||
Read more details of `predict` in our [Predict](https://docs.ultralytics.com/modes/predict/) page.
|
||||
@ -107,11 +107,11 @@ Export a YOLOv8n model to a different format like ONNX, CoreML, etc.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom trained
|
||||
model = YOLO('yolov8n.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom trained
|
||||
|
||||
# Export the model
|
||||
model.export(format="onnx")
|
||||
model.export(format='onnx')
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
|
@ -28,11 +28,11 @@ train an OpenPose model on a custom dataset, see the OpenPose Training page.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.yaml") # build a new model from scratch
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
model = YOLO('yolov8n.yaml') # build a new model from scratch
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
model.train(data="coco128.yaml", epochs=100, imgsz=640)
|
||||
model.train(data='coco128.yaml', epochs=100, imgsz=640)
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
@ -53,8 +53,8 @@ training `data` and arguments as model attributes.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Validate the model
|
||||
metrics = model.val() # no arguments needed, dataset and settings remembered
|
||||
@ -82,17 +82,17 @@ Use a trained YOLOv8n model to run predictions on images.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Predict with the model
|
||||
results = model("https://ultralytics.com/images/bus.jpg") # predict on an image
|
||||
results = model('https://ultralytics.com/images/bus.jpg') # predict on an image
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
```bash
|
||||
yolo detect predict model=yolov8n.pt source="https://ultralytics.com/images/bus.jpg" # predict with official model
|
||||
yolo detect predict model=path/to/best.pt source="https://ultralytics.com/images/bus.jpg" # predict with custom model
|
||||
yolo detect predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg' # predict with official model
|
||||
yolo detect predict model=path/to/best.pt source='https://ultralytics.com/images/bus.jpg' # predict with custom model
|
||||
```
|
||||
|
||||
Read more details of `predict` in our [Predict](https://docs.ultralytics.com/modes/predict/) page.
|
||||
@ -109,11 +109,11 @@ Export a YOLOv8n model to a different format like ONNX, CoreML, etc.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom trained
|
||||
model = YOLO('yolov8n.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom trained
|
||||
|
||||
# Export the model
|
||||
model.export(format="onnx")
|
||||
model.export(format='onnx')
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
|
@ -26,11 +26,11 @@ arguments see the [Configuration](../usage/cfg.md) page.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n-seg.yaml") # build a new model from scratch
|
||||
model = YOLO("yolov8n-seg.pt") # load a pretrained model (recommended for training)
|
||||
model = YOLO('yolov8n-seg.yaml') # build a new model from scratch
|
||||
model = YOLO('yolov8n-seg.pt') # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
model.train(data="coco128-seg.yaml", epochs=100, imgsz=640)
|
||||
model.train(data='coco128-seg.yaml', epochs=100, imgsz=640)
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
@ -51,8 +51,8 @@ retains it's training `data` and arguments as model attributes.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n-seg.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n-seg.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Validate the model
|
||||
metrics = model.val() # no arguments needed, dataset and settings remembered
|
||||
@ -84,17 +84,17 @@ Use a trained YOLOv8n-seg model to run predictions on images.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n-seg.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom model
|
||||
model = YOLO('yolov8n-seg.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom model
|
||||
|
||||
# Predict with the model
|
||||
results = model("https://ultralytics.com/images/bus.jpg") # predict on an image
|
||||
results = model('https://ultralytics.com/images/bus.jpg') # predict on an image
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
```bash
|
||||
yolo segment predict model=yolov8n-seg.pt source="https://ultralytics.com/images/bus.jpg" # predict with official model
|
||||
yolo segment predict model=path/to/best.pt source="https://ultralytics.com/images/bus.jpg" # predict with custom model
|
||||
yolo segment predict model=yolov8n-seg.pt source='https://ultralytics.com/images/bus.jpg' # predict with official model
|
||||
yolo segment predict model=path/to/best.pt source='https://ultralytics.com/images/bus.jpg' # predict with custom model
|
||||
```
|
||||
|
||||
Read more details of `predict` in our [Predict](https://docs.ultralytics.com/modes/predict/) page.
|
||||
@ -111,11 +111,11 @@ Export a YOLOv8n-seg model to a different format like ONNX, CoreML, etc.
|
||||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO("yolov8n-seg.pt") # load an official model
|
||||
model = YOLO("path/to/best.pt") # load a custom trained
|
||||
model = YOLO('yolov8n-seg.pt') # load an official model
|
||||
model = YOLO('path/to/best.pt') # load a custom trained
|
||||
|
||||
# Export the model
|
||||
model.export(format="onnx")
|
||||
model.export(format='onnx')
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
|
@ -17,7 +17,7 @@ def on_predict_batch_end(predictor):
|
||||
im0s = im0s if isinstance(im0s, list) else [im0s]
|
||||
predictor.results = zip(predictor.results, im0s)
|
||||
|
||||
model = YOLO(f"yolov8n.pt")
|
||||
model = YOLO(f'yolov8n.pt')
|
||||
model.add_callback("on_predict_batch_end", on_predict_batch_end)
|
||||
for (result, frame) in model.track/predict():
|
||||
pass
|
||||
|
@ -59,8 +59,8 @@ Use a trained YOLOv8n model to run predictions on images.
|
||||
!!! example ""
|
||||
|
||||
```bash
|
||||
yolo detect predict model=yolov8n.pt source="https://ultralytics.com/images/bus.jpg" # predict with official model
|
||||
yolo detect predict model=path/to/best.pt source="https://ultralytics.com/images/bus.jpg" # predict with custom model
|
||||
yolo detect predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg' # predict with official model
|
||||
yolo detect predict model=path/to/best.pt source='https://ultralytics.com/images/bus.jpg' # predict with custom model
|
||||
```
|
||||
|
||||
## Export
|
||||
|
@ -6,7 +6,7 @@ The simplest way of simply using YOLOv8 directly in a Python environment.
|
||||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO("yolov8n.pt") # pass any model type
|
||||
model = YOLO('yolov8n.pt') # pass any model type
|
||||
model.train(epochs=5)
|
||||
```
|
||||
|
||||
@ -14,8 +14,8 @@ The simplest way of simply using YOLOv8 directly in a Python environment.
|
||||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO("yolov8n.yaml")
|
||||
model.train(data="coco128.yaml", epochs=5)
|
||||
model = YOLO('yolov8n.yaml')
|
||||
model.train(data='coco128.yaml', epochs=5)
|
||||
```
|
||||
|
||||
=== "Resume"
|
||||
@ -31,8 +31,8 @@ The simplest way of simply using YOLOv8 directly in a Python environment.
|
||||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO("yolov8n.yaml")
|
||||
model.train(data="coco128.yaml", epochs=5)
|
||||
model = YOLO('yolov8n.yaml')
|
||||
model.train(data='coco128.yaml', epochs=5)
|
||||
model.val() # It'll automatically evaluate the data you trained.
|
||||
```
|
||||
|
||||
@ -44,7 +44,7 @@ The simplest way of simply using YOLOv8 directly in a Python environment.
|
||||
# It'll use the data yaml file in model.pt if you don't set data.
|
||||
model.val()
|
||||
# or you can set the data you want to val
|
||||
model.val(data="coco128.yaml")
|
||||
model.val(data='coco128.yaml')
|
||||
```
|
||||
|
||||
!!! example "Predict"
|
||||
|
Reference in New Issue
Block a user