refactor(pixel-grid): migrate reconstructor to Python - #623
Conversation
The server reconstructor imports NumPy and Pillow directly. Declare both packages in the app manifest and refresh the workspace lock metadata. Deployments no longer rely on transitive image-processing dependencies.
The migrated algorithm remains derived from a fixed MIT-licensed upstream revision. Record the reuse boundary and include the upstream copyright and license terms. Reviewers can verify provenance without consulting the retired Rust pull request.
The explicit grid reconstructor does not require a separate Rust delivery path. Port deterministic clustering and two-stage packing to bounded NumPy and Pillow code. RGBA behavior stays compatible while removing the future PyO3 integration burden.
A language migration must not alter grid, color, alpha, or resource contracts. Cover the Rust golden output alongside explicit grids, limits, and transparent RGB behavior. Future numerical or algorithm substitutions now fail against observable results.
The Python port needs repeatable latency, memory, and output-parity evidence. Add the same 1024-square workload and Rust RGBA golden used during migration. Reviewers can measure warmed median latency and peak RSS on their target host.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Review conclusion
Reviewed the complete fixed range d14d07c574a39ae910a7581b4b7b453044e10372...78133b3029e49ec177f12481652d4d9fa329e24f, covering the dependency/lock updates, provenance files, Python reconstructor, tests, and benchmark. I found no actionable correctness, compatibility, resource-bound, or security regression introduced by this PR. Static compilation and git diff --check pass. The focused pytest command was not runnable in this workspace because uv and pytest are unavailable; the PR description reports the focused suite passing.
xyh202131
left a comment
There was a problem hiding this comment.
服务端实现边界清晰,资源上限和回归覆盖齐全;可以合并。
|
@nighca 老师,这是完美像素化的 PR,还没 review 过,xyh 不小心把他merge 了😂 |
nighca
left a comment
There was a problem hiding this comment.
@nighca 老师,这是完美像素化的 PR,还没 review 过,xyh 不小心把他merge 了😂
@huyanxius 好的,PR 本身没啥大问题,不过“不小心 merge”这个不太应该
| @@ -0,0 +1,67 @@ | |||
| """运行与 PR #495 Rust 基线相同的显式网格重建负载。""" | |||
There was a problem hiding this comment.
性能基本能和 rust 持平,但是问题是,现在看起来完美像素化图片尚还可以,但是到了视频逐帧就有点灾难了,张靖恒正在 做实验,稍后他会提一个 issue
There was a problem hiding this comment.
“灾难”是指性能吧?是不是没有控制并行处理的任务数量,如果很多个像素化任务一下子一起跑,有问题是正常的,排队处理就行
There was a problem hiding this comment.
倒不是性能,是指它的质量,因为它视频截帧之后并不是按照严格的像素逻辑移动的,而且每一次都会带有一定随机性,造成的偏移会更大,所以看起来质量会比完美像素化之前低。
老师可以在这里看看:#665
将显式网格重建器从 Rust 迁移到服务端 Python。输入仍为
PNG/JPEG bytes + cols + rows + colors,输出仍为cols × rows的 RGBA PNG;算法和输出行为不变。Why
该模块位于 Python 服务端,核心计算是数组距离、聚合投票和图片编解码,可由 NumPy/Pillow 直接完成。保留 Rust 版本需要额外维护 PyO3 接口、跨平台构建产物和 Rust 工具链,本次迁移移除这层跨语言边界。
Algorithm
cols × rows网格,按三角空间权重投票,确定每个 cell 的结构标签。colors只控制结构聚类数量,不限制最终输出色板。透明像素 RGB 继续沿用现有行为。Changes
windup_app.server.pixel_perfect.reconstructor,使用 NumPy/Pillow 实现重建入口与错误边界。ef376e57e1c272633ca2dbf5f29ec3fcf6596465,保留 MIT 许可证。Verification
uv run pytest -q tests/test_pixel_grid_reconstructor.py --no-cov:14 passed。uv run ruff check ...:All checks passed。uv run ruff format --check ...:4 files already formatted。uv run lint-imports:2 kept,0 broken。uv lock --check:通过。git diff --check upstream/main...HEAD:通过。Scope
Related Issues
Closes #613
Refs #491
Refs #495
Refs #496