TVP-Training-Data / README.md
yunfengwang's picture
Upload README.md with huggingface_hub
0f5ee57 verified
metadata
license: mit
task_categories:
  - object-detection
  - visual-question-answering
language:
  - en
tags:
  - visual-reasoning
  - grounding
  - counting
  - spatial-reasoning
  - maze
  - path-tracing
  - visual-primitives
  - chain-of-thought
size_categories:
  - 100K<n<1M
configs:
  - config_name: default
    data_files:
      - split: pretrain
        path: pretrain/*.jsonl
      - split: sft_grounding
        path: sft/grounding/*.jsonl
      - split: sft_counting
        path: sft/counting/*.jsonl
      - split: sft_spatial
        path: sft/spatial/*.jsonl
      - split: sft_maze
        path: sft/maze/*.jsonl
      - split: sft_path
        path: sft/path/*.jsonl

TVP Training Data — Thinking with Visual Primitives

Training data for the Thinking with Visual Primitives PyTorch implementation.

Overview

This dataset contains all training data for the multi-stage TVP pipeline:

Split File Samples Description
Pretrain pretrain/grounding.jsonl 146K COCO-based grounding (label + bbox)
SFT sft/grounding/sft_grounding.jsonl 30K Grounding with structured thinking + negatives (15%)
SFT sft/counting/counting_data.jsonl 8K Counting with bbox grounding in CoT
SFT sft/spatial/spatial_data.jsonl 3K CLEVR-style spatial reasoning
SFT sft/maze/maze_data.jsonl 5K Procedural maze navigation (point primitives)
SFT sft/path/path_data.jsonl 3K Path tracing (point sequences)

Data Format

All files are JSONL. Coordinates are normalized integers in [0, 999].

Pretrain Grounding

{
  "image": "images/000000000009.jpg",
  "label": "person",
  "boxes": [[480, 201, 720, 850]],
  "points": [],
  "normalized": true
}

SFT Grounding (with structured thinking)

{
  "image": "images/000000000009.jpg",
  "question": "Locate the person in the image.",
  "thinking": "1. **Analyzing the request**\nThe user asks me to locate the person in this image.\n2. **Object grounding**\nI see a <|ref|>person<|/ref|><|box|>[[480,201,720,850]]<|/box|>.\n3. **Conclusion**\nThe person is located at the specified coordinates.",
  "answer": "The person is located at [[480,201,720,850]].",
  "boxes": [[480, 201, 720, 850]],
  "points": []
}

SFT Counting

{
  "image": "images/000000000025.jpg",
  "question": "How many people are in this image?",
  "thinking": "1. **Analyzing the request**\nThe user asks me to count the person in this image.\n2. **Object grounding**\nI see 2 instance(s) of <|ref|>person<|/ref|><|box|>[[338,121,630,923],[634,154,888,945]]<|/box|>.\n3. **Conclusion**\nThere are 2 person in this image.",
  "count": 2,
  "boxes": [[338, 121, 630, 923], [634, 154, 888, 945]]
}

Maze / Path (point primitives)

{
  "image": "images/maze_00001.png",
  "question": "Navigate from start to end in this maze.",
  "thinking": "... DFS exploration with <|point|>[[x,y]]<|/point|> waypoints ...",
  "answer": "...",
  "points": [[100, 200], [150, 250], [200, 300]]
}

Visual Primitives

# Bounding box
<|ref|>cat<|/ref|><|box|>[[x1,y1,x2,y2]]<|/box|>

# Multiple boxes
<|ref|>person<|/ref|><|box|>[[130,50,400,800],[500,60,750,790]]<|/box|>

# Point sequence
<|point|>[[100,200],[150,250],[200,300]]<|/point|>

Generation Scripts

The scripts/ folder contains all data generation code:

Script Purpose
prepare_all_data.py One-command pipeline (downloads COCO + generates all data)
generate_sft_grounding_data.py Grounding with negatives + diverse prompt templates
generate_maze_data.py Procedural maze generation with DFS solutions
generate_path_data.py Path tracing data generation

Regenerate from scratch

# Full pipeline (downloads COCO 2017 val ~1GB)
python scripts/prepare_all_data.py \
    --output_dir data --coco_split val --coco_subset 5000

# Generate grounding with negatives
python scripts/generate_sft_grounding_data.py \
    --coco_jsonl data/pretrain/grounding.jsonl \
    --image_root data/coco/val \
    --output data/sft/grounding/sft_grounding.jsonl \
    --neg_ratio 0.15 --max_samples 30000

Source Images

The JSONL files reference COCO 2017 images. Download them separately:

For maze/spatial/path tasks, images are procedurally generated by the scripts.

Related

Citation

@software{wang2026tvp_pytorch,
  title={Thinking with Visual Primitives — PyTorch Implementation},
  author={Wang, Weishan},
  url={https://github.com/vra/Thinking-with-Visual-Primitives-pytorch},
  year={2026}
}

License

MIT