getitune-training-a-model
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTraining a model with getitune
使用getitune训练模型
getituneEnginecreate_engine(...)library/src/getitune/recipe/<task>/There are two equal entry points that share the same objects and recipes:
- Python API — , then
from getitune.engine import create_engine/engine.train(). Preferred for notebooks, scripts, tests, and library integration. Seeengine.test()("Quick Start") andlibrary/README.md.library/docs/source/guide/get_started/api_tutorial.rst - CLI — . Preferred for reproducible experiments and shell workflows. See
getitune train --data_root <path> --model <name|recipe.yaml>.library/docs/source/guide/get_started/cli_commands.rst
Run everything from . Install with the extra that matches your
hardware: (cpu), , or .
library/uv syncuv sync --extra xpuuv sync --extra cudagetitunecreate_engine(...)Enginelibrary/src/getitune/recipe/<task>/有两个等价的入口点,它们共享相同的对象和recipes:
- Python API — 导入,然后调用
from getitune.engine import create_engine/engine.train()。适用于Notebook、脚本、测试和库集成场景。详见engine.test()(“快速开始”)和library/README.md。library/docs/source/guide/get_started/api_tutorial.rst - CLI — 执行。适用于可复现的实验和Shell工作流。详见
getitune train --data_root <path> --model <name|recipe.yaml>。library/docs/source/guide/get_started/cli_commands.rst
所有操作都在目录下执行。根据你的硬件安装对应的扩展包:(CPU)、或。
library/uv syncuv sync --extra xpuuv sync --extra cudaPython API workflow
Python API工作流
python
from getitune.engine import create_engine
engine = create_engine(
model="efficientnet_b0", # model name, recipe .yaml path, or model class
data="/path/to/dataset_root", # dataset root (COCO/YOLO/VOC/native), auto-detected
work_dir="./my_workspace", # checkpoints + logs; defaults to ./getitune-workspace
device="auto", # "auto", "cpu", "gpu", "xpu", "cuda", "0", ...
)
engine.train(max_epochs=50)
engine.test()- Pick the model/recipe. Pass a model name (), a recipe path (
"efficientnet_b0"), or a model class. If a name matches recipes under several tasks, pass"src/getitune/recipe/detection/yolox_s.yaml"(e.g.task=) to disambiguate. Use thetask="DETECTION"skill to list options.getitune-discovering-models- Done when: returns without a
create_engine(...)/ValueError.FileNotFoundError
- Done when:
- Point at the dataset root. Format is auto-detected by Datumaro; see the
data=skill.getitune-preparing-datasets- Done when: the engine builds a datamodule without a format/feature error.
- Smoke-test the wiring first with a tiny run (or a small subset) before a long run.
engine.train(max_epochs=1)- Done when: one train + one validation pass complete without shape errors.
- Train, overriding hyperparameters as needed
().
engine.train(max_epochs=50)- Done when: checkpoints appear under .
work_dir
- Done when: checkpoints appear under
- Evaluate with and confirm the task metric moves, not just loss. Record the model +
engine.test()that produced it.work_dir
Warm-start from existing weights with
.
create_engine(..., checkpoint="/path/to/weights.pt")python
from getitune.engine import create_engine
engine = create_engine(
model="efficientnet_b0", # 模型名称、recipe .yaml路径或模型类
data="/path/to/dataset_root", # 数据集根目录(COCO/YOLO/VOC/原生格式),会自动检测格式
work_dir="./my_workspace", # 检查点和日志存储目录;默认是./getitune-workspace
device="auto", # "auto"、"cpu"、"gpu"、"xpu"、"cuda"、"0"等
)
engine.train(max_epochs=50)
engine.test()- 选择模型/recipe。传入模型名称()、recipe路径(
"efficientnet_b0")或模型类。如果一个名称对应多个任务下的recipe,需传入"src/getitune/recipe/detection/yolox_s.yaml"参数(例如task=)来消除歧义。使用task="DETECTION"技能查看可选选项。getitune-discovering-models- 完成标志:执行后未抛出
create_engine(...)/ValueError。FileNotFoundError
- 完成标志:
- 将指向数据集根目录。格式由Datumaro自动检测;详见
data=技能。getitune-preparing-datasets- 完成标志:引擎成功构建数据模块,未出现格式/特征错误。
- 先进行冒烟测试:在长时间运行前,先执行一次小型运行(或使用小数据集子集)。
engine.train(max_epochs=1)- 完成标志:一次训练+一次验证过程顺利完成,未出现形状错误。
- 训练:根据需要覆盖超参数()。
engine.train(max_epochs=50)- 完成标志:检查点出现在目录下。
work_dir
- 完成标志:检查点出现在
- 评估:调用并确认任务指标有所变化,而不仅仅是损失值。记录生成该模型的模型名称和
engine.test()路径。work_dir
通过从已有权重热启动训练。
create_engine(..., checkpoint="/path/to/weights.pt")CLI workflow
CLI工作流
bash
undefinedbash
undefinedfrom library/
在library/目录下执行
1. Simplest: data only — getitune picks a default model for the task
1. 最简方式:仅指定数据集 — getitune会为任务选择默认模型
getitune train --data_root /path/to/dataset
getitune train --data_root /path/to/dataset
2. Choose a model or recipe
2. 选择模型或recipe
getitune train --data_root /path/to/dataset --model yolox_s
getitune train --data_root /path/to/dataset --model yolox_s
3. Override hyperparameters
3. 覆盖超参数
getitune train --data_root /path/to/dataset --model yolox_s
--max_epochs 200 --checkpoint /path/to/weights.pt
--max_epochs 200 --checkpoint /path/to/weights.pt
getitune train --data_root /path/to/dataset --model yolox_s
--max_epochs 200 --checkpoint /path/to/weights.pt
--max_epochs 200 --checkpoint /path/to/weights.pt
4. Run a full, resolved config file
4. 使用完整的已解析配置文件运行
getitune train --data_root /path/to/dataset --config src/getitune/recipe/detection/yolox_s.yaml
`getitune test` and `getitune predict` share the same `--model` / `--data_root`
shape. Use `getitune <cmd> --help -v` (and `-vv`) for the full overridable
argument list.getitune train --data_root /path/to/dataset --config src/getitune/recipe/detection/yolox_s.yaml
`getitune test`和`getitune predict`使用与上述相同的`--model` / `--data_root`参数格式。使用`getitune <cmd> --help -v`(以及`-vv`)查看所有可覆盖的参数列表。Choosing a device
选择设备
- selects an available accelerator; force with
device="auto","cpu","gpu","xpu", or an index like"cuda"."0" - The device must match the installed extra — for Intel GPUs,
--extra xpufor NVIDIA. Guard nothing yourself; the library handles capability checks.--extra cuda
- 会自动选择可用的加速器;也可以强制指定为
device="auto"、"cpu"、"gpu"、"xpu"或索引值如"cuda"。"0" - 设备必须与安装的扩展包匹配 — Intel GPU使用,NVIDIA GPU使用
--extra xpu。无需自行检查兼容性,库会处理能力验证。--extra cuda
Debugging a run
调试训练运行
- Run one epoch on a small dataset first to isolate construction vs. dataloading vs. training failures.
- Shape/feature mismatches usually mean the dataset's labels or task disagree
with the model — recheck and the dataset format (
task=).getitune-preparing-datasets - Dataset auto-detection failures: confirm the folder matches one supported layout (COCO/YOLO/VOC/native).
- 先在小数据集上运行一个epoch,以区分是构建阶段、数据加载阶段还是训练阶段的错误。
- 形状/特征不匹配通常意味着数据集的标签或任务与模型不匹配 — 重新检查参数和数据集格式(参考
task=技能)。getitune-preparing-datasets - 数据集自动检测失败:确认文件夹结构符合支持的格式(COCO/YOLO/VOC/原生格式)。
Verify
验证
bash
undefinedbash
undefinedfrom library/
在library/目录下执行
just lint
just test-unit -- -k engine # when you changed engine/training code
For API-facing work, add or run a short Python smoke test that calls
`create_engine(...)` + `engine.train(max_epochs=1)` on a tiny fixture rather than
a long real run.just lint
just test-unit -- -k engine # 当你修改了引擎/训练代码时执行
对于面向API的工作,添加或运行一个简短的Python冒烟测试,在小型测试数据上调用`create_engine(...)` + `engine.train(max_epochs=1)`,而不是运行长时间的真实训练。Related skills
相关技能
- — list models/recipes and disambiguate by task.
getitune-discovering-models - — the
getitune-preparing-datasetshalf of the engine.data= - — export a trained checkpoint to OpenVINO/ONNX.
getitune-exporting-a-model - — run predictions with a trained or exported model.
getitune-running-inference - — when the library/model code itself needs changes.
geti-library-dev
- — 列出模型/recipes并按任务消除歧义。
getitune-discovering-models - — 引擎的
getitune-preparing-datasets部分相关技能。data= - — 将训练好的检查点导出为OpenVINO/ONNX格式。
getitune-exporting-a-model - — 使用训练好的或导出的模型运行推理。
getitune-running-inference - — 当需要修改库/模型代码本身时使用。
geti-library-dev