Datasets:
Download vlm_plant_sim.py from heesup/vlm-plant-sim: direct link, hf CLI and curl.
- Browser
- Download file 5.04 kB
-
https://huggingface.co/datasets/heesup/vlm-plant-sim/resolve/main/vlm_plant_sim.py
- Command line
-
hf download hf://datasets/heesup/vlm-plant-sim/vlm_plant_sim.py
-
curl -L -o vlm_plant_sim.py https://huggingface.co/datasets/heesup/vlm-plant-sim/resolve/main/vlm_plant_sim.py
5.04 kB
| """ | |
| 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 | |