Upload folder using huggingface_hub
Browse files- __pycache__/predict.cpython-311.pyc +0 -0
- model_pole_position.pt +1 -1
- predict.py +37 -58
- train.log +31 -52
__pycache__/predict.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/predict.cpython-311.pyc and b/__pycache__/predict.cpython-311.pyc differ
|
|
|
model_pole_position.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2971526
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:623ad759c36dc1680ed19ae7b6ab72e0803aa12aaa2df333fecf6ad4c90ad220
|
| 3 |
size 2971526
|
predict.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""
|
| 2 |
import sys
|
| 3 |
import os
|
| 4 |
import numpy as np
|
|
@@ -182,7 +182,7 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 182 |
return result
|
| 183 |
|
| 184 |
elif game == "sonic":
|
| 185 |
-
# Sonic: AR(fp16)+direct(int8) with step blending and
|
| 186 |
if ens.direct_cache is not None and n > CONTEXT_FRAMES and ens.cache_step < PRED_FRAMES:
|
| 187 |
result = ens.direct_cache[ens.cache_step]
|
| 188 |
ens.cache_step += 1
|
|
@@ -195,49 +195,34 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 195 |
context_tensor = torch.from_numpy(context).to(DEVICE)
|
| 196 |
last_tensor = torch.from_numpy(last_frame_t).to(DEVICE)
|
| 197 |
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
for step in range(PRED_FRAMES):
|
| 227 |
-
pred = _predict_ar_frame(ens.sonic_ar, c, l)
|
| 228 |
-
ar_chain.append(pred)
|
| 229 |
-
cf = c.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
|
| 230 |
-
cf = torch.cat([cf[:, 1:], pred.unsqueeze(1)], dim=1)
|
| 231 |
-
c = cf.reshape(1, -1, 64, 64)
|
| 232 |
-
l = pred
|
| 233 |
-
all_ar_preds.append(torch.stack(ar_chain, dim=1))
|
| 234 |
-
|
| 235 |
-
# Undo flips
|
| 236 |
-
ar0 = all_ar_preds[0]
|
| 237 |
-
ar1 = torch.flip(all_ar_preds[1], dims=[4])
|
| 238 |
-
ar2 = torch.flip(all_ar_preds[2], dims=[3])
|
| 239 |
-
ar3 = torch.flip(all_ar_preds[3], dims=[3, 4])
|
| 240 |
-
ar_pred = (ar0 + ar1 + ar2 + ar3) / 4.0
|
| 241 |
|
| 242 |
predicted = torch.zeros_like(direct_pred)
|
| 243 |
for step in range(PRED_FRAMES):
|
|
@@ -257,7 +242,7 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 257 |
return result
|
| 258 |
|
| 259 |
else:
|
| 260 |
-
# PP: direct with
|
| 261 |
if ens.direct_cache is not None and n > CONTEXT_FRAMES and ens.cache_step < PRED_FRAMES:
|
| 262 |
result = ens.direct_cache[ens.cache_step]
|
| 263 |
ens.cache_step += 1
|
|
@@ -270,18 +255,12 @@ def predict_next_frame(ens, context_frames: np.ndarray) -> np.ndarray:
|
|
| 270 |
context_tensor = torch.from_numpy(context).to(DEVICE)
|
| 271 |
last_tensor = torch.from_numpy(last_frame_t).to(DEVICE)
|
| 272 |
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
p0 = _predict_8frames_direct(ens.models["pole_position"], context_tensor, last_tensor)
|
| 281 |
-
p1 = torch.flip(_predict_8frames_direct(ens.models["pole_position"], ctx_hf, last_hf), dims=[4])
|
| 282 |
-
p2 = torch.flip(_predict_8frames_direct(ens.models["pole_position"], ctx_vf, last_vf), dims=[3])
|
| 283 |
-
p3 = torch.flip(_predict_8frames_direct(ens.models["pole_position"], ctx_hv, last_hv), dims=[3, 4])
|
| 284 |
-
predicted = (p0 + p1 + p2 + p3) / 4.0
|
| 285 |
|
| 286 |
predicted_np = predicted[0].cpu().numpy()
|
| 287 |
ens.direct_cache = []
|
|
|
|
| 1 |
+
"""Full PP swap: Pong direct int8, full PP model, Sonic AR fp16 + direct int8."""
|
| 2 |
import sys
|
| 3 |
import os
|
| 4 |
import numpy as np
|
|
|
|
| 182 |
return result
|
| 183 |
|
| 184 |
elif game == "sonic":
|
| 185 |
+
# Sonic: AR(fp16)+direct(int8) with step blending and TTA
|
| 186 |
if ens.direct_cache is not None and n > CONTEXT_FRAMES and ens.cache_step < PRED_FRAMES:
|
| 187 |
result = ens.direct_cache[ens.cache_step]
|
| 188 |
ens.cache_step += 1
|
|
|
|
| 195 |
context_tensor = torch.from_numpy(context).to(DEVICE)
|
| 196 |
last_tensor = torch.from_numpy(last_frame_t).to(DEVICE)
|
| 197 |
|
| 198 |
+
direct_orig = _predict_8frames_direct(ens.sonic_direct, context_tensor, last_tensor)
|
| 199 |
+
context_flipped = torch.flip(context_tensor, dims=[3])
|
| 200 |
+
last_flipped = torch.flip(last_tensor, dims=[3])
|
| 201 |
+
direct_flipped = _predict_8frames_direct(ens.sonic_direct, context_flipped, last_flipped)
|
| 202 |
+
direct_flipped = torch.flip(direct_flipped, dims=[4])
|
| 203 |
+
direct_pred = (direct_orig + direct_flipped) / 2.0
|
| 204 |
+
|
| 205 |
+
ar_preds = []
|
| 206 |
+
ctx = context_tensor.clone()
|
| 207 |
+
ctx_flip = context_flipped.clone()
|
| 208 |
+
last_t = last_tensor.clone()
|
| 209 |
+
last_f = last_flipped.clone()
|
| 210 |
+
for step in range(PRED_FRAMES):
|
| 211 |
+
ar_orig = _predict_ar_frame(ens.sonic_ar, ctx, last_t)
|
| 212 |
+
ar_flip = _predict_ar_frame(ens.sonic_ar, ctx_flip, last_f)
|
| 213 |
+
ar_flip_back = torch.flip(ar_flip, dims=[3])
|
| 214 |
+
ar_frame = (ar_orig + ar_flip_back) / 2.0
|
| 215 |
+
ar_preds.append(ar_frame)
|
| 216 |
+
ctx_frames = ctx.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
|
| 217 |
+
ctx_frames = torch.cat([ctx_frames[:, 1:], ar_orig.unsqueeze(1)], dim=1)
|
| 218 |
+
ctx = ctx_frames.reshape(1, -1, 64, 64)
|
| 219 |
+
last_t = ar_orig
|
| 220 |
+
ctx_flip_frames = ctx_flip.reshape(1, CONTEXT_FRAMES, 3, 64, 64)
|
| 221 |
+
ctx_flip_frames = torch.cat([ctx_flip_frames[:, 1:], ar_flip.unsqueeze(1)], dim=1)
|
| 222 |
+
ctx_flip = ctx_flip_frames.reshape(1, -1, 64, 64)
|
| 223 |
+
last_f = ar_flip
|
| 224 |
+
|
| 225 |
+
ar_pred = torch.stack(ar_preds, dim=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
predicted = torch.zeros_like(direct_pred)
|
| 228 |
for step in range(PRED_FRAMES):
|
|
|
|
| 242 |
return result
|
| 243 |
|
| 244 |
else:
|
| 245 |
+
# PP: direct with TTA and caching
|
| 246 |
if ens.direct_cache is not None and n > CONTEXT_FRAMES and ens.cache_step < PRED_FRAMES:
|
| 247 |
result = ens.direct_cache[ens.cache_step]
|
| 248 |
ens.cache_step += 1
|
|
|
|
| 255 |
context_tensor = torch.from_numpy(context).to(DEVICE)
|
| 256 |
last_tensor = torch.from_numpy(last_frame_t).to(DEVICE)
|
| 257 |
|
| 258 |
+
predicted_orig = _predict_8frames_direct(ens.models["pole_position"], context_tensor, last_tensor)
|
| 259 |
+
context_flipped = torch.flip(context_tensor, dims=[3])
|
| 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 = (predicted_orig + predicted_flipped) / 2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
predicted_np = predicted[0].cpu().numpy()
|
| 266 |
ens.direct_cache = []
|
train.log
CHANGED
|
@@ -1,52 +1,31 @@
|
|
| 1 |
-
[2026-04-12
|
| 2 |
-
[2026-04-12
|
| 3 |
-
[2026-04-12
|
| 4 |
-
[2026-04-12
|
| 5 |
-
[2026-04-12
|
| 6 |
-
[2026-04-12
|
| 7 |
-
[2026-04-12
|
| 8 |
-
[2026-04-12
|
| 9 |
-
[2026-04-12
|
| 10 |
-
[2026-04-12
|
| 11 |
-
[2026-04-12
|
| 12 |
-
[2026-04-12
|
| 13 |
-
[2026-04-12
|
| 14 |
-
[2026-04-12
|
| 15 |
-
[2026-04-12
|
| 16 |
-
[2026-04-12
|
| 17 |
-
[2026-04-12
|
| 18 |
-
[2026-04-12
|
| 19 |
-
[2026-04-12
|
| 20 |
-
[2026-04-12
|
| 21 |
-
[2026-04-12
|
| 22 |
-
[2026-04-12
|
| 23 |
-
[2026-04-12
|
| 24 |
-
[2026-04-12
|
| 25 |
-
[2026-04-12
|
| 26 |
-
[2026-04-12
|
| 27 |
-
[2026-04-12
|
| 28 |
-
[2026-04-12
|
| 29 |
-
[2026-04-12
|
| 30 |
-
[2026-04-12
|
| 31 |
-
[2026-04-12
|
| 32 |
-
[2026-04-12 06:14:50] E46/150 | T:0.033140(S:0.9518) V:0.097767(S:0.8514) LR:2.36e-04
|
| 33 |
-
[2026-04-12 06:15:49] E49/150 | T:0.032213(S:0.9533) V:0.097305(S:0.8522) LR:2.28e-04
|
| 34 |
-
[2026-04-12 06:16:09] E50/150 | T:0.031634(S:0.9541) V:0.097047(S:0.8524) LR:2.25e-04
|
| 35 |
-
[2026-04-12 06:17:28] E54/150 | T:0.030719(S:0.9556) V:0.096493(S:0.8531) LR:2.14e-04
|
| 36 |
-
[2026-04-12 06:18:27] E57/150 | T:0.030218(S:0.9563) V:0.095355(S:0.8549) LR:2.06e-04
|
| 37 |
-
[2026-04-12 06:18:47] E58/150 | T:0.029896(S:0.9568) V:0.094789(S:0.8558) LR:2.03e-04
|
| 38 |
-
[2026-04-12 06:19:27] E60/150 | T:0.029534(S:0.9574) V:0.096519(S:0.8532) LR:1.97e-04
|
| 39 |
-
[2026-04-12 06:22:43] E70/150 | T:0.027838(S:0.9600) V:0.095992(S:0.8544) LR:1.66e-04
|
| 40 |
-
[2026-04-12 06:25:55] E80/150 | T:0.026637(S:0.9619) V:0.095754(S:0.8547) LR:1.35e-04
|
| 41 |
-
[2026-04-12 06:28:12] E87/150 | T:0.025836(S:0.9631) V:0.094571(S:0.8563) LR:1.13e-04
|
| 42 |
-
[2026-04-12 06:28:52] E89/150 | T:0.025732(S:0.9633) V:0.094485(S:0.8564) LR:1.07e-04
|
| 43 |
-
[2026-04-12 06:29:11] E90/150 | T:0.025655(S:0.9634) V:0.094835(S:0.8561) LR:1.04e-04
|
| 44 |
-
[2026-04-12 06:32:25] E100/150 | T:0.024915(S:0.9645) V:0.094847(S:0.8561) LR:7.57e-05
|
| 45 |
-
[2026-04-12 06:35:38] E110/150 | T:0.024432(S:0.9653) V:0.094407(S:0.8567) LR:5.05e-05
|
| 46 |
-
[2026-04-12 06:38:57] E120/150 | T:0.024090(S:0.9658) V:0.094761(S:0.8562) LR:2.96e-05
|
| 47 |
-
[2026-04-12 06:42:12] E130/150 | T:0.023891(S:0.9661) V:0.094652(S:0.8564) LR:1.39e-05
|
| 48 |
-
[2026-04-12 06:45:25] E140/150 | T:0.023785(S:0.9663) V:0.094651(S:0.8564) LR:4.27e-06
|
| 49 |
-
[2026-04-12 06:48:40] E150/150 | T:0.023744(S:0.9663) V:0.094663(S:0.8564) LR:1.00e-06
|
| 50 |
-
[2026-04-12 06:48:40] Done. Best val loss: 0.094407
|
| 51 |
-
[2026-04-12 06:48:40] Model size: 2.3 MB
|
| 52 |
-
[2026-04-12 06:48:40] Training complete!
|
|
|
|
| 1 |
+
[2026-04-12 07:14:27] Starting PP SSIM-only training for 2026-04-12-153000-pp-ssim-only
|
| 2 |
+
[2026-04-12 07:14:27] Device: cuda
|
| 3 |
+
[2026-04-12 07:14:27] PP: 1,465,848 params (2.8 MB fp16)
|
| 4 |
+
[2026-04-12 07:14:28] PP train: 4097 seqs (len=16)
|
| 5 |
+
[2026-04-12 07:14:28] PP val: 482 seqs (len=16)
|
| 6 |
+
[2026-04-12 07:14:38] E1/100 | T:0.089821(S:0.9041) V:0.069040(S:0.9263) LR:3.00e-04
|
| 7 |
+
[2026-04-12 07:14:46] E2/100 | T:0.074465(S:0.9199) V:0.061649(S:0.9337) LR:3.00e-04
|
| 8 |
+
[2026-04-12 07:14:55] E3/100 | T:0.069567(S:0.9251) V:0.060543(S:0.9351) LR:2.99e-04
|
| 9 |
+
[2026-04-12 07:15:04] E4/100 | T:0.066393(S:0.9284) V:0.058608(S:0.9372) LR:2.99e-04
|
| 10 |
+
[2026-04-12 07:15:12] E5/100 | T:0.063999(S:0.9309) V:0.057957(S:0.9378) LR:2.98e-04
|
| 11 |
+
[2026-04-12 07:15:21] E6/100 | T:0.061633(S:0.9334) V:0.056070(S:0.9396) LR:2.97e-04
|
| 12 |
+
[2026-04-12 07:15:31] E7/100 | T:0.060136(S:0.9350) V:0.051418(S:0.9447) LR:2.96e-04
|
| 13 |
+
[2026-04-12 07:15:50] E9/100 | T:0.057306(S:0.9380) V:0.050541(S:0.9454) LR:2.94e-04
|
| 14 |
+
[2026-04-12 07:16:00] E10/100 | T:0.055858(S:0.9396) V:0.052572(S:0.9431) LR:2.93e-04
|
| 15 |
+
[2026-04-12 07:16:09] E11/100 | T:0.055021(S:0.9404) V:0.049028(S:0.9470) LR:2.91e-04
|
| 16 |
+
[2026-04-12 07:17:14] E18/100 | T:0.048082(S:0.9480) V:0.047964(S:0.9479) LR:2.77e-04
|
| 17 |
+
[2026-04-12 07:17:30] E20/100 | T:0.047000(S:0.9492) V:0.049137(S:0.9465) LR:2.71e-04
|
| 18 |
+
[2026-04-12 07:18:25] E26/100 | T:0.043209(S:0.9533) V:0.047514(S:0.9482) LR:2.53e-04
|
| 19 |
+
[2026-04-12 07:18:45] E28/100 | T:0.042278(S:0.9543) V:0.046412(S:0.9495) LR:2.46e-04
|
| 20 |
+
[2026-04-12 07:19:04] E30/100 | T:0.041417(S:0.9553) V:0.047650(S:0.9481) LR:2.38e-04
|
| 21 |
+
[2026-04-12 07:20:37] E40/100 | T:0.037882(S:0.9592) V:0.048536(S:0.9469) LR:1.97e-04
|
| 22 |
+
[2026-04-12 07:21:15] E44/100 | T:0.036738(S:0.9604) V:0.046170(S:0.9495) LR:1.79e-04
|
| 23 |
+
[2026-04-12 07:22:10] E50/100 | T:0.035150(S:0.9621) V:0.048340(S:0.9468) LR:1.50e-04
|
| 24 |
+
[2026-04-12 07:23:41] E60/100 | T:0.033106(S:0.9644) V:0.048292(S:0.9467) LR:1.04e-04
|
| 25 |
+
[2026-04-12 07:25:13] E70/100 | T:0.031615(S:0.9660) V:0.047850(S:0.9472) LR:6.26e-05
|
| 26 |
+
[2026-04-12 07:26:46] E80/100 | T:0.030609(S:0.9671) V:0.047661(S:0.9474) LR:2.96e-05
|
| 27 |
+
[2026-04-12 07:28:21] E90/100 | T:0.030099(S:0.9676) V:0.048131(S:0.9468) LR:8.32e-06
|
| 28 |
+
[2026-04-12 07:29:58] E100/100 | T:0.029986(S:0.9678) V:0.048119(S:0.9469) LR:1.00e-06
|
| 29 |
+
[2026-04-12 07:29:58] Done. Best val loss: 0.046170
|
| 30 |
+
[2026-04-12 07:29:58] Model size: 2.8 MB
|
| 31 |
+
[2026-04-12 07:29:58] Training complete!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|