Delete RefRef_dataset.py
Browse files- RefRef_dataset.py +0 -105
RefRef_dataset.py
DELETED
|
@@ -1,105 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
import os
|
| 3 |
-
import datasets
|
| 4 |
-
|
| 5 |
-
_CITATION = """\
|
| 6 |
-
@InProceedings{...},
|
| 7 |
-
title = {Your Dataset Title},
|
| 8 |
-
author={Your Name},
|
| 9 |
-
year={2025}
|
| 10 |
-
}
|
| 11 |
-
"""
|
| 12 |
-
|
| 13 |
-
_DESCRIPTION = """\
|
| 14 |
-
Dataset containing multi-view images with camera poses, depth maps, and masks for NeRF training.
|
| 15 |
-
"""
|
| 16 |
-
|
| 17 |
-
_LICENSE = "MIT"
|
| 18 |
-
|
| 19 |
-
class RefRefConfig(datasets.BuilderConfig):
|
| 20 |
-
"""BuilderConfig for RefRef dataset."""
|
| 21 |
-
|
| 22 |
-
def __init__(self, scene=None, **kwargs):
|
| 23 |
-
"""BuilderConfig for RefRef dataset.
|
| 24 |
-
|
| 25 |
-
Args:
|
| 26 |
-
**kwargs: keyword arguments forwarded to super.
|
| 27 |
-
"""
|
| 28 |
-
super().__init__(**kwargs)
|
| 29 |
-
self.scene = scene
|
| 30 |
-
|
| 31 |
-
class RefRef(datasets.GeneratorBasedBuilder):
|
| 32 |
-
"""A dataset loader for NeRF-style data with camera poses, depth maps, and masks."""
|
| 33 |
-
|
| 34 |
-
VERSION = datasets.Version("1.0.0")
|
| 35 |
-
BUILDER_CONFIG_CLASS = RefRefConfig
|
| 36 |
-
BUILDER_CONFIGS = [
|
| 37 |
-
RefRefConfig(
|
| 38 |
-
name="single-non-convex",
|
| 39 |
-
description="Single non-convex scene configuration for RefRef dataset.",
|
| 40 |
-
),
|
| 41 |
-
RefRefConfig(
|
| 42 |
-
name="multiple-non-convex",
|
| 43 |
-
description="Multiple non-convex scene configuration for RefRef dataset.",
|
| 44 |
-
),
|
| 45 |
-
RefRefConfig(
|
| 46 |
-
name="single-convex",
|
| 47 |
-
description="Single convex scene configuration for RefRef dataset.",
|
| 48 |
-
)
|
| 49 |
-
]
|
| 50 |
-
|
| 51 |
-
def _info(self):
|
| 52 |
-
features = datasets.Features({
|
| 53 |
-
"image": datasets.Image(),
|
| 54 |
-
"depth": datasets.Image(),
|
| 55 |
-
"mask": datasets.Image(),
|
| 56 |
-
"transform_matrix": datasets.Sequence(
|
| 57 |
-
datasets.Sequence(datasets.Value("float64"), length=4),
|
| 58 |
-
length=4
|
| 59 |
-
),
|
| 60 |
-
"rotation": datasets.Value("float32")
|
| 61 |
-
})
|
| 62 |
-
|
| 63 |
-
return datasets.DatasetInfo(
|
| 64 |
-
description=_DESCRIPTION,
|
| 65 |
-
features=features,
|
| 66 |
-
homepage="",
|
| 67 |
-
license=_LICENSE,
|
| 68 |
-
citation=_CITATION
|
| 69 |
-
)
|
| 70 |
-
|
| 71 |
-
def _split_generators(self, dl_manager):
|
| 72 |
-
# Automatically find all JSON files matching the split patterns
|
| 73 |
-
return [
|
| 74 |
-
datasets.SplitGenerator(
|
| 75 |
-
name=f"{'cube' if cat == 'textured_cube_scene' else 'sphere' if cat == 'textured_sphere_scene' else 'env'}_{'smcvx' if self.config.name == 'single-convex' else 'smncvx' if self.config.name == 'single-non-convex' else 'mmncvx'}_{self.config.scene}",
|
| 76 |
-
gen_kwargs={
|
| 77 |
-
"filepaths": os.path.join(f"https://huggingface.co/datasets/yinyue27/RefRef_dataset/resolve/main/image_data/{cat}/{self.config.name}/",
|
| 78 |
-
f"{self.config.scene}_sphere" if cat == "textured_sphere_scene" else f"{self.config.scene}_hdr" if cat == "environment_map_scene" else self.config.scene),
|
| 79 |
-
"split": f"{'cube' if cat == 'textured_cube_scene' else 'sphere' if cat == 'textured_sphere_scene' else 'env'}_{'smcvx' if self.config.name == 'single-convex' else 'smncvx' if self.config.name == 'single-non-convex' else 'mmncvx'}_{self.config.scene}",
|
| 80 |
-
},
|
| 81 |
-
) for cat in ["textured_sphere_scene", "textured_cube_scene", "environment_map_scene"]
|
| 82 |
-
]
|
| 83 |
-
|
| 84 |
-
def _generate_examples(self, filepaths, split):
|
| 85 |
-
for split in ["train", "val", "test"]:
|
| 86 |
-
split_filepaths = os.path.join(filepaths, f"transforms_{split}.json")
|
| 87 |
-
with open(split_filepaths, "r", encoding="utf-8") as f:
|
| 88 |
-
try:
|
| 89 |
-
data = json.load(f)
|
| 90 |
-
except json.JSONDecodeError:
|
| 91 |
-
print("Error opening " + split_filepaths)
|
| 92 |
-
continue
|
| 93 |
-
|
| 94 |
-
scene_name = os.path.basename(os.path.dirname(split_filepaths))
|
| 95 |
-
|
| 96 |
-
for frame_idx, frame in enumerate(data.get("frames", [])):
|
| 97 |
-
base_dir = os.path.dirname(split_filepaths)
|
| 98 |
-
|
| 99 |
-
yield f"{scene_name}_{frame_idx}", {
|
| 100 |
-
"image": os.path.join(base_dir, frame["file_path"]+".png"),
|
| 101 |
-
"depth": os.path.join(base_dir, frame["depth_file_path"]),
|
| 102 |
-
"mask": os.path.join(base_dir, frame["mask_file_path"]),
|
| 103 |
-
"transform_matrix": frame["transform_matrix"],
|
| 104 |
-
"rotation": frame.get("rotation", 0.0)
|
| 105 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|