Upload folder using huggingface_hub
Browse files- __pycache__/predict.cpython-311.pyc +0 -0
- predict.py +5 -7
__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
|
@@ -155,8 +155,7 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 155 |
ctx = context_tensor.clone()
|
| 156 |
last_t = last_tensor.clone()
|
| 157 |
for step in range(PRED_FRAMES):
|
| 158 |
-
|
| 159 |
-
predicted = _predict_ar_frame(ens.models["pong"], ctx, last_t, residual_scale=pong_scale)
|
| 160 |
ar_preds.append(predicted)
|
| 161 |
ctx_frames = ctx.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
|
| 162 |
ctx_frames = torch.cat([ctx_frames[:, 1:], predicted.unsqueeze(1)], dim=1)
|
|
@@ -167,7 +166,7 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 167 |
|
| 168 |
predicted = torch.zeros_like(direct_pred)
|
| 169 |
for step in range(PRED_FRAMES):
|
| 170 |
-
ar_weight = 0.
|
| 171 |
direct_weight = 1.0 - ar_weight
|
| 172 |
predicted[:, step] = ar_weight * ar_pred[:, step] + direct_weight * direct_pred[:, step]
|
| 173 |
|
|
@@ -214,9 +213,8 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 214 |
for step in range(PRED_FRAMES):
|
| 215 |
ctx_in = ctx if noise_std == 0 else torch.clamp(ctx + torch.randn_like(ctx) * noise_std, 0, 1)
|
| 216 |
ctx_flip_in = ctx_flip if noise_std == 0 else torch.clamp(ctx_flip + torch.randn_like(ctx_flip) * noise_std, 0, 1)
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
ar_flip = _predict_ar_frame(ens.sonic_ar, ctx_flip_in, last_f, residual_scale=sonic_scale)
|
| 220 |
ar_flip_back = torch.flip(ar_flip, dims=[3])
|
| 221 |
ar_frame = (ar_orig + ar_flip_back) / 2.0
|
| 222 |
ar_preds_run.append(ar_frame)
|
|
@@ -234,7 +232,7 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 234 |
|
| 235 |
predicted = torch.zeros_like(direct_pred)
|
| 236 |
for step in range(PRED_FRAMES):
|
| 237 |
-
ar_weight = 0.
|
| 238 |
direct_weight = 1.0 - ar_weight
|
| 239 |
predicted[:, step] = ar_weight * ar_pred[:, step] + direct_weight * direct_pred[:, step]
|
| 240 |
|
|
|
|
| 155 |
ctx = context_tensor.clone()
|
| 156 |
last_t = last_tensor.clone()
|
| 157 |
for step in range(PRED_FRAMES):
|
| 158 |
+
predicted = _predict_ar_frame(ens.models["pong"], ctx, last_t, residual_scale=1.03)
|
|
|
|
| 159 |
ar_preds.append(predicted)
|
| 160 |
ctx_frames = ctx.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
|
| 161 |
ctx_frames = torch.cat([ctx_frames[:, 1:], predicted.unsqueeze(1)], dim=1)
|
|
|
|
| 166 |
|
| 167 |
predicted = torch.zeros_like(direct_pred)
|
| 168 |
for step in range(PRED_FRAMES):
|
| 169 |
+
ar_weight = 0.90 - (step / (PRED_FRAMES - 1)) * 0.3
|
| 170 |
direct_weight = 1.0 - ar_weight
|
| 171 |
predicted[:, step] = ar_weight * ar_pred[:, step] + direct_weight * direct_pred[:, step]
|
| 172 |
|
|
|
|
| 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, residual_scale=1.08)
|
| 217 |
+
ar_flip = _predict_ar_frame(ens.sonic_ar, ctx_flip_in, last_f, residual_scale=1.08)
|
|
|
|
| 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)
|
|
|
|
| 232 |
|
| 233 |
predicted = torch.zeros_like(direct_pred)
|
| 234 |
for step in range(PRED_FRAMES):
|
| 235 |
+
ar_weight = 0.70 - (step / (PRED_FRAMES - 1)) * 0.3
|
| 236 |
direct_weight = 1.0 - ar_weight
|
| 237 |
predicted[:, step] = ar_weight * ar_pred[:, step] + direct_weight * direct_pred[:, step]
|
| 238 |
|