Update acwm_dataset.py
Browse files- acwm_dataset.py +10 -3
acwm_dataset.py
CHANGED
|
@@ -62,6 +62,8 @@ class ACWMDataset(Dataset):
|
|
| 62 |
force_clip=8.0,
|
| 63 |
contact_gain=5.0,
|
| 64 |
eps=1e-6,
|
|
|
|
|
|
|
| 65 |
):
|
| 66 |
self.source_root = source_root
|
| 67 |
self.height = height
|
|
@@ -69,6 +71,7 @@ class ACWMDataset(Dataset):
|
|
| 69 |
self.force_clip = force_clip
|
| 70 |
self.contact_gain = contact_gain
|
| 71 |
self.eps = eps
|
|
|
|
| 72 |
|
| 73 |
# Required by launch_training_task: it checks `dataset.load_from_cache`
|
| 74 |
# to decide model({}, inputs=data) vs model(data). We never use the
|
|
@@ -77,7 +80,11 @@ class ACWMDataset(Dataset):
|
|
| 77 |
|
| 78 |
with open(pipeline_json) as f:
|
| 79 |
blob = json.load(f)
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# ---- contact/force pixel-space normalization stats (VAE-matched) ----
|
| 83 |
with open(physical_stats_json) as f:
|
|
@@ -100,7 +107,7 @@ class ACWMDataset(Dataset):
|
|
| 100 |
np.asarray(astats["std"], dtype=np.float32), eps) # (7,)
|
| 101 |
|
| 102 |
def __len__(self):
|
| 103 |
-
return len(self.samples)
|
| 104 |
|
| 105 |
# ------------------------------------------------------------------ #
|
| 106 |
# loaders
|
|
@@ -147,7 +154,7 @@ class ACWMDataset(Dataset):
|
|
| 147 |
# ------------------------------------------------------------------ #
|
| 148 |
|
| 149 |
def __getitem__(self, idx):
|
| 150 |
-
s = self.samples[idx]
|
| 151 |
|
| 152 |
obs_png = s["observation_frame"]
|
| 153 |
future_pngs = s["frames"] # 16 frames
|
|
|
|
| 62 |
force_clip=8.0,
|
| 63 |
contact_gain=5.0,
|
| 64 |
eps=1e-6,
|
| 65 |
+
repeat=1,
|
| 66 |
+
max_samples=None,
|
| 67 |
):
|
| 68 |
self.source_root = source_root
|
| 69 |
self.height = height
|
|
|
|
| 71 |
self.force_clip = force_clip
|
| 72 |
self.contact_gain = contact_gain
|
| 73 |
self.eps = eps
|
| 74 |
+
self.repeat = max(1, int(repeat))
|
| 75 |
|
| 76 |
# Required by launch_training_task: it checks `dataset.load_from_cache`
|
| 77 |
# to decide model({}, inputs=data) vs model(data). We never use the
|
|
|
|
| 80 |
|
| 81 |
with open(pipeline_json) as f:
|
| 82 |
blob = json.load(f)
|
| 83 |
+
samples = blob["samples"] if isinstance(blob, dict) else blob
|
| 84 |
+
# optional subset for overfit experiments
|
| 85 |
+
if max_samples is not None:
|
| 86 |
+
samples = samples[:max_samples]
|
| 87 |
+
self.samples = samples
|
| 88 |
|
| 89 |
# ---- contact/force pixel-space normalization stats (VAE-matched) ----
|
| 90 |
with open(physical_stats_json) as f:
|
|
|
|
| 107 |
np.asarray(astats["std"], dtype=np.float32), eps) # (7,)
|
| 108 |
|
| 109 |
def __len__(self):
|
| 110 |
+
return len(self.samples) * self.repeat
|
| 111 |
|
| 112 |
# ------------------------------------------------------------------ #
|
| 113 |
# loaders
|
|
|
|
| 154 |
# ------------------------------------------------------------------ #
|
| 155 |
|
| 156 |
def __getitem__(self, idx):
|
| 157 |
+
s = self.samples[idx % len(self.samples)]
|
| 158 |
|
| 159 |
obs_png = s["observation_frame"]
|
| 160 |
future_pngs = s["frames"] # 16 frames
|