Check if cache exists and parameters match. Args: num_frames: Number of frames in the scene image_width: Width of RGB images image_height: Height of RGB images has_transform: Whether traj_transform.txt exists Returns:
(self, num_frames: int, image_width: int, image_height: int, has_transform: bool)
| 114 | self.sky_masks_file = self.cache_dir / "sky_masks.npz" |
| 115 | |
| 116 | def is_valid(self, num_frames: int, image_width: int, image_height: int, has_transform: bool) -> bool: |
| 117 | """Check if cache exists and parameters match. |
| 118 | |
| 119 | Args: |
| 120 | num_frames: Number of frames in the scene |
| 121 | image_width: Width of RGB images |
| 122 | image_height: Height of RGB images |
| 123 | has_transform: Whether traj_transform.txt exists |
| 124 | |
| 125 | Returns: |
| 126 | True if cache is valid and can be used |
| 127 | """ |
| 128 | if not self.cache_file.exists() or not self.params_file.exists(): |
| 129 | return False |
| 130 | |
| 131 | try: |
| 132 | with open(self.params_file, 'r') as f: |
| 133 | params = json.load(f) |
| 134 | |
| 135 | # Check parameters |
| 136 | if params.get('spatial_subsample') != self.spatial_subsample: |
| 137 | return False |
| 138 | if params.get('image_width') != image_width: |
| 139 | return False |
| 140 | if params.get('image_height') != image_height: |
| 141 | return False |
| 142 | if params.get('num_frames') != num_frames: |
| 143 | return False |
| 144 | # Check if alignment state matches |
| 145 | if params.get('is_aligned', False) != has_transform: |
| 146 | return False |
| 147 | |
| 148 | return True |
| 149 | except Exception as e: |
| 150 | logger.warning(f"Cache validation failed: {e}") |
| 151 | return False |
| 152 | |
| 153 | def load(self) -> tuple[Dict[str, np.ndarray], List[Dict[str, np.ndarray]], bool]: |
| 154 | """Load cached scene data. |
no test coverage detected