tao-generate-referring-expressions
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImage Referring Expression Pipeline
图像指代表达流水线
Generate referring-expression and grounding annotations from images with KITTI-format bounding box labels. A single VLM (Gemini or any OpenAI-compatible endpoint) runs four steps: per-object region descriptions, holistic image captions, grouped grounding expressions tied to bboxes, and an optional double-check verification pass.
从带有KITTI格式边界框标签的图像生成指代表达与grounding标注。单个VLM(Gemini或任何兼容OpenAI的端点)执行四个步骤:逐对象区域描述、整体图像标题、与边界框关联的分组grounding表达,以及可选的双重校验步骤。
Purpose
用途
Transform pairs into a unified containing rich, grounded referring expressions. The VLM acts as a "teacher" annotator: Steps 0-1 see the image; Step 2 groups Step 0 outputs into grouping phrases with bbox lists; Step 3 (optional) re-examines those bboxes against the image and corrects mismatches.
(image, KITTI labels)annotations.jsonl将对转换为包含丰富grounded指代表达的统一文件。VLM充当「教师」标注器:步骤0-1读取图像;步骤2将步骤0的输出分组为带有边界框列表的分组短语;步骤3(可选)对照图像重新检查这些边界框并纠正不匹配项。
(图像, KITTI标签)annotations.jsonlPipeline Architecture
流水线架构
Step 0: Region expression ──┐
├──▶ Step 2: Grounding expression ──▶ [Step 3: Double check]
Step 1: Image caption ──────┘ (optional)- Step 0 (region_expr) — VLM emits one short discriminative phrase per KITTI bbox (,
bbox_2d,type,color).description - Step 1 (image_caption) — VLM emits a holistic, location-agnostic scene caption.
- Step 2 (grounding_expr) — VLM groups Step 0 objects into grouping phrases and returns one bbox list per group, optionally using Step 1's caption as extra context.
- Step 3 (double_check) — VLM re-checks each Step 2 bbox against the image; bad matches are removed, slightly-off boxes get tightened.
Steps 0 and 1 run in parallel within a single thread pool (they only depend on the seed records). Each step writes its own and skips already-processed images on re-run unless .
step_<N>_*/annotations.jsonlworkflow.force_reprocess: trueStep 0: Region expression ──┐
├──▶ Step 2: Grounding expression ──▶ [Step 3: Double check]
Step 1: Image caption ──────┘ (optional)- Step 0 (region_expr) — VLM为每个KITTI边界框生成一个简短的区分性短语(包含、
bbox_2d、type、color)。description - Step 1 (image_caption) — VLM生成一个整体的、与位置无关的场景标题。
- Step 2 (grounding_expr) — VLM将步骤0中的对象分组为分组短语,并为每个组返回一个边界框列表,可选择使用步骤1的标题作为额外上下文。
- Step 3 (double_check) — VLM对照图像重新检查步骤2中的每个边界框;移除匹配错误的框,微调位置略有偏差的框。
步骤0和1在单个线程池中并行运行(它们仅依赖于初始记录)。每个步骤都会生成自己的文件,重新运行时会跳过已处理的图像,除非设置。
step_<N>_*/annotations.jsonlworkflow.force_reprocess: trueInstructions
使用说明
Initial setup
初始设置
When a user wants to run this pipeline, walk through these steps:
-
Images: Ask for, the directory containing
data.image_dir,.jpg, or.jpegimages..png -
KITTI labels: Ask for, the directory containing one
data.kitti_label_dirlabel file per image. Each label line must use KITTI format:.txt. Lines with fewer than 8 fields are silently skipped. Set this even for Step 1-only runs because Steps 0 and 2 require it.<type> <truncated> <occluded> <alpha> <bbox_left> <bbox_top> <bbox_right> <bbox_bottom> ... -
Resume from existing annotations: If the user already has a unifiedfrom a previous run, set
annotations.jsonlto that file instead of seeding fromdata.input_annotations_jsonlanddata.image_dir.data.kitti_label_dir -
API access: Ask the user which VLM endpoint they want to use. Present these five options and act on the choice:
- Gemini — set ; require
vlm.backend: "gemini"(env var orGOOGLE_API_KEY).vlm.gemini.api_key - NIM (e.g. ) — set
https://inference-api.nvidia.com/v1; collectvlm.backend: "openai",base_url, andmodel_name.api_key - TAO inference microservice (self-hosted, OpenAI-compatible). Confirm whether the server is already running:
- Running — collect ,
base_url, and (optionally)model_name; setapi_key.vlm.backend: "openai" - Not running — guide the user through the skill, which stands up a local TAO inference microservice with an OpenAI-compatible API. Before promising a specific model, check
skills/applications/tao-run-inference-serviceforskills/applications/tao-run-inference-service/references/service.yaml. Once the server is up, collectvalid_network_arch_config_basenames,base_url, and (optionally)model_name; setapi_key.vlm.backend: "openai"
- Running — collect
- vLLM (self-hosted, OpenAI-compatible). Confirm whether the server is already running:
- Running — collect ,
base_url, and (optionally)model_name; setapi_key.vlm.backend: "openai" - Not running — follow references/vllm_server.md to install and launch a vLLM server, then collect ,
base_url, and (optionally)model_name; setapi_key.vlm.backend: "openai"
- Running — collect
- Custom (any other OpenAI-compatible endpoint) — set ; collect
vlm.backend: "openai",base_url, and (optionally)model_name.api_key
If the user has no endpoint and does not want to set one up, stop and help resolve API access first. - Gemini — set
-
Workflow steps: Choose one of:
- Full pipeline:
["0", "1", "2", "3"] - No caption generation: , where Step 2 falls back to image-only context
["0", "2", "3"] - No verification:
["0", "1", "2"] - Custom subset: any supported subset of steps
- Full pipeline:
-
Output format: Choose one of:
- : unified schema only
jsonl - : byte-compatible
legacyfiles only.txt.stepN - : writes both formats and is the default for downstream tooling
both
当用户想要运行此流水线时,请按以下步骤操作:
-
图像:询问用户,即包含
data.image_dir、.jpg或.jpeg格式图像的目录。.png -
KITTI标签:询问用户,即包含每个图像对应
data.kitti_label_dir标签文件的目录。每个标签行必须采用KITTI格式:.txt。字段少于8个的行将被自动跳过。即使仅运行步骤1也需设置此参数,因为步骤0和2需要它。<type> <truncated> <occluded> <alpha> <bbox_left> <bbox_top> <bbox_right> <bbox_bottom> ... -
从现有标注恢复:如果用户已有之前运行生成的统一文件,请将
annotations.jsonl设置为该文件,而非从data.input_annotations_jsonl和data.image_dir初始化。data.kitti_label_dir -
API访问:询问用户想要使用哪个VLM端点。提供以下五个选项并根据选择执行操作:
- Gemini — 设置;需要
vlm.backend: "gemini"(环境变量或GOOGLE_API_KEY)。vlm.gemini.api_key - NIM(例如) — 设置
https://inference-api.nvidia.com/v1;收集vlm.backend: "openai"、base_url和model_name。api_key - TAO推理微服务(自托管,兼容OpenAI)。确认服务器是否已运行:
- 已运行 — 收集、
base_url和(可选)model_name;设置api_key。vlm.backend: "openai" - 未运行 — 引导用户使用技能,该技能会启动一个带有兼容OpenAI API的本地TAO推理微服务。在承诺特定模型之前,请查看
skills/applications/tao-run-inference-service中的skills/applications/tao-run-inference-service/references/service.yaml。服务器启动后,收集valid_network_arch_config_basenames、base_url和(可选)model_name;设置api_key。vlm.backend: "openai"
- 已运行 — 收集
- vLLM(自托管,兼容OpenAI)。确认服务器是否已运行:
- 已运行 — 收集、
base_url和(可选)model_name;设置api_key。vlm.backend: "openai" - 未运行 — 按照references/vllm_server.md中的说明安装并启动vLLM服务器,然后收集、
base_url和(可选)model_name;设置api_key。vlm.backend: "openai"
- 已运行 — 收集
- 自定义(任何其他兼容OpenAI的端点) — 设置;收集
vlm.backend: "openai"、base_url和(可选)model_name。api_key
如果用户没有端点且不想设置,请先帮助解决API访问问题。 - Gemini — 设置
-
工作流步骤:选择以下选项之一:
- 完整流水线:
["0", "1", "2", "3"] - 不生成标题:,此时步骤2将回退到仅图像上下文
["0", "2", "3"] - 不进行校验:
["0", "1", "2"] - 自定义子集:任何受支持的步骤子集
- 完整流水线:
-
输出格式:选择以下选项之一:
- :仅统一格式
jsonl - :仅字节兼容的
legacy文件.txt.stepN - :同时写入两种格式,是下游工具的默认选项
both
Running the pipeline
运行流水线
The pipeline runs inside the TAO Toolkit container via the CLI:
auto_labelbash
auto_label generate -e /path/to/spec.yaml \
results_dir=/results \
image_referring_expression.data.image_dir=/data/images \
image_referring_expression.data.kitti_label_dir=/data/labels \
image_referring_expression.vlm.gemini.api_key=$GOOGLE_API_KEYGenerate a default spec: , then set . All fields support Hydra dot-notation overrides on the command line.
auto_label default_specs results_dir=/results module_name=auto_labelautolabel_type: "image_referring_expression"See references/configuration.md for the full YAML structure, all parameters, model/endpoint setup, and error patterns.
流水线在TAO Toolkit容器内通过 CLI运行:
auto_labelbash
auto_label generate -e /path/to/spec.yaml \
results_dir=/results \
image_referring_expression.data.image_dir=/data/images \
image_referring_expression.data.kitti_label_dir=/data/labels \
image_referring_expression.vlm.gemini.api_key=$GOOGLE_API_KEY生成默认配置:,然后设置。所有字段都支持在命令行使用Hydra点符号进行覆盖。
auto_label default_specs results_dir=/results module_name=auto_labelautolabel_type: "image_referring_expression"有关完整YAML结构、所有参数、模型/端点设置和错误模式,请参阅references/configuration.md。
Recommended pilot workflow
推荐试点工作流
- Run on 5-10 images with all four steps.
- Inspect — are object types, colors, and discriminating phrases accurate?
step_0_region_expr/annotations.jsonl - Inspect — are objects grouped sensibly, and do bbox coordinates match the described groups?
step_2_grounding_expr/annotations.jsonl - Inspect — were mismatched bboxes removed or tightened? Are any new errors introduced (rare)?
step_3_double_check/annotations.jsonl - If quality is insufficient, switch the VLM to a stronger model (e.g. or a larger Qwen3-VL endpoint), raise
gemini-2.5-pro/media_resolution, then re-run withmax_output_tokens.workflow.force_reprocess=true - Scale to the full dataset once satisfied.
- 使用全部四个步骤在5-10张图像上运行。
- 检查— 对象类型、颜色和区分性短语是否准确?
step_0_region_expr/annotations.jsonl - 检查— 对象分组是否合理,边界框坐标是否与描述的组匹配?
step_2_grounding_expr/annotations.jsonl - 检查— 不匹配的边界框是否被移除或微调?是否引入了新的错误(很少见)?
step_3_double_check/annotations.jsonl - 如果质量不足,请将VLM切换为更强的模型(例如或更大的Qwen3-VL端点),提高
gemini-2.5-pro/media_resolution,然后设置max_output_tokens重新运行。workflow.force_reprocess=true - 满意后再扩展到完整数据集。
Configuration
配置
Key configuration fields (full reference in references/configuration.md):
| Field | Default | Description |
|---|---|---|
| | Which steps to execute ( |
| | Parallel threads per step (watch API rate limits) |
| | Ignore cached per-step outputs and reprocess from scratch |
| | |
| | |
| required | Directory of input images ( |
| required (unless resuming) | Directory of KITTI-format |
| | Optional pre-seeded |
关键配置字段(完整参考请见references/configuration.md):
| 字段 | 默认值 | 描述 |
|---|---|---|
| | 要执行的步骤( |
| | 每个步骤的并行线程数(注意API速率限制) |
| | 忽略缓存的步骤输出并从头开始重新处理 |
| | |
| | |
| 必填 | 输入图像目录( |
| 必填(除非从已有标注恢复) | KITTI格式 |
| | 可选的预初始化 |
Inputs
输入
Two ways to seed the pipeline:
- Image directory + KITTI labels (default). Set and
data.image_dir. The orchestrator walks the image directory, reads the matchingdata.kitti_label_dirKITTI file, parses bboxes (fields 0 + 4-7), reads each image's<stem>.txt/widthvia PIL, and writes aheighttoseed_annotations.jsonl.results_dir/ - Pre-seeded annotations JSONL (resume / pre-computed regions). Set to a file with one
data.input_annotations_jsonlobject per line.{"image_id", "image_path", "width", "height", "kitti_bboxes": [...]}
有两种方式初始化流水线:
- 图像目录 + KITTI标签(默认)。设置和
data.image_dir。编排器遍历图像目录,读取匹配的data.kitti_label_dirKITTI文件,解析边界框(字段0 + 4-7),通过PIL读取每个图像的<stem>.txt/width,并将height写入seed_annotations.jsonl。results_dir/ - 预初始化标注JSONL(恢复/预计算区域)。将设置为每行包含一个
data.input_annotations_jsonl对象的文件。{"image_id", "image_path", "width", "height", "kitti_bboxes": [...]}
Outputs
输出
All outputs go to :
results_dir/- — initial per-image records (unless
seed_annotations.jsonlwas supplied).input_annotations_jsonl - — adds
step_0_region_expr/annotations.jsonl(each withregions[]/bbox,bbox_2d,type,color).description - — adds
step_1_image_caption/annotations.jsonl(string).caption - — adds
step_2_grounding_expr/annotations.jsonl(eachexpressions[]).{text, instances: [{bbox: [x1,y1,x2,y2]}]} - — same shape as Step 2, with bboxes removed/updated.
step_3_double_check/annotations.jsonl - — copy of the last completed step's output.
results_dir/annotations.jsonl - When is
workflow.output_formator"legacy", each step also writes byte-compatible"both"files for the original 2d-data-engine tooling.step_<N>_*/labels/<stem>.txt.stepN
所有输出均保存到:
results_dir/- — 初始的逐图像记录(除非提供了
seed_annotations.jsonl)。input_annotations_jsonl - — 添加
step_0_region_expr/annotations.jsonl(每个包含regions[]/bbox、bbox_2d、type、color)。description - — 添加
step_1_image_caption/annotations.jsonl(字符串)。caption - — 添加
step_2_grounding_expr/annotations.jsonl(每个为expressions[])。{text, instances: [{bbox: [x1,y1,x2,y2]}]} - — 与步骤2结构相同,但边界框已被移除/更新。
step_3_double_check/annotations.jsonl - — 最后完成步骤输出的副本。
results_dir/annotations.jsonl - 当设置为
workflow.output_format或"legacy"时,每个步骤还会为原始2d-data-engine工具写入字节兼容的"both"文件。step_<N>_*/labels/<stem>.txt.stepN
Prerequisites
前置条件
- Container:
nvcr.io/nvidia/tao/tao-toolkit:6.26.3-pyt - API access: At least one VLM endpoint (Gemini API key or OpenAI-compatible endpoint capable of image input)
- PIL / Pillow: Required to read image dimensions during seeding (already present in the TAO container)
- 容器:
nvcr.io/nvidia/tao/tao-toolkit:6.26.3-pyt - API访问:至少一个VLM端点(Gemini API密钥或支持图像输入的兼容OpenAI端点)
- PIL / Pillow:初始化期间读取图像尺寸所需(已包含在TAO容器中)