Upload folder using huggingface_hub
Browse files- __pycache__/predict.cpython-311.pyc +0 -0
- predict.py +28 -22
__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,27 +202,33 @@ 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 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
predicted = torch.zeros_like(direct_pred)
|
| 228 |
for step in range(PRED_FRAMES):
|
|
@@ -260,7 +266,7 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 260 |
last_flipped = torch.flip(last_tensor, dims=[3])
|
| 261 |
predicted_flipped = _predict_8frames_direct(ens.models["pole_position"], context_flipped, last_flipped)
|
| 262 |
predicted_flipped = torch.flip(predicted_flipped, dims=[4])
|
| 263 |
-
predicted =
|
| 264 |
|
| 265 |
predicted_np = predicted[0].cpu().numpy()
|
| 266 |
ens.direct_cache = []
|
|
|
|
| 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
|
| 206 |
+
all_ar_runs = []
|
| 207 |
+
for noise_std in [0.0, 1.0/255.0, 2.0/255.0]:
|
| 208 |
+
ar_preds_run = []
|
| 209 |
+
ctx = context_tensor.clone()
|
| 210 |
+
ctx_flip = context_flipped.clone()
|
| 211 |
+
last_t = last_tensor.clone()
|
| 212 |
+
last_f = last_flipped.clone()
|
| 213 |
+
for step in range(PRED_FRAMES):
|
| 214 |
+
ctx_in = ctx if noise_std == 0 else torch.clamp(ctx + torch.randn_like(ctx) * noise_std, 0, 1)
|
| 215 |
+
ctx_flip_in = ctx_flip if noise_std == 0 else torch.clamp(ctx_flip + torch.randn_like(ctx_flip) * noise_std, 0, 1)
|
| 216 |
+
ar_orig = _predict_ar_frame(ens.sonic_ar, ctx_in, last_t)
|
| 217 |
+
ar_flip = _predict_ar_frame(ens.sonic_ar, ctx_flip_in, last_f)
|
| 218 |
+
ar_flip_back = torch.flip(ar_flip, dims=[3])
|
| 219 |
+
ar_frame = (ar_orig + ar_flip_back) / 2.0
|
| 220 |
+
ar_preds_run.append(ar_frame)
|
| 221 |
+
ctx_frames = ctx.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
|
| 222 |
+
ctx_frames = torch.cat([ctx_frames[:, 1:], ar_orig.unsqueeze(1)], dim=1)
|
| 223 |
+
ctx = ctx_frames.reshape(1, -1, 64, 64)
|
| 224 |
+
last_t = ar_orig
|
| 225 |
+
ctx_flip_frames = ctx_flip.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
|
| 226 |
+
ctx_flip_frames = torch.cat([ctx_flip_frames[:, 1:], ar_flip.unsqueeze(1)], dim=1)
|
| 227 |
+
ctx_flip = ctx_flip_frames.reshape(1, -1, 64, 64)
|
| 228 |
+
last_f = ar_flip
|
| 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 |
predicted = torch.zeros_like(direct_pred)
|
| 234 |
for step in range(PRED_FRAMES):
|
|
|
|
| 266 |
last_flipped = torch.flip(last_tensor, dims=[3])
|
| 267 |
predicted_flipped = _predict_8frames_direct(ens.models["pole_position"], context_flipped, last_flipped)
|
| 268 |
predicted_flipped = torch.flip(predicted_flipped, dims=[4])
|
| 269 |
+
predicted = (predicted_orig + predicted_flipped) / 2.0
|
| 270 |
|
| 271 |
predicted_np = predicted[0].cpu().numpy()
|
| 272 |
ens.direct_cache = []
|