tao-train-grounding-dino
NVIDIA/skills
針對一個名為 Grounding DINO 的模型,進行訓練、評估、匯出、量化,並執行推論;該模型可根據文字提示偵測物件,且無需固定的類別詞彙表。
...展開全部DINO 的基礎訓練
適用於開放集物件偵測的 Grounding DINO。結合 DINO 風格的偵測機制與 BERT 文字編碼器,實現語言引導式偵測。可根據文字提示偵測物件,且無需固定類別詞彙表。
若需完整的 Grounding DINO 權重,請設定 `train.pretrained_model_path`;若僅需骨幹模型,請設定 `model.pretrained_backbone_path`。
若要使用 TAO Deploy 的 TensorRT 動作(gen_trt_engine、TensorRTevaluate 及 TensorRTinference),請先閱讀references/tao-deploy-grounding-dino.md。 部署規格範本位於此技能的references/資料夾中,檔案名稱以spec_template_deploy_*.yaml為前綴。
資料類別模式
生成的 TAO Core 模式封裝於schemas/ 中,而schemas/manifest.json則列出了可用的動作。每個生成的模式還會從模式頂層的default欄位產生references/spec_template_。 AutoML 的啟用設定是在references/skill_info.yaml的模型層級透過automl_enabled 宣告的。可執行的 AutoML 仍需schemas/train.schema.json和references/spec_template_train.yaml存在並能被解析。 請使用封裝好的訓練模式來設定automl_default_parameters、automl_disabled_parameters、預設值、最小/最大範圍、枚舉、選項權重、數學條件、依賴關係以及常用參數。請勿預期在執行時能找到~/tao-core;維護人員會在封裝技能庫之前重新生成模式與範本。
訓練動作政策
此模型在模型層級已啟用 AutoML。在處理任何訓練階段請求之前,請讀取references/skill_info.yaml,並從顯式的automl_policy值或使用者的工作流程請求中解析執行覆寫設定。預設使用automl_policy: on,並僅在新啟動提示中提供on/off選項。 將「關閉 AutoML」、「停用 AutoML」、「不使用 HPO」或「普通訓練」等短語視為僅針對本次執行設定automl_policy: off。 當automl_policy: on、automl_enabled: true,且schemas/train.schema.json與references/spec_template_train.yaml均已打包時,預設會將訓練動作透過tao-skill-bank:tao-run-automl進行路由,並使用該模型的skill_dir。 保留針對資料集、規格、輸出目錄、GPU/平台設定、父檢查點以及automl_policy 的工作流程/應用程式覆寫設定。 僅當`automl_policy: off` 或打包的訓練模式/範本缺失時,才使用直接模型訓練;在模式缺失的情況下,應回報「AutoML 已啟用,但此模型在產生模式前無法執行」。
非訓練操作(例如評估、推論、匯出和部署流程)仍保留在此模型技能中。每次執行時的automl_policy覆寫設定不會變更模型元資料。
訓練需求
- 資料集類型:object_detection
- 格式:odvg、coco、raw
- 監控指標:val_mAP50
各動作的資料集要求
| 動作 | 規格關鍵字 | 來源 | 檔案 | 清單? |
|---|---|---|---|---|
| 評估 | 資料集.test_data_sources | eval_dataset | image_dir:images.tar.gz,json_file:annotations.json | 否 |
| 推論 | dataset.infer_data_sources.image_dir | 推論資料集 | images.tar.gz | 是 |
| 推論 | 資料集.推論_資料來源.圖說 | 工作流程提示 | 提示清單 | 是 |
| 量化 | 資料集.訓練資料來源 | train_datasets | image_dir: images.tar.gz, json_file: annotations_odvg.jsonl, label_map: annotations_odvg_labelmap.json | 是 |
| 量化 | 資料集.val_data_sources | eval_dataset | image_dir:images.tar.gz,json_file:annotations.json | 否 |
| 量化 | 資料集.量化校準資料來源 | 校準/評估資料集 | image_dir:images.tar.gz,json_file:annotations.json | 否 |
| 訓練 | 資料集.train_data_sources | 訓練資料集 | image_dir:images.tar.gz,json_file:annotations_odvg.jsonl,label_map:annotations_odvg_labelmap.json | 是 |
| train | dataset.val_data_sources | 評估資料集 | image_dir:images.tar.gz,json_file:annotations.json | 否 |
執行器可將映像檔存檔(如images.tar.gz)作為來源,但直接的本地
Docker TAO CLI 規格必須將image_dir指向已解壓縮的映像檔目錄。
技能元資料會為這些以存檔為基礎的映像檔來源標記
runtime: extracted_folder,以便新的執行器能在
啟動 TAO 之前解壓縮該存檔。
常見的規格覆寫
每個動作都必須覆寫資料來源 — 代理程式必須根據上方的「每項動作資料集需求」表格建構資料來源路徑,並將其納入spec_overrides 中。
S3_TRAIN = "s3://bucket/data/train"
S3_EVAL = "s3://bucket/data/eval"
train(必填資料來源):
{
"train.num_epochs": 10,
"train.checkpoint_interval": 10,
"train.validation_interval": 10,
"train.num_gpus": 1,
"dataset.train_data_sources": [{"image_dir": f"{S3_TRAIN}/images.tar.gz", "json_file": f"{S3_TRAIN}/annotations_odvg.jsonl", "label_map": f"{S3_TRAIN}/annotations_odvg_labelmap.json"}],
"dataset.val_data_sources": {"image_dir": f"{S3_EVAL}/images.tar.gz", "json_file": f"{S3_EVAL}/annotations.json"},
}
deploy/gen_trt_engine(使用references/tao-deploy-grounding-dino.md):
{
"gen_trt_engine.onnx_file": "",
"gen_trt_engine.trt_engine": "",
"gen_trt_engine.tensorrt.data_type": "FP16",
}
推論(必填資料來源):
{
"inference.checkpoint": "<選定的訓練/AutoML 檢查點>",
"dataset.infer_data_sources.image_dir": [f"{S3_EVAL}/images.tar.gz"],
"dataset.infer_data_sources.captions": [
"滅火器",
"錐形路標",
"手推車",
"叉車"
],
}
評估(必填資料來源):
{
"evaluate.checkpoint": "<選定的訓練/AutoML 檢查點>",
"dataset.test_data_sources": {"image_dir": f"{S3_EVAL}/images.tar.gz", "json_file": f"{S3_EVAL}/annotations.json"},
}
量化 (必填資料來源):
{
"quantize.model_path": "",
"dataset.train_data_sources": [{"image_dir": f"{S3_TRAIN}/images.tar.gz", "json_file": f"{S3_TRAIN}/annotations_odvg.jsonl", "label_map": f"{S3_TRAIN}/annotations_odvg_labelmap.json"}],
"dataset.val_data_sources": {"image_dir": f"{S3_EVAL}/images.tar.gz", "json_file": f"{S3_EVAL}/annotations.json"},
"dataset.quant_calibration_data_sources": {"image_dir": f"{S3_EVAL}/images.tar.gz", "json_file": f"{S3_EVAL}/annotations.json"},
}
評估資料集
可選。儘管訓練可使用 ODVG 格式,但驗證時會採用 COCO 格式的標註來計算 mAP。
重要參數
- model.backbone:預設為 swin_tiny_224_1k。亦支援 resnet_50 及其他 Swin 變體。Swin 通常在定位任務上表現更佳。
- model.text_encoder_type:用於文字編碼的 BERT 模型。預設為 bert-base-uncased。max_text_len 的預設值為 256。
- model.max_text_len:請確保此參數與資料集標籤/標記 位置映射保持一致。除非對應的 標籤映射已以相同長度重新生成,否則請勿在快速測試中縮減此參數;否則驗證階段可能會 因標記機率與位置 映射之間的矩陣形狀不匹配而失敗。
- train.optim.lr:學習率。預設值為 2e-4。lr_backbone 為 2e-5。除 fp16/fp32 外,亦支援 bf16 精度。
- dataset.max_labels:訓練期間每張圖片的最大標籤數。預設值為 50。對於標註密集的資料集,請增加此數值。
- model.num_queries:物件查詢次數。由於開放詞彙表的特性,預設值為 900(高於 DINO 的 300)。
- model.num_queries / model.num_select:請將
num_queries設定得足夠高, 以因應批次中匹配的 ODVG 目標數量。 若 smoke 值設定過低 (例如 20),在處理高密度影像時,匈牙利演算法目標索引可能會失敗;除非已知 資料集每張影像的物件數量較少,否則針對 Grounding DINO 的 smoke 運行, 請至少設定 100。 - train.optim.lr_steps:多階段學習率(MultiStep LR)調度。預設值 [10]。
多 GPU / 多節點
啟動方式:Lightning 管理(單一Python程序,由 Lightning 啟動工作執行者)。
| 規格參數 | 說明 | 預設值 |
|---|---|---|
train.num_gpus |
GPU 數量 | 1 |
train.gpu_ids |
GPU 裝置索引 | [0] |
train.num_nodes |
節點數量 | 1 |
train.distributed_strategy |
ddp或fsdp |
ddp |
與 DINO 相同的 DDP/FSDP 行為。多節點模式需要由協調器設定WORLD_SIZE、NODE_RANK、MASTER_ADDR、MASTER_PORT等環境變數。
匯出 / TRT 預設值
- 匯出輸入:960x544(比其他 OD 模型更大),操作集 17。保留
Grounding-DINO 匯出規格應維持在範本匯出解析度以進行初步測試;
若將匯出尺寸縮小至 128x128 等極小影像,可能會在
`torch.onnx.export` 執行期間,觸發對比文本頭中的 PyTorch ONNX 形狀推論斷言。 - 其父級 PyTorch
grounding_dino命令列介面支援訓練、評估、推論、匯出及量化。請透過references/tao-deploy-grounding-dino.md執行 TensorRT 引擎生成、 TensorRT 推論及 TensorRT 評估。 - TRT 資料類型:僅支援 FP32、FP16 —不支援 INT8
- TRT 工作區:8192 MB(比其他 OD 模型大 8 倍)
- TRT max_batch_size:4
硬體
至少 1 張 GPU,建議 4 張 GPU。每張 GPU 需具備 24GB+(建議使用 A100)的 VRAM。由於 Grounding DINO 採用文字編碼器(BERT),其運算負荷較標準 DINO 更高。建議使用 24GB+ 的 GPU 記憶體。 若使用 16GB GPU,請降低 batch_size 數值。
錯誤模式
CUDA 記憶體不足:請減少 batch_size(4 → 2 → 1)。BERT 文字編碼器會在視覺主架構之上增加顯著的記憶體開銷。
Val 標註類別 ID:為正確計算損失,驗證標註的類別 ID 應從 0 開始。如有需要,請使用標註格式轉換功能。
文字編碼器載入錯誤:請確保容器能下載 bert-base-uncased 權重,或提供本機路徑。
在 TAO Toolkit 7.0.0-rc-226 中使用 PyTorch 檢查點進行量化失敗:
容器的 Grounding-DINO 量化腳本在
載入檢查點時傳入cap_lists=None,導致post_process.py 執行失敗。 ONNX 量化使用
匯出的 ONNX 產出檔及 COCO 校準資料,但預設的 rc-226
PyTorch 映像檔也缺少modelopt.onnx.quantization模組。請將此視為
映像檔/SDK 的阻滯問題,而非檢查點解析器的問題。
在post_process.py中無法對 mat1 和 mat2 的形狀進行乘法運算:文字
標記長度與標籤位置映射不一致,通常是因為
model.max_text_len被覆寫為低於預設值 256,而資料集
的標籤映射仍使用 256 長度的位置映射。 請恢復model.max_text_len的預設值,或
以相同長度重新生成標籤映射。
criterion.py中第 0 維度的索引超出範圍:model.num_queries
對於當前批次中匹配的 ODVG 目標而言過小。請增加
model.num_queries,並確保model.num_select與其相容。
images.tar.gz/發生 NotADirectoryError:直接 TAO CLI 正
嘗試將壓縮檔路徑當作目錄進行遍歷。請解壓縮檔案,並將
相關的image_dir欄位設定為解壓縮後的圖片資料夾;基於壓縮檔的
技能資料來源會使用runtime:extracted_folder,正是基於此原因。
規格參數 / 父模型推論
特定於模型的推論映射應置於此 MD 檔案中,而非config.json。生成的執行程式應讀取此節內容,並在呼叫 create_job() 之前透過 SDK 輔助函式套用這些映射。此作法與舊版微服務的infer_params.py流程一致。
來自 TAO Core `grounding_dino.config.json` 的推論映射:
| 動作 | 規格欄位 | 推論函式 | 含義 |
|---|---|---|---|
| evaluate | 加密金鑰 |
密鑰 |
加密金鑰 |
| 評估 | evaluate.checkpoint |
父模型 |
從父工作結果資料夾推斷出的模型檔案 |
| evaluate | evaluate.trt_engine |
parent_model |
從父工作結果資料夾推導出的模型檔案 |
| 評估 | results_dir |
output_dir |
當前工作結果目錄 |
| 匯出 | 加密金鑰 |
密鑰 |
加密金鑰 |
| 匯出 | export.checkpoint |
父模型 |
從父工作結果資料夾推斷出的模型檔案 |
| 匯出 | export.onnx_file |
建立 ONNX 檔案 |
ONNX 輸出路徑 |
| 匯出 | 結果目錄 |
輸出目錄 |
當前工作結果目錄 |
| 推論 | 加密金鑰 |
密鑰 |
加密金鑰 |
| 推論 | 推論檢查點 |
父模型 |
從父任務結果資料夾推導出的模型檔案 |
| 推論 | inference.trt_engine |
parent_model |
從父工作結果資料夾推斷出的模型檔案 |
| 推論 | results_dir |
輸出目錄 |
當前工作結果目錄 |
| 量化 | 加密金鑰 |
密鑰 |
加密金鑰 |
| 量化 | 量化.模型路徑 |
父模型 |
從父工作結果資料夾推斷出的模型檔案 |
| 量化 | results_dir |
輸出目錄 |
當前工作結果目錄 |
| train | 加密金鑰 |
密鑰 |
加密金鑰 |
| train | model.pretrained_backbone_path |
若無恢復檢查點時使用 PTM |
當不存在恢復檢查點時的 PTM |
| train | results_dir |
輸出目錄 |
當前工作結果目錄 |
| train | train.pretrained_model_path |
ptm_if_no_resume_model |
當不存在恢復檢查點時使用的 PTM |
| train | train.resume_training_checkpoint_path |
resume_model |
從當前工作結果資料夾推斷出的模型檔案 |
對於parent_model或parent_model_folder,請將上游 train/export/AutoML 子工作 ID 傳入作為parent_job_id。SDK 會列出父結果資料夾、篩選檢查點資源,並回傳選定的模型檔案或資料夾。 請勿將這些對應關係重新加入config.json,亦請勿修改生成的執行程式腳本以推測檢查點路徑。
在 SDK 解析器之外選取 Grounding-DINO 檢查點時,請精確匹配
目標的 epoch/step 產出檔案,例如
model_epoch_000_step_00046.pth。gdino_model_latest.pth符號連結僅在
明確要求 latest 時才有效。 請將結構性模型設定(例如
model.backbone、model.num_queries、model.num_select、
model.num_feature_levels、model.max_text_len 以及輸出輸入解析度)
向前傳遞至 evaluate、inference、export 和 deploy 規格中,以確保檢查點與
引擎的結構相符。
部署
- tao-deploy-grounding-dino
---
name: tao-train-grounding-dino
description: Trains, evaluates, exports, quantizes, and runs inference for a Grounding DINO model that detects objects described by text prompts without a fixed class vocabulary.
license: Apache-2.0
---
# Grounding DINO
Grounding DINO for open-set object detection. Combines DINO-style detection with BERT text encoder for language-guided detection. Detects objects described by text prompts without fixed class vocabulary.
Set train.pretrained_model_path for full Grounding DINO weights or model.pretrained_backbone_path for backbone-only.
For TAO Deploy TensorRT actions (`gen_trt_engine`, TensorRT `evaluate`, and TensorRT `inference`), read `references/tao-deploy-grounding-dino.md` first. Deploy spec templates live in this skill's `references/` folder with the `spec_template_deploy_*.yaml` prefix.
## Dataclass Schemas
Generated TAO Core schemas are packaged in `schemas/<action>.schema.json`, with `schemas/manifest.json` listing available actions. Each generated schema also emits `references/spec_template_<action>.yaml` from the schema top-level `default` field. AutoML enablement is declared at the model layer in `references/skill_info.yaml` via `automl_enabled`. Runnable AutoML still requires `schemas/train.schema.json` and `references/spec_template_train.yaml` to exist and parse. Use the packaged train schema for `automl_default_parameters`, `automl_disabled_parameters`, defaults, min/max bounds, enums, option weights, math conditions, dependencies, and popular parameters. Do not expect `~/tao-core` at runtime; maintainers regenerate schemas/templates before packaging the skill bank.
## Train Action Policy
This model is AutoML-enabled at the model layer. Before handling any train-stage request, read `references/skill_info.yaml` and resolve the run override from either an explicit `automl_policy` value or the user's workflow request. Use `automl_policy: on` by default and only expose `on` / `off` in new launch prompts. Treat phrases like "turn off AutoML", "disable AutoML", "no HPO", or "plain training" as `automl_policy: off` for this run only. When `automl_policy: on`, `automl_enabled: true`, and both `schemas/train.schema.json` and `references/spec_template_train.yaml` are packaged, route the train action through `tao-skill-bank:tao-run-automl` by default with this model's `skill_dir`. Preserve workflow/application overrides for datasets, specs, output directories, GPU/platform settings, parent checkpoints, and `automl_policy`. Use direct model training only when `automl_policy: off` 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.
Non-train actions such as `evaluate`, `inference`, `export`, and deploy flows stay in this model skill. The per-run `automl_policy` override does not change model metadata.
## Training Requirements
- **Dataset type:** object_detection
- **Formats:** odvg, coco, raw
- **Monitoring metric:** val_mAP50
### Per-Action Dataset Requirements
| Action | Spec Key | Source | Files | List? |
|---|---|---|---|---|
| evaluate | dataset.test_data_sources | eval_dataset | image_dir: images.tar.gz, json_file: annotations.json | No |
| inference | dataset.infer_data_sources.image_dir | inference_dataset | images.tar.gz | Yes |
| inference | dataset.infer_data_sources.captions | workflow prompts | prompt list | Yes |
| quantize | dataset.train_data_sources | train_datasets | image_dir: images.tar.gz, json_file: annotations_odvg.jsonl, label_map: annotations_odvg_labelmap.json | Yes |
| quantize | dataset.val_data_sources | eval_dataset | image_dir: images.tar.gz, json_file: annotations.json | No |
| quantize | dataset.quant_calibration_data_sources | calibration/eval dataset | image_dir: images.tar.gz, json_file: annotations.json | No |
| train | dataset.train_data_sources | train_datasets | image_dir: images.tar.gz, json_file: annotations_odvg.jsonl, label_map: annotations_odvg_labelmap.json | Yes |
| train | dataset.val_data_sources | eval_dataset | image_dir: images.tar.gz, json_file: annotations.json | No |
The runner may source image archives as `images.tar.gz`, but direct local
Docker TAO CLI specs must point `image_dir` to an extracted image directory.
Skill metadata marks these archive-backed image sources with
`runtime: extracted_folder` so a fresh runner can unpack the archive before
launching TAO.
### Typical Spec Overrides
Data source overrides are **mandatory for every action** — the agent MUST construct data source paths from the Per-Action Dataset Requirements table above and include them in `spec_overrides`.
```python
S3_TRAIN = "s3://bucket/data/train"
S3_EVAL = "s3://bucket/data/eval"
```
**train (mandatory data sources):**
```python
{
"train.num_epochs": 10,
"train.checkpoint_interval": 10,
"train.validation_interval": 10,
"train.num_gpus": 1,
"dataset.train_data_sources": [{"image_dir": f"{S3_TRAIN}/images.tar.gz", "json_file": f"{S3_TRAIN}/annotations_odvg.jsonl", "label_map": f"{S3_TRAIN}/annotations_odvg_labelmap.json"}],
"dataset.val_data_sources": {"image_dir": f"{S3_EVAL}/images.tar.gz", "json_file": f"{S3_EVAL}/annotations.json"},
}
```
**deploy/gen_trt_engine (use `references/tao-deploy-grounding-dino.md`):**
```python
{
"gen_trt_engine.onnx_file": "<exported_onnx_uri>",
"gen_trt_engine.trt_engine": "<output_engine_path>",
"gen_trt_engine.tensorrt.data_type": "FP16",
}
```
**inference (mandatory data sources):**
```python
{
"inference.checkpoint": "<selected train/AutoML checkpoint>",
"dataset.infer_data_sources.image_dir": [f"{S3_EVAL}/images.tar.gz"],
"dataset.infer_data_sources.captions": [
"fire extinguisher",
"cone",
"cart",
"forklift"
],
}
```
**evaluate (mandatory data sources):**
```python
{
"evaluate.checkpoint": "<selected train/AutoML checkpoint>",
"dataset.test_data_sources": {"image_dir": f"{S3_EVAL}/images.tar.gz", "json_file": f"{S3_EVAL}/annotations.json"},
}
```
**quantize (mandatory data sources):**
```python
{
"quantize.model_path": "<selected train checkpoint or exported ONNX model>",
"dataset.train_data_sources": [{"image_dir": f"{S3_TRAIN}/images.tar.gz", "json_file": f"{S3_TRAIN}/annotations_odvg.jsonl", "label_map": f"{S3_TRAIN}/annotations_odvg_labelmap.json"}],
"dataset.val_data_sources": {"image_dir": f"{S3_EVAL}/images.tar.gz", "json_file": f"{S3_EVAL}/annotations.json"},
"dataset.quant_calibration_data_sources": {"image_dir": f"{S3_EVAL}/images.tar.gz", "json_file": f"{S3_EVAL}/annotations.json"},
}
```
## Eval Dataset
Optional. Validation uses COCO-format annotations for mAP even though training can use ODVG format.
## Important Parameters
- **model.backbone**: Default swin_tiny_224_1k. Also supports resnet_50 and other Swin variants. Swin generally performs better for grounding tasks.
- **model.text_encoder_type**: BERT model for text encoding. Default bert-base-uncased. max_text_len defaults to 256.
- **model.max_text_len**: Keep this aligned with the dataset label/token
position maps. Do not shrink it for smoke tests unless the corresponding
label maps are regenerated with the same length; otherwise validation can
fail with a matrix shape mismatch between token probabilities and position
maps.
- **train.optim.lr**: Learning rate. Default 2e-4. lr_backbone 2e-5. Supports bf16 precision in addition to fp16/fp32.
- **dataset.max_labels**: Maximum labels per image during training. Default 50. Increase for dense annotation datasets.
- **model.num_queries**: Object queries. Default 900 (higher than DINO's 300) due to open-vocabulary nature.
- **model.num_queries / model.num_select**: Keep `num_queries` high enough
for the number of matched ODVG targets in a batch. Very small smoke values
such as 20 can fail during Hungarian target indexing on dense images; use at
least 100 for minimal Grounding DINO smoke runs unless the dataset is known
to have fewer objects per image.
- **train.optim.lr_steps**: MultiStep LR schedule. Default [10].
## Multi-GPU / Multi-Node
**Launch method:** Lightning-managed (single `python` process, Lightning spawns workers).
| Spec Key | Description | Default |
|----------|-------------|---------|
| `train.num_gpus` | Number of GPUs | 1 |
| `train.gpu_ids` | GPU device indices | [0] |
| `train.num_nodes` | Number of nodes | 1 |
| `train.distributed_strategy` | `ddp` or `fsdp` | `ddp` |
Same DDP/FSDP behavior as DINO. Multi-node requires `WORLD_SIZE`, `NODE_RANK`, `MASTER_ADDR`, `MASTER_PORT` env vars set by orchestrator.
## Export / TRT Defaults
- Export input: 960x544 (larger than other OD models), opset 17. Keep
Grounding-DINO export specs at the template export resolution for smoke tests;
reducing export to very small image sizes such as 128x128 can trigger a
PyTorch ONNX shape-inference assertion in the contrastive text head during
`torch.onnx.export`.
- The parent PyTorch `grounding_dino` CLI supports `train`, `evaluate`,
`inference`, `export`, and `quantize`. Run TensorRT engine generation,
TensorRT inference, and TensorRT evaluation through `references/tao-deploy-grounding-dino.md`.
- TRT data types: FP32, FP16 only — **INT8 is NOT supported**
- TRT workspace: 8192 MB (8x larger than other OD models)
- TRT max_batch_size: 4
## Hardware
Minimum 1 GPU(s), recommended 4 GPU(s). 24GB+ (A100 recommended) VRAM per GPU. Grounding DINO is heavier than standard DINO due to the text encoder (BERT). 24GB+ GPU memory recommended. Reduce batch_size for 16GB GPUs.
## Error Patterns
**CUDA out of memory**: Reduce batch_size (4 -> 2 -> 1). The BERT text encoder adds significant memory overhead on top of the vision backbone.
**Val annotation category IDs**: Validation annotations should have category IDs starting from 0 for correct loss computation. Use annotation format conversion if needed.
**Text encoder loading error**: Ensure the container has access to download bert-base-uncased weights or provide a local path.
**Quantize with a PyTorch checkpoint fails in TAO Toolkit 7.0.0-rc-226**:
The container's Grounding-DINO quantize script passes `cap_lists=None` when
loading a checkpoint, which fails in `post_process.py`. ONNX quantization uses
the exported ONNX artifact and COCO calibration data, but the default rc-226
PyTorch image also lacks the `modelopt.onnx.quantization` module. Treat this as
an image/SDK blocker, not a checkpoint resolver issue.
**mat1 and mat2 shapes cannot be multiplied in `post_process.py`**: The text
token length and label position maps are inconsistent, commonly because
`model.max_text_len` was overridden below the default 256 while the dataset
label maps still use 256-length position maps. Restore `model.max_text_len` or
regenerate the label maps with the same length.
**index is out of bounds for dimension 0 in `criterion.py`**: `model.num_queries`
is too small for the matched ODVG targets in the current batch. Increase
`model.num_queries` and keep `model.num_select` compatible with it.
**NotADirectoryError with `images.tar.gz/<image>.jpg`**: The direct TAO CLI is
trying to traverse an archive path as a directory. Extract the archive and set
the relevant `image_dir` field to the extracted image folder; archive-backed
skill data sources use `runtime: extracted_folder` for this reason.
## Spec Param / Parent Model Inference
Model-specific inference mappings belong in this MD file, not in `config.json`. Generated runners should read this section and apply the mappings with SDK helpers before `create_job()`. This mirrors the old microservices `infer_params.py` flow.
Inference mappings from TAO Core `grounding_dino.config.json`:
| Action | Spec Field | Inference Function | Meaning |
|---|---|---|---|
| evaluate | `encryption_key` | `key` | encryption key |
| evaluate | `evaluate.checkpoint` | `parent_model` | model file inferred from the parent job results folder |
| evaluate | `evaluate.trt_engine` | `parent_model` | model file inferred from the parent job results folder |
| evaluate | `results_dir` | `output_dir` | current job results directory |
| export | `encryption_key` | `key` | encryption key |
| export | `export.checkpoint` | `parent_model` | model file inferred from the parent job results folder |
| export | `export.onnx_file` | `create_onnx_file` | output ONNX path |
| export | `results_dir` | `output_dir` | current job results directory |
| inference | `encryption_key` | `key` | encryption key |
| inference | `inference.checkpoint` | `parent_model` | model file inferred from the parent job results folder |
| inference | `inference.trt_engine` | `parent_model` | model file inferred from the parent job results folder |
| inference | `results_dir` | `output_dir` | current job results directory |
| quantize | `encryption_key` | `key` | encryption key |
| quantize | `quantize.model_path` | `parent_model` | model file inferred from the parent job results folder |
| quantize | `results_dir` | `output_dir` | current job results directory |
| train | `encryption_key` | `key` | encryption key |
| train | `model.pretrained_backbone_path` | `ptm_if_no_resume_model` | PTM when no resume checkpoint exists |
| train | `results_dir` | `output_dir` | current job results directory |
| train | `train.pretrained_model_path` | `ptm_if_no_resume_model` | PTM when no resume checkpoint exists |
| train | `train.resume_training_checkpoint_path` | `resume_model` | model file inferred from the current job results folder |
For `parent_model` or `parent_model_folder`, pass the upstream train/export/AutoML child job id as `parent_job_id`. 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 `config.json` and do not patch generated runner scripts to guess checkpoint paths.
When selecting a Grounding-DINO checkpoint outside the SDK resolver, match the
intended epoch/step artifact exactly, for example
`model_epoch_000_step_00046.pth`. The `gdino_model_latest.pth` symlink is valid
only when latest is explicitly requested. Carry structural model settings such
as `model.backbone`, `model.num_queries`, `model.num_select`,
`model.num_feature_levels`, `model.max_text_len`, and export input resolution
forward into evaluate, inference, export, and deploy specs so checkpoint and
engine shapes match.
## Deployment
- [tao-deploy-grounding-dino](references/tao-deploy-grounding-dino.md)
所有檔案
24 個檔案安裝 tao-train-grounding-dino
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/NVIDIA/skills/tree/main/skills/tao-train-grounding-dino # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
