mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 21:44:22 +08:00
Cli support (#50)
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:
parent
4291b9c31c
commit
512a225ce8
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -94,8 +94,8 @@ jobs:
|
|||||||
- name: Test segmentation
|
- name: Test segmentation
|
||||||
shell: bash # for Windows compatibility
|
shell: bash # for Windows compatibility
|
||||||
run: |
|
run: |
|
||||||
python ultralytics/yolo/v8/segment/train.py model=yolov5n-seg.yaml data=coco128-seg.yaml epochs=1 img_size=64
|
yolo task=segment mode=train model=yolov5n-seg.yaml data=coco128-seg.yaml epochs=1 img_size=64
|
||||||
- name: Test classification
|
- name: Test classification
|
||||||
shell: bash # for Windows compatibility
|
shell: bash # for Windows compatibility
|
||||||
run: |
|
run: |
|
||||||
python ultralytics/yolo/v8/classify/train.py model=resnet18 data=mnist160 epochs=1 img_size=32
|
yolo task=classify mode=train model=resnet18 data=mnist160 epochs=1 img_size=32
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -132,3 +132,5 @@ dmypy.json
|
|||||||
datasets/
|
datasets/
|
||||||
ultralytics-yolo/
|
ultralytics-yolo/
|
||||||
runs/
|
runs/
|
||||||
|
|
||||||
|
.DS_Store
|
28
README.md
28
README.md
@ -3,18 +3,32 @@
|
|||||||
### Install
|
### Install
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
pip install ultralytics
|
||||||
|
```
|
||||||
|
Development
|
||||||
|
```
|
||||||
git clone https://github.com/ultralytics/ultralytics
|
git clone https://github.com/ultralytics/ultralytics
|
||||||
cd ultralytics
|
cd ultralytics
|
||||||
python -m pip install --upgrade pip wheel
|
pip install -e .
|
||||||
pip install . # (dev)
|
|
||||||
# pip install ultralytics (production)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Usage
|
## Usage
|
||||||
|
### 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
|
||||||
|
```
|
||||||
|
### 2. Python SDK
|
||||||
|
To use pythonic interface of Ultralytics YOLO model
|
||||||
```python
|
```python
|
||||||
import ultralytics
|
import ultralytics
|
||||||
from ultralytics import HUB, YOLO
|
from ultralytics import YOLO
|
||||||
|
|
||||||
ultralytics.checks()
|
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, ...)
|
||||||
```
|
```
|
||||||
|
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.
|
||||||
|
5
setup.py
5
setup.py
@ -46,4 +46,7 @@ setup(
|
|||||||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||||||
"Topic :: Scientific/Engineering :: Image Recognition", "Operating System :: POSIX :: Linux",
|
"Topic :: Scientific/Engineering :: Image Recognition", "Operating System :: POSIX :: Linux",
|
||||||
"Operating System :: MacOS", "Operating System :: Microsoft :: Windows"],
|
"Operating System :: MacOS", "Operating System :: Microsoft :: Windows"],
|
||||||
keywords="machine-learning, deep-learning, vision, ML, DL, AI, YOLO, YOLOv3, YOLOv5, YOLOv8, HUB, Ultralytics")
|
keywords="machine-learning, deep-learning, vision, ML, DL, AI, YOLO, YOLOv3, YOLOv5, YOLOv8, HUB, Ultralytics",
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
'yolo = ultralytics.yolo.__init__:cli',],})
|
||||||
|
@ -1 +1 @@
|
|||||||
__version__ = "0.0.1.dev0"
|
__version__ = "8.0.0.dev0"
|
||||||
|
@ -1,7 +1,39 @@
|
|||||||
import ultralytics.yolo.v8 as v8
|
import hydra
|
||||||
|
|
||||||
|
import ultralytics
|
||||||
|
import ultralytics.yolo.v8 as yolo
|
||||||
|
|
||||||
from .engine.model import YOLO
|
from .engine.model import YOLO
|
||||||
from .engine.trainer import BaseTrainer
|
from .engine.trainer import DEFAULT_CONFIG, BaseTrainer
|
||||||
from .engine.validator import BaseValidator
|
from .engine.validator import BaseValidator
|
||||||
|
from .utils import LOGGER
|
||||||
|
|
||||||
__all__ = ["BaseTrainer", "BaseValidator", "YOLO"] # allow simpler import
|
__all__ = ["BaseTrainer", "BaseValidator", "YOLO"] # allow simpler import
|
||||||
|
|
||||||
|
|
||||||
|
@hydra.main(version_base=None, config_path="utils/configs", config_name="default")
|
||||||
|
def cli(cfg):
|
||||||
|
LOGGER.info(f"using Ultralytics YOLO v{ultralytics.__version__}")
|
||||||
|
module_file = None
|
||||||
|
if cfg.task.lower() == "detect":
|
||||||
|
module_file = yolo.detect
|
||||||
|
elif cfg.task.lower() == "segment":
|
||||||
|
module_file = yolo.segment
|
||||||
|
elif cfg.task.lower() == "classify":
|
||||||
|
module_file = yolo.classify
|
||||||
|
|
||||||
|
if not module_file:
|
||||||
|
raise Exception("task not recognized. Choices are `'detect', 'segment', 'classify'`")
|
||||||
|
|
||||||
|
module_function = None
|
||||||
|
|
||||||
|
if cfg.mode.lower() == "train":
|
||||||
|
module_function = module_file.train
|
||||||
|
elif cfg.mode.lower() == "val":
|
||||||
|
module_function = module_file.val
|
||||||
|
elif cfg.mode.lower() == "infer":
|
||||||
|
module_function = module_file.infer
|
||||||
|
|
||||||
|
if not module_function:
|
||||||
|
raise Exception("mode not recognized. Choices are `'train', 'val', 'infer'`")
|
||||||
|
module_function(cfg)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# YOLO 🚀 by Ultralytics, GPL-3.0 license
|
# YOLO 🚀 by Ultralytics, GPL-3.0 license
|
||||||
# Default training settings and hyperparameters for medium-augmentation COCO training
|
# Default training settings and hyperparameters for medium-augmentation COCO training
|
||||||
|
|
||||||
|
# Task and Mode
|
||||||
|
task: "classify" # choices=['detect', 'segment', 'classify']
|
||||||
|
mode: "train" # choice=['train', 'val', 'infer']
|
||||||
|
|
||||||
# Train settings -------------------------------------------------------------------------------------------------------
|
# Train settings -------------------------------------------------------------------------------------------------------
|
||||||
model: null # i.e. yolov5s.pt, yolo.yaml
|
model: null # i.e. yolov5s.pt, yolo.yaml
|
||||||
@ -36,7 +39,6 @@ max_det: 300
|
|||||||
half: True
|
half: True
|
||||||
plots: False
|
plots: False
|
||||||
save_txt: False
|
save_txt: False
|
||||||
task: 'val'
|
|
||||||
|
|
||||||
# Hyperparameters ------------------------------------------------------------------------------------------------------
|
# Hyperparameters ------------------------------------------------------------------------------------------------------
|
||||||
lr0: 0.001 # initial learning rate (SGD=1E-2, Adam=1E-3)
|
lr0: 0.001 # initial learning rate (SGD=1E-2, Adam=1E-3)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from ultralytics.yolo.v8.classify.train import ClassificationTrainer
|
from ultralytics.yolo.v8.classify.train import ClassificationTrainer, train
|
||||||
from ultralytics.yolo.v8.classify.val import ClassificationValidator
|
from ultralytics.yolo.v8.classify.val import ClassificationValidator
|
||||||
|
|
||||||
__all__ = ["train"]
|
__all__ = ["train"]
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
from ultralytics.yolo.v8.segment.train import SegmentationTrainer
|
from ultralytics.yolo.v8.segment.train import SegmentationTrainer, train
|
||||||
from ultralytics.yolo.v8.segment.val import SegmentationValidator
|
from ultralytics.yolo.v8.segment.val import SegmentationValidator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user