Upload folder using huggingface_hub
Browse files- __pycache__/predict.cpython-311.pyc +0 -0
- predict.py +16 -12
__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
|
@@ -151,18 +151,22 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 151 |
|
| 152 |
direct_pred = _predict_8frames_direct(ens.pong_direct, context_tensor, last_tensor)
|
| 153 |
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
-
ar_pred =
|
| 166 |
|
| 167 |
predicted = torch.zeros_like(direct_pred)
|
| 168 |
for step in range(PRED_FRAMES):
|
|
@@ -204,7 +208,7 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 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()
|
|
|
|
| 151 |
|
| 152 |
direct_pred = _predict_8frames_direct(ens.pong_direct, context_tensor, last_tensor)
|
| 153 |
|
| 154 |
+
all_pong_ar_runs = []
|
| 155 |
+
for noise_std in [0.0, 0.5/255.0, 1.0/255.0, 1.5/255.0, 2.0/255.0]:
|
| 156 |
+
ar_preds_run = []
|
| 157 |
+
ctx = context_tensor.clone()
|
| 158 |
+
last_t = last_tensor.clone()
|
| 159 |
+
for step in range(PRED_FRAMES):
|
| 160 |
+
ctx_in = ctx if noise_std == 0 else torch.clamp(ctx + torch.randn_like(ctx) * noise_std, 0, 1)
|
| 161 |
+
predicted = _predict_ar_frame(ens.models["pong"], ctx_in, last_t)
|
| 162 |
+
ar_preds_run.append(predicted)
|
| 163 |
+
ctx_frames = ctx.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
|
| 164 |
+
ctx_frames = torch.cat([ctx_frames[:, 1:], predicted.unsqueeze(1)], dim=1)
|
| 165 |
+
ctx = ctx_frames.reshape(1, -1, 64, 64)
|
| 166 |
+
last_t = predicted
|
| 167 |
+
all_pong_ar_runs.append(torch.stack(ar_preds_run, dim=1))
|
| 168 |
|
| 169 |
+
ar_pred = sum(all_pong_ar_runs) / len(all_pong_ar_runs)
|
| 170 |
|
| 171 |
predicted = torch.zeros_like(direct_pred)
|
| 172 |
for step in range(PRED_FRAMES):
|
|
|
|
| 208 |
|
| 209 |
# Multi-run AR with noise diversity
|
| 210 |
all_ar_runs = []
|
| 211 |
+
for noise_std in [0.0, 0.5/255.0, 1.0/255.0, 1.5/255.0, 2.0/255.0]:
|
| 212 |
ar_preds_run = []
|
| 213 |
ctx = context_tensor.clone()
|
| 214 |
ctx_flip = context_flipped.clone()
|