File size: 5,036 Bytes
44733f7
 
 
782ef5f
 
 
 
 
 
0c37edd
782ef5f
 
44733f7
782ef5f
44733f7
 
 
 
 
 
 
782ef5f
 
 
 
44733f7
 
 
782ef5f
 
 
 
 
 
44733f7
 
782ef5f
44733f7
782ef5f
 
44733f7
782ef5f
 
 
 
 
44733f7
 
 
 
 
 
a1b6268
f2017c7
44733f7
 
 
 
 
 
 
 
 
 
782ef5f
 
 
 
 
 
 
 
 
44733f7
 
782ef5f
 
 
44733f7
782ef5f
 
 
44733f7
782ef5f
 
0c37edd
44733f7
782ef5f
 
 
44733f7
 
782ef5f
44733f7
 
 
 
 
 
 
 
 
 
 
 
 
 
a1b6268
f2017c7
44733f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"""
Dataset script for VLM Plant Sim - enables proper JSONL loading with explicit schema definition.
This prevents HF's auto-inference from failing on complex multi-valued fields.
"""

import json
from typing import Generator

import datasets
from datasets import Features, SplitGenerator, Value, DatasetInfo


# Dataset configuration
_CITATION = """\
@misc{yun2026usingvisionlanguagefoundation,
      title={Using Vision Language Foundation Models to Generate Plant Simulation Configurations via In-Context Learning},
      author={Heesup Yun and Isaac Kazuo Uyehara and Earl Ranario and Lars Lundqvist and Christine H. Diepenbrock and Brian N. Bailey and J. Mason Earles},
      year={2026},
      eprint={2603.08930},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
}
"""

_DESCRIPTION = """\
VLM Plant Sim is a multi-source plant and crop image dataset combining HELIOS synthetic renders,
real drone orthophoto patches, and annotated field data for evaluating Vision Language Models
in generating plant simulation configurations.
"""

_HOMEPAGE = "https://huggingface.co/datasets/heesup/vlm-plant-sim"
_LICENSE = "apache-2.0"


class VlmPlantSimDataset(datasets.GeneratorBasedBuilder):
    """HF Dataset builder for VLM Plant Sim."""

    VERSION = datasets.Version("1.0.0")

    BUILDER_CONFIGS = [
        datasets.BuilderConfig(name="default", version=VERSION, description="Default config"),
    ]

    DEFAULT_CONFIG_NAME = "default"

    def _info(self) -> DatasetInfo:
        """Define the dataset schema explicitly."""
        features = Features({
            "id": Value("string"),
            "split": Value("string"),
            "source": Value("string"),
            "dap": Value("int32"),
            "bed": Value("int32"),
            "tier": Value("int32"),
            "image_path": Value("string"),
            "annotation_path": Value("string"),
            "scene_json_path": Value("string"),
            "camera_json_path": Value("string"),
            "params_json_path": Value("string"),
            "classes_txt_path": Value("string"),
            "boxes_txt_path": Value("string"),
            "masks_json_path": Value("string"),
            "notes": Value("string"),
        })

        return DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        """Define the splits."""
        return [
            SplitGenerator(
                name="synthetic",
                gen_kwargs={"manifest_file": "manifests/synthetic.jsonl"},
            ),
            SplitGenerator(
                name="real",
                gen_kwargs={"manifest_file": "manifests/real.jsonl"},
            ),
            SplitGenerator(
                name="real_dap10_boxes",
                gen_kwargs={"manifest_file": "manifests/initial_plant.jsonl"},
            ),
        ]

    def _generate_examples(self, manifest_file: str) -> Generator:
        """Generate examples from JSONL manifest file."""
        idx = 0
        try:
            with open(manifest_file, "r", encoding="utf-8") as f:
                for line in f:
                    line = line.strip()
                    if not line:
                        continue
                    try:
                        record = json.loads(line)
                        # Ensure all expected fields are present
                        example = {
                            "id": record.get("id", ""),
                            "split": record.get("split", ""),
                            "source": record.get("source", ""),
                            "dap": int(record.get("dap", 0)),
                            "bed": int(record.get("bed", record.get("tier", record.get("location", 0)))),
                            "tier": int(record.get("tier", record.get("bed", record.get("location", 0)))),
                            "image_path": record.get("image_path", ""),
                            "annotation_path": record.get("annotation_path", ""),
                            "scene_json_path": record.get("scene_json_path", ""),
                            "camera_json_path": record.get("camera_json_path", ""),
                            "params_json_path": record.get("params_json_path", ""),
                            "classes_txt_path": record.get("classes_txt_path", ""),
                            "boxes_txt_path": record.get("boxes_txt_path", ""),
                            "masks_json_path": record.get("masks_json_path", ""),
                            "notes": record.get("notes", ""),
                        }
                        yield idx, example
                        idx += 1
                    except (json.JSONDecodeError, ValueError) as e:
                        # Skip invalid lines
                        continue
        except FileNotFoundError:
            # File not found - return empty result
            pass