feat(pixel-grid): add independent native grid detector - #493
Conversation
Pixel-style images need a reusable grid estimate before reconstruction can run. Port the fixed upstream consensus detector behind bounded PNG/JPEG bytes and a six-field JSON CLI. The detector now runs independently without importing the application or generation pipeline.
The native detector needs a reproducible package boundary and dependency graph. Add the Rust manifest, locked dependency set, and local target exclusion. The module can now be built in isolation with deterministic dependency resolution.
The detector contract needs evidence for both simple grids and disputed inputs. Cover arbitration, sub-three-pixel confidence, JSON fields, and bounded encoded input. Regressions in consensus execution or resource handling now fail at the module boundary.
The reused detector must remain reviewable and license compliant. Document the standalone CLI, capability boundary, fixed upstream revision, and MIT terms. Maintainers can trace both the algorithm and its arbitration fixture to their source.
The standalone native module needs a gate that does not widen backend CI. Run format and locked release tests only when detector paths or its workflow change. Detector changes now receive isolated validation without touching generation jobs.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
已完成对固定 0b1e5acd6fa62988dff453161cb09773ecdc0731...baa1eb679134341f3a5d8397d24f99e8aec76f21 完整变更范围的审查,覆盖 CI path filter、Rust crate 边界、PNG/JPEG 解码与资源限制、full/fast 检测路径、六字段 JSON 契约以及测试 fixture。未发现满足审查标准的可操作 P0–P3 正确性、可靠性、安全性或性能问题。
验证:远端 PR checks 中 test、lint-and-test、codecov/patch 均通过;固定 diff git diff --check 通过。当前审查环境未安装 Cargo,因此未在本地重复运行 Rust 测试。
xiaocheny214
left a comment
There was a problem hiding this comment.
@huyanxius 这是rust语言吗?虽然rust语言性能很高......但这怎么接入后端是python语言的项目中?这个对外提供的api接口我也没有看到👀
api 接口我特地没定,交给你们后端来定吧
目前决定采用PyO3 原生扩展,Rust 源码仍放仓库根目录 native/pixel-perfect,不放进 Python backend;通过 maturin 编译成 Python 可导入的原生模块,后端只保留调用适配层 |
The detector is a native algorithm library rather than Python backend code. Move the crate into the root native workspace and remove the retired CLI boundary. Keep the detector independently buildable for the later PyO3 binding.
The detector CI still watched the retired backend-native path. Point path filters and the working directory at the root native workspace. Detector checks now run for the relocated crate.
|
这个问题成立,已按评审调整边界:Rust 检测器已从 |
A shared workspace would couple later pull requests before their merge order is established. Keep the detector lockfile with its crate and remove the premature workspace manifest. Each native module can now build and land independently.
The detector no longer builds through a shared native workspace. Run its workflow from the crate directory with the crate-local lockfile. CI now matches the independently reviewable module boundary.
xyh202131
left a comment
There was a problem hiding this comment.
已复核当前提交:原生像素网格检测器保持独立库边界,输入大小、像素量与解码资源限制明确,六字段检测契约和 full/fast 路径均有测试覆盖;当前 CI 全部通过且无未解决审查线程。
新增独立 Rust 像素网格识别库,为后续 PyO3 工具 API 提供稳定的六字段检测契约;算法源码位于仓库根目录,不属于 Python 后端,也不进入任何生成或工作流调用链。
Why
模型生成的像素风图片通常仍存在隐含网格、抗锯齿和非整数像素单元。重建模块需要先获得可替换、可验证的网格估计,同时 Rust 算法不应被归入 Python 后端目录或通过生产 CLI 暴露。
Changes
cols、rows、step_x、step_y、consensus、confidence。<3px时统一标记为低置信度。native/pixel-perfect/crates/detector/,删除生产 stdin/stdout CLI 和 JSON 依赖。Implementation
detect_bytes是唯一算法入口,DetectorMode::Full与DetectorMode::Fast保持显式区分。Verification
cargo fmt --check:通过。cargo test --release --locked:5 项测试通过,0 项失败。git diff --check upstream/main...HEAD:通过。Scope
<3px的自动识别准确率,不加入单图启发式特例。Related Issues
Closes #490
Refs #489