tao-train-visual-changenet
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVisual ChangeNet
Visual ChangeNet
Visual ChangeNet is a TAO Toolkit model for visual inspection and defect detection. It supports two tasks:
- Classify — Binary image classification using a siamese-style architecture with a shared backbone (C-RADIO ViT) and a learnable difference module. Compares image pairs to classify defects as PASS/NO_PASS.
- Segment — Pixel-level change segmentation using a ViT-Large NVDINOv2 backbone. Compares before/after image pairs to produce a binary change mask.
The backbone weight () is the model from HuggingFace, distributed as (~393 MB). The TAO 7.0.0-rc container does not auto-fetch from HF URLs — hands the value to / directly. Passing an URL or a repo id produces and the run fails with within a few seconds. Stage the file locally before launch:
c_radio_v2_vit_base_patch16_224nvidia/C-RADIOv2-Bmodel.safetensorsptm_utils.load_pretrained_weights()pretrained_backbone_pathtorch.load(path)safetensors.torch.load_file(path)https://huggingface.co/...FileNotFoundErrorExecution status: FAILbash
python3 -c "from huggingface_hub import hf_hub_download; import shutil; \
shutil.copy(hf_hub_download('nvidia/C-RADIOv2-B', 'model.safetensors'), '<workspace>/backbone/c_radio_v2_b.safetensors')"Mount it into the container () and set the spec to the container path. is only needed at staging time, not at training time.
-v <workspace>/backbone/c_radio_v2_b.safetensors:/data/pretrained_models/C-RADIOv2_B.safetensorsmodel.backbone.pretrained_backbone_pathHF_TOKENVisual ChangeNet是一款用于视觉检测和缺陷检测的TAO Toolkit模型。它支持两项任务:
- 分类 — 采用带有共享骨干网络(C-RADIO ViT)和可学习差异模块的孪生式架构进行二值图像分类。通过对比图像对将缺陷分为PASS/NO_PASS。
- 分割 — 使用ViT-Large NVDINOv2骨干网络进行像素级变化分割。对比前后图像对以生成二值变化掩码。
骨干权重()是来自HuggingFace的模型,以(约393 MB)格式分发。TAO 7.0.0-rc容器不会自动从HF URL获取权重 — 会直接将的值传递给 / 。传入 URL或仓库ID会导致,运行会在几秒内失败并显示。请在启动前将文件预存到本地:
c_radio_v2_vit_base_patch16_224nvidia/C-RADIOv2-Bmodel.safetensorsptm_utils.load_pretrained_weights()pretrained_backbone_pathtorch.load(path)safetensors.torch.load_file(path)https://huggingface.co/...FileNotFoundErrorExecution status: FAILbash
python3 -c "from huggingface_hub import hf_hub_download; import shutil; \
shutil.copy(hf_hub_download('nvidia/C-RADIOv2-B', 'model.safetensors'), '<workspace>/backbone/c_radio_v2_b.safetensors')"将其挂载到容器中(),并将配置设置为容器内的路径。仅在预存文件时需要,训练时不需要。
-v <workspace>/backbone/c_radio_v2_b.safetensors:/data/pretrained_models/C-RADIOv2_B.safetensorsmodel.backbone.pretrained_backbone_pathHF_TOKENDataclass Schemas
数据类模式
Generated TAO Core schemas are packaged in , with listing available actions. Each generated schema also emits from the schema top-level field. AutoML enablement is declared at the model layer in via . Runnable AutoML still requires and to exist and parse. Use the packaged train schema for , , defaults, min/max bounds, enums, option weights, math conditions, dependencies, and popular parameters. Do not expect at runtime; maintainers regenerate schemas/templates before packaging the skill bank.
schemas/<action>.schema.jsonschemas/manifest.jsonreferences/spec_template_<action>.yamldefaultreferences/skill_info.yamlautoml_enabledschemas/train.schema.jsonreferences/spec_template_train.yamlautoml_default_parametersautoml_disabled_parameters~/tao-core生成的TAO Core模式打包在中,列出了可用的操作。每个生成的模式还会从模式顶层的字段生成。AutoML支持在中的模型层通过声明。可运行的AutoML仍要求和存在且可解析。使用打包的训练模式来设置、、默认值、最小/最大边界、枚举、选项权重、数学条件、依赖关系以及常用参数。运行时不要依赖;维护人员在打包技能库前会重新生成模式/模板。
schemas/<action>.schema.jsonschemas/manifest.jsondefaultreferences/spec_template_<action>.yamlreferences/skill_info.yamlautoml_enabledschemas/train.schema.jsonreferences/spec_template_train.yamlautoml_default_parametersautoml_disabled_parameters~/tao-coreTrain Action Policy
训练操作策略
This model is AutoML-enabled at the model layer. Before handling any train-stage request, read and resolve the run override from either an explicit value or the user's workflow request. Treat phrases like "turn off AutoML", "disable AutoML", "no HPO", or "plain training" as for this run only; otherwise default to . When , , and both and are packaged, route the train action through by default with this model's . Preserve workflow/application overrides for datasets, specs, output directories, GPU/platform settings, parent checkpoints, and . Use direct model training only when or the packaged train schema/template is missing; in the missing-schema case, report that AutoML is enabled but not runnable for this model until schemas are generated.
references/skill_info.yamlautoml_policyautoml_policy: offautoautoml_policy: autoautoml_enabled: trueschemas/train.schema.jsonreferences/spec_template_train.yamltao-skill-bank:tao-run-automlskill_dirautoml_policyautoml_policy: offNon-train actions such as , , , and deploy flows stay in this model skill. The per-run override does not change model metadata.
evaluateinferenceexportautoml_policyFor TAO Deploy TensorRT actions (, TensorRT , and TensorRT for classify and segment variants), read first. Deploy spec templates live in this skill's folder with the prefix.
gen_trt_engineevaluateinferencereferences/tao-deploy-visual-changenet.mdreferences/spec_template_deploy_*.yaml该模型在模型层支持AutoML。处理任何训练阶段请求前,请读取,并通过显式的值或用户的工作流请求来解析运行覆盖配置。将"turn off AutoML"、"disable AutoML"、"no HPO"或"plain training"这类短语视为本次运行的;否则默认设为。当、且和均已打包时,默认将训练操作通过路由,并传入该模型的。保留数据集、配置、输出目录、GPU/平台设置、父检查点和的工作流/应用覆盖配置。仅当或打包的训练模式/模板缺失时,才使用直接模型训练;如果模式缺失,需报告该模型已启用AutoML但无法运行,直到生成模式为止。
references/skill_info.yamlautoml_policyautoml_policy: offautoautoml_policy: autoautoml_enabled: trueschemas/train.schema.jsonreferences/spec_template_train.yamltao-skill-bank:tao-run-automlskill_dirautoml_policyautoml_policy: off非训练操作(如、、以及部署流程)仍在该模型技能中执行。每次运行的覆盖配置不会更改模型元数据。
evaluateinferenceexportautoml_policy对于TAO Deploy TensorRT操作(、TensorRT 以及分类和分割变体的TensorRT ),请先阅读。部署配置模板位于该技能的文件夹中,前缀为。
gen_trt_engineevaluateinferencereferences/tao-deploy-visual-changenet.mdreferences/spec_template_deploy_*.yamlTasks
任务
Classify (default)
分类(默认)
Uses actions: , , . Defaults template: .
trainevaluateinferencereferences/spec_template_train.yaml使用操作:、、。默认模板:。
trainevaluateinferencereferences/spec_template_train.yamlSegment
分割
Uses actions: , , . Defaults template: .
segment_trainsegment_evaluatesegment_inferencereferences/spec_template_segment.yamlSegmentation requires compiling custom CUDA ops () on first run, which takes ~5 minutes. The ViT adapter backbone uses these for multi-scale feature extraction.
MultiScaleDeformableAttentionDataset structure for segmentation differs from classify — uses paired directories (, , , ) instead of CSV files. See in the defaults.
A/B/list/label/dataset.segment.root_dir使用操作:、、。默认模板:。
segment_trainsegment_evaluatesegment_inferencereferences/spec_template_segment.yaml分割任务首次运行时需要编译自定义CUDA算子(),耗时约5分钟。ViT适配器骨干网络使用这些算子进行多尺度特征提取。
MultiScaleDeformableAttention分割任务的数据集结构与分类不同 — 使用配对目录(、、、)而非CSV文件。请参见默认配置中的。
A/B/list/label/dataset.segment.root_dirDatasets, Spec Overrides, and Data Format
数据集、配置覆盖与数据格式
Visual ChangeNet has two task modes with different dataset types and data source structures. Classify uses a 4-column CSV () plus an images directory; segment uses a paired directory structure (, , , ) under a single . Data source overrides are mandatory for every action — the agent MUST construct data source paths and include them in .
input_path,golden_path,label,object_nameA/B/list/label/root_dirspec_overridesSee for the full per-action dataset requirement tables (classify and segment), every spec-override example (train, export, quantize, evaluate, inference, gen_trt_engine for both variants), the classify CSV format, evaluate/inference and segment input fields, lighting conventions, segment data layout, and the multi-lighting configuration.
references/dataset-and-specs.mdinput_mapVisual ChangeNet有两种任务模式,对应不同的数据集类型和数据源结构。分类任务使用4列CSV()加图像目录;分割任务在单个下使用配对目录结构(、、、)。每个操作都必须覆盖数据源配置 — 代理必须构建数据源路径并将其包含在中。
input_path,golden_path,label,object_nameroot_dirA/B/list/label/spec_overrides有关分类和分割任务的各操作数据集要求表、所有配置覆盖示例(训练、导出、量化、评估、推理、两种变体的)、分类CSV格式、评估/推理和分割输入字段、光照约定、分割数据布局以及多光照配置,请参见。
gen_trt_engineinput_mapreferences/dataset-and-specs.mdLocal Docker Invocation
本地Docker调用
Without the TAO SDK, resolve the TAO pyt image from and invoke directly with and the backbone mounted as a single file. See for the full command, the shared-memory requirement, the backbone mount detail, and the checkpoint/results_dir command-line override pattern.
versions.yamlvisual_changenet <action>--shm-size=8g.ckptreferences/local-docker-invocation.mddocker run如果没有TAO SDK,请从中解析TAO pyt镜像,直接调用,并设置,同时将骨干网络作为单个文件挂载。完整的命令、共享内存要求、骨干网络挂载细节以及检查点/results_dir命令行覆盖模式,请参见。
versions.yamlvisual_changenet <action>--shm-size=8g.ckptdocker runreferences/local-docker-invocation.mdParameters, Hardware, and Error Patterns
参数、硬件与错误模式
Key knobs include (default 50, must be ≤ num_epochs), (default 200, must be ≤ num_epochs), (default 100), (default 0.3, the primary precision/recall threshold), and (default [1.0, 10.0]). Minimum hardware is 1 GPU with 16GB+ VRAM; 8 GPUs (DDP) are recommended for production. GPU count is managed internally by TAO — do not set .
train.validation_intervaltrain.checkpoint_intervaltrain.num_epochsmodel.classify.eval_margintrain.classify.cls_weightgpu_spec_keySee for the full parameter reference, hardware guidance, and the complete error-pattern catalog (checkpoint not found, CSV format mismatch, image extension mismatch, OOM, low eval accuracy, the contrastive-loss assertion, non-convergence, the segment-only MultiScaleDeformableAttention build, Lightning epoch misconfiguration, PYTHONPATH/ModuleNotFoundError, and epoch defaults).
references/parameters-and-troubleshooting.md关键参数包括(默认50,必须≤训练轮数)、(默认200,必须≤训练轮数)、(默认100)、(默认0.3,主要的精确率/召回率阈值)和(默认[1.0, 10.0])。最低硬件要求为1块显存≥16GB的GPU;生产环境推荐使用8块GPU(DDP)。GPU数量由TAO内部管理 — 请勿设置。
train.validation_intervaltrain.checkpoint_intervaltrain.num_epochsmodel.classify.eval_margintrain.classify.cls_weightgpu_spec_key完整的参数参考、硬件指南以及完整的错误模式目录(检查点未找到、CSV格式不匹配、图像扩展名不匹配、内存不足、评估准确率低、对比损失断言、不收敛、分割任务专属的MultiScaleDeformableAttention构建、Lightning训练轮数配置错误、PYTHONPATH/ModuleNotFoundError、训练轮数默认值问题),请参见。
references/parameters-and-troubleshooting.mdSpec Param / Parent Model Inference
配置参数 / 父模型推理
Model-specific inference mappings belong in this MD file, not in . Generated runners should read this section and apply the mappings with SDK helpers before . This mirrors the old microservices flow.
config.jsoncreate_job()infer_params.pyInference mappings from this model skill:
| Action | Spec Field | Inference Function | Meaning |
|---|---|---|---|
| evaluate | | | current job results directory |
| inference | | | current job results directory |
| train | | | current job results directory |
| train | | | model file inferred from the current job results folder |
For or , pass the upstream train/export/AutoML child job id as . The SDK lists the parent result folder, filters checkpoint artifacts, and returns the selected model file or folder. Do not add these mappings back to and do not patch generated runner scripts to guess checkpoint paths.
parent_modelparent_model_folderparent_job_idconfig.json模型特定的推理映射应放在此MD文件中,而非。生成的运行器应读取本节内容,并在前使用SDK助手应用这些映射。这与旧微服务的流程一致。
config.jsoncreate_job()infer_params.py该模型技能的推理映射:
| 操作 | 配置字段 | 推理函数 | 含义 |
|---|---|---|---|
| evaluate | | | 当前作业结果目录 |
| inference | | | 当前作业结果目录 |
| train | | | 当前作业结果目录 |
| train | | | 从当前作业结果文件夹推断出的模型文件 |
对于或,将上游训练/导出/AutoML子作业ID作为传入。SDK会列出父结果文件夹,过滤检查点工件,并返回选定的模型文件或文件夹。请勿将这些映射添加回,也不要修改生成的运行器脚本以猜测检查点路径。
parent_modelparent_model_folderparent_job_idconfig.jsonDeployment
部署
- tao-deploy-visual-changenet — Visual ChangeNet deploy workflow for TensorRT engine generation, TensorRT evaluation, and TensorRT inference using TAO Deploy.
- tao-deploy-visual-changenet — 基于TAO Deploy的Visual ChangeNet部署工作流,用于TensorRT引擎生成、TensorRT评估和TensorRT推理。