Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
test(rife): the binary and the torch backend are judged alike on the walker pairs picked for each model, rife-v4.6 by name on its seven and rife-v4.25 on the six that meet the same rule on an Apple GPU and on llvmpipe (bfar50's cross-fade reads over its bound on llvmpipe alone); tests/fixtures/rife-walkers/walkers.json records each model's pick, and docs/loop-repair.md and the release notes say so
Soohong Kim2e60c68b54c1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex da7c1db..15c5566 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,7 +14,7 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the- **Changed: the torch backend runs rife-v4.25 (`rife_torch.NETS`, `rife_torch.Net`, `rife_torch.Head`, `rife_torch.layers`, `IFNet(name)`, `state_from_ncnn(files, name)`).** Practical-RIFE 4.25's IFNet, an encoder on each image and five blocks at scales 16 to 1, written again, its weights read from the release's `rife-v4.25` files (the published `flownet.pkl`, SHA-256 `6615790efd627772917205db291f51cd392528a157ecbb2ecaeec3bff8eb6de2`, as converted to float16), the betas held apart and the encoder's two copies checked equal. On the CPU it makes Practical-RIFE's own frame from those weights, byte for byte. No pkl mirror: the weights come from the same GitHub zip as the binary.- **Changed: reports and identities name the model.** `interpolator.model` in reports; the torch runner's and executor's identity carry `model`, so a frame kept for one model is never taken for the other, and a host whose executor answers with another model is refused as the RIFE is made.- **Licences: `NOTICE` gains TNTwise's rife-ncnn-vulkan (MIT, © 2020 nihui) and Practical-RIFE's 4.25 model (MIT, © 2021 hzwer).**-- **Tests: `tests/video/test_rife_models.py`, `tests/video/test_rife_cuts.py`, `tests/video/test_rife_torch_v425.py`, `tests/fixtures/rife-cuts`.** The default and the named model, their refusals and pins; the 128 padding (frames a multiple of 128, zeros outside) for rife-v4.25 and rife-v4.6 handed as before; cache keys apart by model; three public cuts (a knight's walk, Pip's run and jump, lossless WebP, their RGBA pinned) filled 24 → 60 fps by the binary (`real_rife`) and by the torch backend (`torch_rife`): the knight's walk at least 40 poses, Pip's run and jump within one of 39 and 67, Pip's jump the very frames PyTorch took, and every frame rife-v4.6's feet windows caught dragged 2 px caught for rife-v4.25 too; the rife-v4.25 IFNet's layer order, betas and refusals. `tests/video/test_held_fill.py` adds the unheld-bytes test above; Tests that pin the binary's calls pin them by model through `as_pinned` in `tests/conftest.py` (0 calls where the binary is not found, the same as `rife_located()` false before), which reads a pin as an int, held exactly, or as a pair `(floor, top)`, held from floor to top with both ends allowed, given by model (a dict keyed by model name) or for every model alike: rife-v4.6 the count exactly, as before, and a pair for any model but rife-v4.25 refused (ValueError); rife-v4.25 between a floor and a top, where before it was held only at most the pin, since a reviewer pointed out that a change that skipped interpolation (no calls, or too few) would still pass. The floor is the calls the cut makes when no frame is made again at another fraction, two calls for each frame the cut asks for, each asked once at its own time; the top is the larger of the counts measured on an Apple GPU and on llvmpipe (the CPU Vulkan driver of the Linux lane), because rife-v4.25 runs with no augmentation, in float16, so its frames differ with the GPU's arithmetic, and with them the frames refused and made again at another fraction. The floor counts the frames the cut asks for, not every cell of a held run it sets out to fill: a refused frame with no other fraction left to try ends that run's fill, and on four of the cases the cut then calls the binary fewer times than one frame for each cell would take (the 35 pinned cases were run on both machines, 24 of them reaching the binary; in every case both machines asked for the same number of frames at their own time, so each floor is one number; the counts were the same on both machines except on one synthetic walk, 8 calls on the Apple GPU and 10 on llvmpipe; in 9 of the 24 no frame was made again, so the floor equals the top and the count is held exactly; rife-v4.6's counts were the same on every machine measured); the purpose of the pin is unchanged, each call seconds on a CPU's Vulkan driver, so a change that asks for more calls fails on the count, not on the test's time limit, and now a change that asks for fewer frames fails on the count too. rife-v4.25 asks for more calls on some synthetic cuts and fewer on others, refusing a frame between held cells that shows a neighbour's picture again and making it at another time, or keeping the cells as filmed: `tests/video/test_play.py` (once-return, 30 to 44 against 36), `tests/video/test_ghost_given_way.py` (8 to 10 against 8), `tests/video/test_ghost_screen.py` (8 to 28 against 20), `tests/video/test_wrap_blend.py` (8 to 24 against 16), `tests/video/test_gait_fallback.py` (4 to 16 against 22 and 4 to 16 against 14), `tests/video/test_explicit_window.py` (6 to 20 against 6 and 4 to 16 against 22), `tests/video/test_walk_steps.py` (ten cases, the least 2 against 6, the most 12 to 30 against 12). `tests/release/test_rife_pins.py` holds how `as_pinned` reads a pin: rife-v4.25 from its floor to its top (0 calls, and fewer than the floor, fail), rife-v4.6 exactly, a pin not by model exactly for every model, a pair for rife-v4.6 refused, and 0 calls where the binary is not found. `tests/video/test_loop_overlap.py`: rife-v4.25 drags the third walker's hand apart at weight 0.5 (refused as torn), and at 0.7 keeps it whole and reads under the bar (`TORN_AT`). Tests calibrated on rife-v4.6's augmentation name it.+- **Tests: `tests/video/test_rife_models.py`, `tests/video/test_rife_cuts.py`, `tests/video/test_rife_torch_v425.py`, `tests/fixtures/rife-cuts`.** The default and the named model, their refusals and pins; the 128 padding (frames a multiple of 128, zeros outside) for rife-v4.25 and rife-v4.6 handed as before; cache keys apart by model; three public cuts (a knight's walk, Pip's run and jump, lossless WebP, their RGBA pinned) filled 24 → 60 fps by the binary (`real_rife`) and by the torch backend (`torch_rife`): the knight's walk at least 40 poses, Pip's run and jump within one of 39 and 67, Pip's jump the very frames PyTorch took, and every frame rife-v4.6's feet windows caught dragged 2 px caught for rife-v4.25 too; the rife-v4.25 IFNet's layer order, betas and refusals. `tests/video/test_held_fill.py` adds the unheld-bytes test above; Tests that pin the binary's calls pin them by model through `as_pinned` in `tests/conftest.py` (0 calls where the binary is not found, the same as `rife_located()` false before), which reads a pin as an int, held exactly, or as a pair `(floor, top)`, held from floor to top with both ends allowed, given by model (a dict keyed by model name) or for every model alike: rife-v4.6 the count exactly, as before, and a pair for any model but rife-v4.25 refused (ValueError); rife-v4.25 between a floor and a top, where before it was held only at most the pin, since a reviewer pointed out that a change that skipped interpolation (no calls, or too few) would still pass. The floor is the calls the cut makes when no frame is made again at another fraction, two calls for each frame the cut asks for, each asked once at its own time; the top is the larger of the counts measured on an Apple GPU and on llvmpipe (the CPU Vulkan driver of the Linux lane), because rife-v4.25 runs with no augmentation, in float16, so its frames differ with the GPU's arithmetic, and with them the frames refused and made again at another fraction. The floor counts the frames the cut asks for, not every cell of a held run it sets out to fill: a refused frame with no other fraction left to try ends that run's fill, and on four of the cases the cut then calls the binary fewer times than one frame for each cell would take (the 35 pinned cases were run on both machines, 24 of them reaching the binary; in every case both machines asked for the same number of frames at their own time, so each floor is one number; the counts were the same on both machines except on one synthetic walk, 8 calls on the Apple GPU and 10 on llvmpipe; in 9 of the 24 no frame was made again, so the floor equals the top and the count is held exactly; rife-v4.6's counts were the same on every machine measured); the purpose of the pin is unchanged, each call seconds on a CPU's Vulkan driver, so a change that asks for more calls fails on the count, not on the test's time limit, and now a change that asks for fewer frames fails on the count too. rife-v4.25 asks for more calls on some synthetic cuts and fewer on others, refusing a frame between held cells that shows a neighbour's picture again and making it at another time, or keeping the cells as filmed: `tests/video/test_play.py` (once-return, 30 to 44 against 36), `tests/video/test_ghost_given_way.py` (8 to 10 against 8), `tests/video/test_ghost_screen.py` (8 to 28 against 20), `tests/video/test_wrap_blend.py` (8 to 24 against 16), `tests/video/test_gait_fallback.py` (4 to 16 against 22 and 4 to 16 against 14), `tests/video/test_explicit_window.py` (6 to 20 against 6 and 4 to 16 against 22), `tests/video/test_walk_steps.py` (ten cases, the least 2 against 6, the most 12 to 30 against 12). `tests/release/test_rife_pins.py` holds how `as_pinned` reads a pin: rife-v4.25 from its floor to its top (0 calls, and fewer than the floor, fail), rife-v4.6 exactly, a pin not by model exactly for every model, a pair for rife-v4.6 refused, and 0 calls where the binary is not found. The test that the binary and the torch backend judge the walkers alike on one machine, which ran them with the default model, rife-v4.25, and failed on the Linux lane on one pair, bfar50 (the binary on llvmpipe read a cross-fade look over its bound, 0.01645 against 0.015, the torch backend on the CPU 0.01198, the faults the same; on the Apple GPU the binary read 0.0113), now judges each model on the pairs picked for it, listed in `tests/fixtures/rife-walkers/walkers.json` under `alike`: rife-v4.6, run by name, on its seven, and rife-v4.25 on six picked 2026-11-01 by the same rule from the same ten candidates, near25, far50, mid50, cross50, bnear50 and bfar33 (nine met the rule, near50, far25 and swap50 among them and not added; bfar50 did not, its verdicts differing on llvmpipe with a least margin of 0.097 of the bound; no rife-v4.25 pair checks the cross-fade look, since with rife-v4.25 no candidate reads it clear of its bound, where rife-v4.6's bfar50 still does). The torch backend judging the walkers as the binary did on a machine with no binary stays on rife-v4.6's seven pairs and the binary's recorded rife-v4.6 frames. `tests/video/test_loop_overlap.py`: rife-v4.25 drags the third walker's hand apart at weight 0.5 (refused as torn), and at 0.7 keeps it whole and reads under the bar (`TORN_AT`). Tests calibrated on rife-v4.6's augmentation name it.## v3.14.0 - A walk whose arms swing past its sides is witnessed where its middle rows read a body rising whole, one on a picture swaying once a cycle or slower held named, the body's word one line in both placesdiff --git a/docs/loop-repair.md b/docs/loop-repair.mdindex d33f4f6..e2a5fbe 100644--- a/docs/loop-repair.md+++ b/docs/loop-repair.md@@ -436,16 +436,26 @@ for compute only cannot run the binary at all, and there the torch backend runs`rife-v4.6` the same augmentation). Elsewhere it adds PyTorch, hundreds of megabytes, for the same model: on a Mac the binaryalready runs on the GPU. On a CPU host the torch backend is faster than the binary on llvmpipe (thetable below), but its frames are not the binary's bytes; a deployment that wants it there names it, and-the default does not move. Measured on synthetic walkers with `rife-v4.6`, 2026-10-21 (with `rife-v4.25`,-2026-11-01, the binary on the Apple GPU and the torch backend on its CPU give the seven pairs the same-verdicts again):--- **The same verdicts.** The seven pairs of `tests/fixtures/rife-walkers` (clean steps, an outline lost- where legs cross far, a ghost band, parts torn, a cross-fade to look at) get the same faults and- looks from the binary on an Apple GPU, the binary on llvmpipe and the torch backend on a CPU, each- reading at least a tenth of its bound away from it (and three more pairs besides, one left out for a- torn reading 8 % from its bound on llvmpipe). The tests keep it: the torch backend judges the seven- as the binary did on a machine with no binary, and as this machine's binary does where both run.+the default does not move. Measured on synthetic walkers with `rife-v4.6`, 2026-10-21, and with `rife-v4.25`, 2026-11-01, the pick+run again on the same ten candidates by the same rule:++- **The same verdicts.** The seven pairs of `tests/fixtures/rife-walkers` picked for `rife-v4.6` (clean+ steps, an outline lost where legs cross far, a ghost band, parts torn, a cross-fade to look at) get the+ same faults and looks from the binary on an Apple GPU, the binary on llvmpipe and the torch backend on+ a CPU, each reading at least a tenth of its bound away from it (of ten candidate pairs, two more met+ the rule and were not added, and near50 was left out for a torn reading 8 % from its bound on+ llvmpipe); run again for `rife-v4.6`, the pick gave the same seven. With `rife-v4.25` nine of the ten+ meet the rule, and six are recorded for it: near25, far50, mid50, cross50, bnear50 and bfar33 (near50,+ far25 and swap50 met the rule and were not added; near50 and far25 are near25's and far50's pairs at+ another t with the same verdict). bfar50 does not meet it: its verdicts differ on llvmpipe, where the+ binary reads a cross-fade look over its bound (0.01645 against 0.015) and the torch backend on that+ CPU does not (0.01198), the faults the same, and its least margin there is 0.097 of the bound; on the+ Apple GPU the binary reads it under (0.0113). With `rife-v4.25` no candidate reads a cross-fade look+ clear of its bound, so no `rife-v4.25` pair checks the look; `rife-v4.6`'s bfar50 still does. The tests+ keep it: the torch backend judges `rife-v4.6`'s seven as the binary did, from the binary's recorded+ `rife-v4.6` frames, on a machine with no binary, and where both run the binary and the torch backend+ judge each model's pairs alike, listed in `tests/fixtures/rife-walkers/walkers.json` under `alike`+ (`rife-v4.6`, run by name, on its seven; `rife-v4.25` on its six).- **Frames as close as two GPUs'.** Against the binary's frame on the Apple GPU, the torch backend'slies 0.005 to 0.052 of 255 apart on average and 11 at most (premultiplied RGBA in the box eithercovers), and the binary's own frame on llvmpipe 0.007 to 0.25 apart and 76 at most: closer on six ofdiff --git a/tests/fixtures/rife-walkers/walkers.json b/tests/fixtures/rife-walkers/walkers.jsonindex 4dbafe3..a185403 100644--- a/tests/fixtures/rife-walkers/walkers.json+++ b/tests/fixtures/rife-walkers/walkers.json@@ -254,5 +254,30 @@"max_abs": 76.0}}+ },+ "alike": {+ "rife-v4.6": {+ "pairs": [+ "bfar33",+ "bfar50",+ "bnear50",+ "cross50",+ "far50",+ "mid50",+ "near25"+ ],+ "picked": "2026-10-21, of ten candidate pairs: the binary's rife-v4.6 frame with -x -z on an Apple M4 Max GPU (MoltenVK) and on Mesa llvmpipe, and the torch backend's on a CPU, the same faults and looks, every reading at least a tenth of its bound away from it. near50 is left out (a torn reading 8 % from its bound on llvmpipe); far25 and swap50 met the rule and were not added. Run by name (SPRITE_GEN_RIFE_MODEL_NAME=rife-v4.6)."+ },+ "rife-v4.25": {+ "pairs": [+ "bfar33",+ "bnear50",+ "cross50",+ "far50",+ "mid50",+ "near25"+ ],+ "picked": "2026-11-01, of the same ten candidates by the same rule: the binary's rife-v4.25 frame with no augmentation (TNTwise rife-ncnn-vulkan 20250112) on an Apple M4 Max GPU (MoltenVK) and on Mesa llvmpipe, and the torch backend's on the CPU of each. bfar50 is left out: on llvmpipe the binary's frame reads a cross-fade of 0.01645, over the look's bound (0.015) by less than a tenth of it, and the torch backend's 0.01198, under it. near50, far25 and swap50 met the rule and were not added: near50 and far25 are near25's and far50's pairs at another t, with the same verdict."+ }}}diff --git a/tests/video/test_rife_torch.py b/tests/video/test_rife_torch.pyindex 298ee3e..d4c270b 100644--- a/tests/video/test_rife_torch.py+++ b/tests/video/test_rife_torch.py@@ -14,7 +14,8 @@ docs/release.md), on the device SPRITE_GEN_RIFE_DEVICE names. The rest need neitThe fixtures are synthetic: discs, legs and walkers drawn here or in tests/video/test_rife.py and test_crossfade.py,and tests/fixtures/rife-walkers — walker pairs, clean and faulty, with the binary's own -x -z frame of each made on-an Apple GPU, the engine's verdict on it, and how far the same binary's frame on Mesa llvmpipe lay from it."""+an Apple GPU, the engine's verdict on it, and how far the same binary's frame on Mesa llvmpipe lay from it; and, for+each model, the pairs it is judged alike on by the binary and the torch backend (`alike`)."""from __future__ import annotations@@ -228,17 +229,30 @@ def test_walkers_are_judged_as_the_binary_judged_them(runner46, key):assert mean <= 2 * rec["gpu_gap"]["mean_abs"] and most <= 2 * rec["gpu_gap"]["max_abs"], (mean, most, rec["gpu_gap"])+def _alike() -> dict:+ """The walker pairs each model is judged alike on (walkers.json `alike`): those its own frames met the pick's rule on,+ the binary on an Apple GPU and on llvmpipe and the torch backend on a CPU giving the same verdict, every reading at+ least a tenth of its bound away from it (`picked` says what was left out, and why)."""+ return json.loads((WALKERS / "walkers.json").read_text())["alike"]++@pytest.mark.real_rife@pytest.mark.torch_rife@pytest.mark.timeout(1800) # the binary on a CPU's Vulkan driver: a minute or more a pair[email protected]("key", sorted(_walkers()))-def test_the_binary_and_the_torch_backend_judge_the_walkers_alike_on_one_machine(runner, key):- """The recorded walker pairs through this machine's binary (llvmpipe on the Linux lane) and the torch backend, each- running the model the engine runs: the same verdict for each."""[email protected]("model, key", [(model, key) for model, picked in sorted(_alike().items()) for key in picked["pairs"]])+def test_the_binary_and_the_torch_backend_judge_the_walkers_alike_on_one_machine(model, key):+ """The walker pairs picked for each model through this machine's binary (llvmpipe on the Linux lane) and the torch+ backend, both running that model by its name: the same verdict for each. rife-v4.6 on the seven recorded for it,+ rife-v4.25, the default, on the six its own frames met the rule on."""+ from sprite_gen.video import rife_torch+t = _walkers()[key]["t"]a, b = _walker(key, "a"), _walker(key, "b")+ binary, held = rife.locate()verdicts = []- for made in (rife.Rife(*rife.locate()), rife.Rife(runner=runner)):+ for made in (rife.Rife(binary, held.parent / model),+ rife.Rife(runner=rife_torch.TorchRunner(rife.locate_model().parent / model, rife.device()))):+ assert made.model_name == modelframe, apart = made.read(a, b, t)verdicts.append(_verdict(frame, a, b, t, apart))assert verdicts[0] == verdicts[1]