File size: 3,725 Bytes
150d753
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
task_categories:
  - image-to-3d
language:
  - en
tags:
  - depth-estimation
  - layered-depth
  - stratified-sampling
  - computer-vision
size_categories:
  - 10K<n<100K
configs:
  - config_name: default
    data_files:
      - split: train
        path: metadata/sample_buckets.parquet
---

# layerdepth-stratified

**Stratified train metadata for [princeton-vl/LayeredDepth-Syn](https://huggingface.co/datasets/princeton-vl/LayeredDepth-Syn).**

This dataset does **not** duplicate LayeredDepth images (~1.9 TB). It publishes:

1. Per-scene **bucket assignments** (compressed layer count 1–4)
2. A **round-robin batch mix manifest** for balanced multilayer training
3. **Preprocessing code** aligned with the original LayeredDepth / SeeGroup pipeline

Use it to train models that avoid fake-layer collapse by balancing layer-count buckets each epoch.

## Base dataset

| Item | Value |
|------|-------|
| Images & depth PNGs | [princeton-vl/LayeredDepth-Syn](https://huggingface.co/datasets/princeton-vl/LayeredDepth-Syn) |
| Train scenes | 14,800 |
| Layers per scene | 4 depth maps (IDs 1, 3, 5, 7) |
| This repo | Metadata + sampling code only |

## Files

| Path | Description |
|------|-------------|
| `metadata/sample_buckets.parquet` | One row per train scene: `row_index`, `bucket`, layer stats |
| `metadata/bucket_manifest.json` | Bucket → row_index lists + default `batch_mix` |
| `metadata/summary.json` | Build provenance and histogram |
| `layerdepth_stratified/preprocess.py` | LayeredDepth depth collapse + RGB/depth decoding |
| `layerdepth_stratified/stratified_sampling.py` | Epoch order + DDP rank split |
| `layerdepth_stratified/dataset_loader.py` | High-level iterator API |

## Quick start

```python
from datasets import load_dataset
from layerdepth_stratified import iter_from_hub_metadata

# 1) Load stratified metadata from this repo
meta = load_dataset("YOUR_USERNAME/layerdepth-stratified", split="train")
print(meta[0])  # row_index, bucket, scene_max_compressed, ...

# 2) Iterate preprocessed samples in stratified epoch order
for sample in iter_from_hub_metadata(
    "YOUR_USERNAME/layerdepth-stratified",
    cache_dir="/path/to/hf/cache",
    seed=42,
    epoch=1,
):
    image = sample["image"]          # float32 HWC, [0, 1]
    depth = sample["depth"]          # float32 HWD, meters, LayeredDepth convention
    valid_mask = sample["valid_mask"]
    break
```

## Preprocessing (matches original LayeredDepth)

1. Decode RGB PNG → float32 `[0, 1]`
2. Decode depth PNG → meters (`/1000`, clip invalid/`>80m`)
3. **Layer collapse**: invalid shallow pixels inherit deeper valid depth (standard LayeredDepth convention)
4. Optional layer subset via `selected_layer_ids`

See `layerdepth_stratified/preprocess.py` for the reference implementation.

## Stratified sampling

Each train scene is assigned to bucket **1–4** by **compressed layer count** (ray-sort + gap events).

Default per-batch mix (`batch_mix`):

```json
{"1": 0.25, "2": 0.25, "3": 0.25, "4": 0.25}
```

Each epoch:
1. Shuffle within each bucket
2. Round-robin across buckets using `batch_mix`
3. Map indices → rows in `princeton-vl/LayeredDepth-Syn` train split

## Rebuild manifest

```bash
python -m layerdepth_stratified.build_manifest \
  --cache-dir /path/to/hf/datasets \
  --output-dir artifacts/layereddepth_stratified
```

## Citation

If you use this stratified metadata, please cite the original LayeredDepth paper/dataset and note that bucket assignments were produced with the SeeGroup stratified sampling pipeline.

## See also

- [LayeredDepth-Syn](https://huggingface.co/datasets/princeton-vl/LayeredDepth-Syn)
- SeeGroup `docs/LAYEREDDEPTH_STRATIFIED_SAMPLING.md`