ojaffe commited on
Commit
6daba35
·
verified ·
1 Parent(s): 07239aa

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. __pycache__/predict.cpython-311.pyc +0 -0
  2. predict.py +9 -19
__pycache__/predict.cpython-311.pyc CHANGED
Binary files a/__pycache__/predict.cpython-311.pyc and b/__pycache__/predict.cpython-311.pyc differ
 
predict.py CHANGED
@@ -229,28 +229,18 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
229
  all_ar_runs.append(torch.stack(ar_preds_run, dim=1))
230
 
231
  ar_pred = sum(all_ar_runs) / len(all_ar_runs)
232
-
233
- # Apply mild Gaussian blur to AR predictions
234
- import torch.nn.functional as F
235
- # Create 3x3 Gaussian kernel with sigma=0.5
236
- kernel_size = 3
237
- sigma = 0.5
238
- x = torch.arange(kernel_size, dtype=torch.float32, device=DEVICE) - kernel_size // 2
239
- gauss = torch.exp(-x**2 / (2 * sigma**2))
240
- kernel_2d = gauss[:, None] * gauss[None, :]
241
- kernel_2d = kernel_2d / kernel_2d.sum()
242
- kernel_2d = kernel_2d.view(1, 1, kernel_size, kernel_size).expand(3, 1, -1, -1)
243
- pad = kernel_size // 2
244
- for s in range(PRED_FRAMES):
245
- frame = ar_pred[:, s] # [1, 3, 64, 64]
246
- frame_padded = F.pad(frame, (pad, pad, pad, pad), mode='reflect')
247
- ar_pred[:, s] = F.conv2d(frame_padded, kernel_2d, groups=3)
248
 
249
  predicted = torch.zeros_like(direct_pred)
250
  for step in range(PRED_FRAMES):
251
- ar_weight = 0.65 - (step / (PRED_FRAMES - 1)) * 0.3
252
- direct_weight = 1.0 - ar_weight
253
- predicted[:, step] = ar_weight * ar_pred[:, step] + direct_weight * direct_pred[:, step]
 
 
 
254
 
255
  predicted_np = predicted[0].cpu().numpy()
256
  ens.direct_cache = []
 
229
  all_ar_runs.append(torch.stack(ar_preds_run, dim=1))
230
 
231
  ar_pred = sum(all_ar_runs) / len(all_ar_runs)
232
+ # Compute per-pixel variance across runs for uncertainty
233
+ ar_stack = torch.stack(all_ar_runs, dim=0) # [3, 1, 8, 3, 64, 64]
234
+ ar_var = ar_stack.var(dim=0) # [1, 8, 3, 64, 64]
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
  predicted = torch.zeros_like(direct_pred)
237
  for step in range(PRED_FRAMES):
238
+ base_ar_weight = 0.65 - (step / (PRED_FRAMES - 1)) * 0.3
239
+ # Per-pixel weight adjustment: reduce AR weight where variance is high
240
+ uncertainty = torch.clamp(ar_var[:, step] * 50, 0, 0.3)
241
+ ar_weight_map = base_ar_weight * (1 - uncertainty)
242
+ direct_weight_map = 1.0 - ar_weight_map
243
+ predicted[:, step] = ar_weight_map * ar_pred[:, step] + direct_weight_map * direct_pred[:, step]
244
 
245
  predicted_np = predicted[0].cpu().numpy()
246
  ens.direct_cache = []