alyelhakie commited on
Commit
1847f6a
·
verified ·
1 Parent(s): 12c9f2c

Add multi-config dataset loading script

Browse files
Files changed (1) hide show
  1. NGS.py +95 -0
NGS.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """NGS Transparency Datasets loading script"""
2
+
3
+ import datasets
4
+ from pathlib import Path
5
+ import os
6
+
7
+ _DESCRIPTION = "A collection of datasets (stones, objects, DTU, OmniObject3D) augmented with noise infills to benchmark 'false transparency' in 3DGS."
8
+ _HOMEPAGE = "https://huggingface.co/datasets/OpsiClear/NGS"
9
+ _LICENSE = "Mixed licenses. See dataset card for details."
10
+ _CITATION = """
11
+ @inproceedings{elhakie2025ngs,
12
+ title={Fix False Transparency by Noise Guided Splatting},
13
+ author={El Hakie, Aly and Lu, Yiren and Yin, Yu and Jenkins, Michael and Liu, Yehe},
14
+ booktitle={Conference on Neural Information Processing Systems (NeurIPS)},
15
+ year={2025}
16
+ }
17
+ """
18
+
19
+ class NGSDatasetConfig(datasets.BuilderConfig):
20
+ """BuilderConfig for the NGS Transparency Datasets."""
21
+ def __init__(self, **kwargs):
22
+ super().__init__(**kwargs)
23
+
24
+ class NGSDatasets(datasets.GeneratorBasedBuilder):
25
+ """NGS Transparency Datasets Loader"""
26
+
27
+ VERSION = datasets.Version("1.0.0")
28
+
29
+ BUILDER_CONFIGS = [
30
+ NGSDatasetConfig(name="stones", description="High-resolution scans of stone specimens."),
31
+ NGSDatasetConfig(name="objects", description="Scans of various everyday objects."),
32
+ NGSDatasetConfig(name="dtu", description="Augmented subset of the DTU dataset."),
33
+ NGSDatasetConfig(name="omniobject3d", description="Augmented subset of the OmniObject3D dataset."),
34
+ ]
35
+
36
+ DEFAULT_CONFIG_NAME = "stones"
37
+
38
+ def _info(self):
39
+ return datasets.DatasetInfo(
40
+ description=_DESCRIPTION,
41
+ features=datasets.Features({
42
+ "scan_id": datasets.Value("string"),
43
+ "subset": datasets.Value("string"),
44
+ "images": datasets.Sequence(datasets.Image()),
45
+ "masks": datasets.Sequence(datasets.Image()),
46
+ "infill_gaussians_path": datasets.Value("string"),
47
+ "surface_gaussians_path": datasets.Value("string"),
48
+ }),
49
+ homepage=_HOMEPAGE,
50
+ license=_LICENSE,
51
+ citation=_CITATION,
52
+ )
53
+
54
+ def _split_generators(self, dl_manager):
55
+ data_dir = dl_manager.download_and_extract(self.config.name)
56
+ return [
57
+ datasets.SplitGenerator(
58
+ name=datasets.Split.TRAIN,
59
+ gen_kwargs={"data_dir": Path(data_dir)},
60
+ ),
61
+ ]
62
+
63
+ def _generate_examples(self, data_dir):
64
+ subset_name = self.config.name
65
+ subset_path = data_dir / subset_name
66
+
67
+ scan_dirs = sorted([d for d in subset_path.iterdir() if d.is_dir()])
68
+
69
+ for idx, scan_dir in enumerate(scan_dirs):
70
+ images = []
71
+ masks = []
72
+
73
+ # Aggregate images from all camera sub-folders
74
+ image_base_path = scan_dir / "images"
75
+ if image_base_path.exists():
76
+ for camera_dir in sorted(image_base_path.iterdir()):
77
+ if camera_dir.is_dir():
78
+ images.extend(sorted([str(p) for p in camera_dir.glob("*.png")]))
79
+ images.extend(sorted([str(p) for p in camera_dir.glob("*.jpg")]))
80
+
81
+ # Aggregate masks from all camera sub-folders
82
+ mask_base_path = scan_dir / "masks"
83
+ if mask_base_path.exists():
84
+ for camera_dir in sorted(mask_base_path.iterdir()):
85
+ if camera_dir.is_dir():
86
+ masks.extend(sorted([str(p) for p in camera_dir.glob("*.png")]))
87
+
88
+ yield idx, {
89
+ "scan_id": scan_dir.name,
90
+ "subset": subset_name,
91
+ "images": images,
92
+ "masks": masks,
93
+ "infill_gaussians_path": str(scan_dir / "infill.ply"),
94
+ "surface_gaussians_path": str(scan_dir / "surface.ply"),
95
+ }