Skip to content

feat(pixel-grid): add independent native grid detector - #493

Open
huyanxius wants to merge 9 commits into
1024XEngineer:mainfrom
huyanxius:feat/490-pixel-grid-detector
Open

feat(pixel-grid): add independent native grid detector#493
huyanxius wants to merge 9 commits into
1024XEngineer:mainfrom
huyanxius:feat/490-pixel-grid-detector

Conversation

@huyanxius

@huyanxius huyanxius commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

新增独立 Rust 像素网格识别库,为后续 PyO3 工具 API 提供稳定的六字段检测契约;算法源码位于仓库根目录,不属于 Python 后端,也不进入任何生成或工作流调用链。

Why

模型生成的像素风图片通常仍存在隐含网格、抗锯齿和非整数像素单元。重建模块需要先获得可替换、可验证的网格估计,同时 Rust 算法不应被归入 Python 后端目录或通过生产 CLI 暴露。

Changes

  • 新增独立 Rust library,读取 PNG/JPEG 字节并返回 colsrowsstep_xstep_yconsensusconfidence
  • 复用 Pixel Art Fixer 固定提交的多检测器共识算法,覆盖快速一致、三方共识和仲裁路径。
  • 在解码前限制 32MiB 输入、4MP 像素数与解码分配;任一轴 <3px 时统一标记为低置信度。
  • 将模块放置在根目录 native/pixel-perfect/crates/detector/,删除生产 stdin/stdout CLI 和 JSON 依赖。
  • 更新独立 path-filter CI、许可证、固定上游版本和测试 fixture 溯源。

Implementation

  • detect_bytes 是唯一算法入口,DetectorMode::FullDetectorMode::Fast 保持显式区分。
  • 检测器使用 crate-local manifest 与 lockfile,可在其他原生模块尚未合入时独立构建;本 crate 不依赖 Python、Windup 应用或其他像素模块。
  • Python 原生扩展与工具 API 由 feat(pixel-perfect): expose an independent tool API #492 单独交付。

Verification

  • cargo fmt --check:通过。
  • cargo test --release --locked:5 项测试通过,0 项失败。
  • git diff --check upstream/main...HEAD:通过。
  • GitHub Actions:等待当前 head 完成。

Scope

Related Issues

Closes #490

Refs #489

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.
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
windup Ignored Ignored Preview Aug 21, 2026 3:56am

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已完成对固定 0b1e5acd6fa62988dff453161cb09773ecdc0731...baa1eb679134341f3a5d8397d24f99e8aec76f21 完整变更范围的审查,覆盖 CI path filter、Rust crate 边界、PNG/JPEG 解码与资源限制、full/fast 检测路径、六字段 JSON 契约以及测试 fixture。未发现满足审查标准的可操作 P0–P3 正确性、可靠性、安全性或性能问题。

验证:远端 PR checks 中 testlint-and-testcodecov/patch 均通过;固定 diff git diff --check 通过。当前审查环境未安装 Cargo,因此未在本地重复运行 Rust 测试。

@xiaocheny214 xiaocheny214 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huyanxius 这是rust语言吗?虽然rust语言性能很高......但这怎么接入后端是python语言的项目中?这个对外提供的api接口我也没有看到👀

@huyanxius

Copy link
Copy Markdown
Collaborator Author

@huyanxius 这是rust语言吗?虽然rust语言性能很高......但这怎么接入后端是python语言的项目中?这个对外提供的api接口我也没有看到👀

api 接口我特地没定,交给你们后端来定吧

@huyanxius 这是rust语言吗?虽然rust语言性能很高......但这怎么接入后端是python语言的项目中?这个对外提供的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.
@huyanxius huyanxius changed the title feat(pixel-grid): add standalone grid detector feat(pixel-grid): add independent native grid detector Aug 21, 2026
@huyanxius

Copy link
Copy Markdown
Collaborator Author

这个问题成立,已按评审调整边界:Rust 检测器已从 backend/native 移到仓库根目录 native/pixel-perfect/crates/detector,本 PR 只交付纯 Rust library。Python 接入不会转写算法,也不再走子进程;#492 将通过 PyO3/maturin 编译原生扩展,由现有 Python 后端直接导入,并在 #496 交付独立 /tools/pixel-perfect API。三个 PR 仍按检测器、重建器、绑定与 API 分开评审,均不进入生成管线。设计变更记录:#490 (comment)

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
xyh202131 previously approved these changes Aug 21, 2026

@xyh202131 xyh202131 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已复核当前提交:原生像素网格检测器保持独立库边界,输入大小、像素量与解码资源限制明确,六字段检测契约和 full/fast 路径均有测试覆盖;当前 CI 全部通过且无未解决审查线程。

xyh202131
xyh202131 previously approved these changes Aug 21, 2026

@xyh202131 xyh202131 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按请求批量审批当前提交。

@xyh202131
xyh202131 dismissed stale reviews from themself August 21, 2026 09:16

按请求撤销此前审批。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(pixel-grid): add an independent grid detector

3 participants