ojaffe commited on
Commit
46248d0
·
verified ·
1 Parent(s): b447b5f

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. __pycache__/predict.cpython-311.pyc +0 -0
  2. predict.py +21 -23
__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
@@ -202,45 +202,43 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
202
  direct_flipped = torch.flip(direct_flipped, dims=[4])
203
  direct_pred = (direct_orig + direct_flipped) / 2.0
204
 
205
- # Multi-run AR with combined noise+brightness diversity (6 runs)
206
- # (noise_std, brightness_mult)
207
- perturbations = [
208
- (0.0, 1.0), # normal
209
- (1.0/255.0, 1.0), # noise only
210
- (2.0/255.0, 1.0), # more noise
211
- (0.0, 1.02), # brighter
212
- (0.0, 0.98), # darker
213
- (1.0/255.0, 1.01), # noise + slight bright
214
- ]
215
  all_ar_runs = []
216
- for noise_std, bright in perturbations:
217
  ar_preds_run = []
218
  ctx = context_tensor.clone()
219
  ctx_flip = context_flipped.clone()
220
  last_t = last_tensor.clone()
221
  last_f = last_flipped.clone()
222
  for step in range(PRED_FRAMES):
223
- ctx_in = ctx
224
- ctx_flip_in = ctx_flip
225
- if noise_std > 0:
226
- ctx_in = torch.clamp(ctx_in + torch.randn_like(ctx_in) * noise_std, 0, 1)
227
- ctx_flip_in = torch.clamp(ctx_flip_in + torch.randn_like(ctx_flip_in) * noise_std, 0, 1)
228
- if bright != 1.0:
229
- ctx_in = torch.clamp(ctx_in * bright, 0, 1)
230
- ctx_flip_in = torch.clamp(ctx_flip_in * bright, 0, 1)
231
  ar_orig = _predict_ar_frame(ens.sonic_ar, ctx_in, last_t)
232
  ar_flip = _predict_ar_frame(ens.sonic_ar, ctx_flip_in, last_f)
233
  ar_flip_back = torch.flip(ar_flip, dims=[3])
234
  ar_frame = (ar_orig + ar_flip_back) / 2.0
235
  ar_preds_run.append(ar_frame)
 
 
 
 
 
 
 
 
 
236
  ctx_frames = ctx.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
237
- ctx_frames = torch.cat([ctx_frames[:, 1:], ar_orig.unsqueeze(1)], dim=1)
238
  ctx = ctx_frames.reshape(1, -1, 64, 64)
239
- last_t = ar_orig
240
  ctx_flip_frames = ctx_flip.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
241
- ctx_flip_frames = torch.cat([ctx_flip_frames[:, 1:], ar_flip.unsqueeze(1)], dim=1)
242
  ctx_flip = ctx_flip_frames.reshape(1, -1, 64, 64)
243
- last_f = ar_flip
244
  all_ar_runs.append(torch.stack(ar_preds_run, dim=1))
245
 
246
  ar_pred = sum(all_ar_runs) / len(all_ar_runs)
 
202
  direct_flipped = torch.flip(direct_flipped, dims=[4])
203
  direct_pred = (direct_orig + direct_flipped) / 2.0
204
 
205
+ # Multi-run AR with noise diversity, using direct step 1 as AR init
206
+ # Get direct model's step 1 prediction for seeding AR context
207
+ direct_step1 = direct_pred[:, 0] # [1, 3, 64, 64]
208
+ direct_step1_flip = torch.flip(direct_step1, dims=[3])
209
+
 
 
 
 
 
210
  all_ar_runs = []
211
+ for noise_std in [0.0, 1.0/255.0, 2.0/255.0]:
212
  ar_preds_run = []
213
  ctx = context_tensor.clone()
214
  ctx_flip = context_flipped.clone()
215
  last_t = last_tensor.clone()
216
  last_f = last_flipped.clone()
217
  for step in range(PRED_FRAMES):
218
+ ctx_in = ctx if noise_std == 0 else torch.clamp(ctx + torch.randn_like(ctx) * noise_std, 0, 1)
219
+ ctx_flip_in = ctx_flip if noise_std == 0 else torch.clamp(ctx_flip + torch.randn_like(ctx_flip) * noise_std, 0, 1)
 
 
 
 
 
 
220
  ar_orig = _predict_ar_frame(ens.sonic_ar, ctx_in, last_t)
221
  ar_flip = _predict_ar_frame(ens.sonic_ar, ctx_flip_in, last_f)
222
  ar_flip_back = torch.flip(ar_flip, dims=[3])
223
  ar_frame = (ar_orig + ar_flip_back) / 2.0
224
  ar_preds_run.append(ar_frame)
225
+
226
+ # For step 0: use direct model's prediction as context seed
227
+ if step == 0:
228
+ feed_orig = direct_step1
229
+ feed_flip = direct_step1_flip
230
+ else:
231
+ feed_orig = ar_orig
232
+ feed_flip = ar_flip
233
+
234
  ctx_frames = ctx.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
235
+ ctx_frames = torch.cat([ctx_frames[:, 1:], feed_orig.unsqueeze(1)], dim=1)
236
  ctx = ctx_frames.reshape(1, -1, 64, 64)
237
+ last_t = feed_orig
238
  ctx_flip_frames = ctx_flip.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
239
+ ctx_flip_frames = torch.cat([ctx_flip_frames[:, 1:], feed_flip.unsqueeze(1)], dim=1)
240
  ctx_flip = ctx_flip_frames.reshape(1, -1, 64, 64)
241
+ last_f = feed_flip
242
  all_ar_runs.append(torch.stack(ar_preds_run, dim=1))
243
 
244
  ar_pred = sum(all_ar_runs) / len(all_ar_runs)