Make YOLO a module (#111)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Ayush Chaurasia 2022-12-29 00:08:37 +05:30 committed by GitHub
parent 0303ced8ab
commit 34829a6b29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 39 deletions

View file

@ -16,19 +16,21 @@ pip install -e .
### 1. CLI
To simply use the latest Ultralytics YOLO models
```bash
yolo task=detect mode=train model=s.yaml ...
classify infer s-cls.yaml
segment val s-seg.yaml
yolo task=detect mode=train model=yolov8n.yaml ...
classify predict yolov8n-cls.yaml
segment val yolov8n-seg.yaml
```
### 2. Python SDK
To use pythonic interface of Ultralytics YOLO model
```python
import ultralytics
from ultralytics import YOLO
model = YOLO()
model.new("s-seg.yaml") # automatically detects task type
model.load("s-seg.pt") # load checkpoint
model.train(data="coco128-segments", epochs=1, lr0=0.01, ...)
model = YOLO.new('yolov8n.yaml') # create a new model from scratch
model = YOLO.load('yolov8n.pt') # load a pretrained model (recommended for best training results)
results = model.train(data='coco128.yaml', epochs=100, imgsz=640, ...)
results = model.val()
results = model.predict(source='bus.jpg')
success = model.export(format='onnx')
```
If you're looking to modify YOLO for R&D or to build on top of it, refer to [Using Trainer]() Guide on our docs.