BonanDing commited on
Commit
ead4a8b
·
1 Parent(s): 047d060

Validate DeMemWM future memory selection

Browse files
.exp_artifact/dememwm_future_memory_selection_plan.md CHANGED
@@ -405,7 +405,7 @@ Make DeMemWM memory streams self-only
405
 
406
  ## Substep 5: Final Integration Validation
407
 
408
- Status: `[ ]`
409
 
410
  Goal:
411
 
 
405
 
406
  ## Substep 5: Final Integration Validation
407
 
408
+ Status: `[x]`
409
 
410
  Goal:
411
 
datasets/video/memory_selection.py CHANGED
@@ -867,8 +867,6 @@ def select_memory_indices(
867
  else:
868
  anchor_stop = min(target_start, max(anchor_start, int(anchor_candidate_stop)))
869
  anchor_candidates = np.arange(anchor_start, anchor_stop, dtype=np.int64)
870
- if len(dynamic) > 0:
871
- anchor_candidates = anchor_candidates[~np.isin(anchor_candidates, dynamic)]
872
  anchor = _select_anchor(anchor_candidates, counts["anchor"], cfg, poses=poses)
873
 
874
  revisit = _select_revisit(
 
867
  else:
868
  anchor_stop = min(target_start, max(anchor_start, int(anchor_candidate_stop)))
869
  anchor_candidates = np.arange(anchor_start, anchor_stop, dtype=np.int64)
 
 
870
  anchor = _select_anchor(anchor_candidates, counts["anchor"], cfg, poses=poses)
871
 
872
  revisit = _select_revisit(
tests/test_dememwm_latent_dataset.py CHANGED
@@ -364,6 +364,30 @@ class MemorySelectionTests(unittest.TestCase):
364
  for key in ("anchor", "dynamic", "revisit"):
365
  self.assertTrue(np.all(indices[key][masks[key]] < 6))
366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  def test_anchor_selection_is_context_bounded_farthest_point(self):
368
  poses = _poses(10)
369
  cfg = _selection_cfg(
@@ -1376,7 +1400,7 @@ class DeMemWMLatentDatasetTests(unittest.TestCase):
1376
 
1377
  self.assertEqual(dataset.context_length, 4)
1378
  self.assertEqual(len(dataset), 112 - (100 + 4 + 3) + 1)
1379
- self.assertEqual(sample["frame_indices"].tolist(), [106, 107, 108, 102, 103, 104, 105])
1380
  self.assertTrue(sample["memory_masks"]["anchor"].all().item())
1381
  self.assertTrue(sample["memory_masks"]["dynamic"].all().item())
1382
  self.assertEqual(tuple(sample["memory_masks"]["revisit"].shape), (0,))
 
364
  for key in ("anchor", "dynamic", "revisit"):
365
  self.assertTrue(np.all(indices[key][masks[key]] < 6))
366
 
367
+ def test_anchor_can_duplicate_recent_dynamic_when_selected(self):
368
+ poses = _poses(8)
369
+ cfg = _selection_cfg(
370
+ max_anchor_frames=1,
371
+ max_dynamic_frames=1,
372
+ max_revisit_frames=0,
373
+ dynamic=_dynamic_cfg("recent"),
374
+ )
375
+
376
+ indices, masks = select_memory_indices(
377
+ poses,
378
+ np.array([6]),
379
+ cfg,
380
+ split="training",
381
+ anchor_candidate_start=5,
382
+ anchor_candidate_stop=6,
383
+ )
384
+
385
+ self.assertEqual(indices["anchor"].tolist(), [5])
386
+ self.assertEqual(indices["dynamic"].tolist(), [5])
387
+ self.assertEqual(masks["anchor"].tolist(), [True])
388
+ self.assertEqual(masks["dynamic"].tolist(), [True])
389
+ self.assertTrue(np.all(indices["dynamic"][masks["dynamic"]] < 6))
390
+
391
  def test_anchor_selection_is_context_bounded_farthest_point(self):
392
  poses = _poses(10)
393
  cfg = _selection_cfg(
 
1400
 
1401
  self.assertEqual(dataset.context_length, 4)
1402
  self.assertEqual(len(dataset), 112 - (100 + 4 + 3) + 1)
1403
+ self.assertEqual(sample["frame_indices"].tolist(), [106, 107, 108, 102, 105, 104, 105])
1404
  self.assertTrue(sample["memory_masks"]["anchor"].all().item())
1405
  self.assertTrue(sample["memory_masks"]["dynamic"].all().item())
1406
  self.assertEqual(tuple(sample["memory_masks"]["revisit"].shape), (0,))