Skip to content

feat(pixel-grid): add independent native grid reconstructor - #495

Open
huyanxius wants to merge 12 commits into
1024XEngineer:mainfrom
huyanxius:feat/491-pixel-grid-reconstructor
Open

feat(pixel-grid): add independent native grid reconstructor#495
huyanxius wants to merge 12 commits into
1024XEngineer:mainfrom
huyanxius:feat/491-pixel-grid-reconstructor

Conversation

@huyanxius

@huyanxius huyanxius commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

新增与检测器和业务应用解耦的显式网格重建库:调用方给定网格后,Rust 模块返回每格单色的原生 1x PNG;源码位于仓库根目录,不属于 Python 后端。

Why

网格识别与像素重建是两种不同职责。把重建逻辑绑定在检测器、Python 后端或生成管线中,会导致后续替换检测算法时同时改动颜色恢复,并扩大本地算法的业务耦合。

Changes

  • 新增独立 Rust library,只接收 PNG/JPEG、colsrowscolors 并返回 PNG。
  • 使用两阶段结构标签投票与原色恢复,使 colors 只控制结构聚类,不硬性截断最终全局色板。
  • 钳制密集网格的负三角权重,避免颜色外插产生荧光坏点。
  • 在解码和算法分配前限制 32MiB 输入、4MP 像素和 128MiB 保守工作集。
  • 将模块放置在 native/pixel-perfect/crates/reconstructor/,删除生产 stdin/stdout CLI。
  • 更新独立 path-filter CI、MIT 许可证和固定上游版本说明。

Implementation

  • reconstruct_bytes 是唯一算法入口;网格参数是唯一空间契约,模块不推断像素密度。
  • 重建器使用 crate-local manifest 与 lockfile,可在检测器尚未合入时独立构建。
  • Python 原生扩展与工具 API 由 feat(pixel-perfect): expose an independent tool API #492 单独交付。

Verification

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

Scope

Related Issues

Closes #491

Refs #489

Detected grids need a separate local stage that can rebuild one color per cell.

Add deterministic two-stage reconstruction with bounded memory and explicit grid arguments.

Images can now be rebuilt without invoking detection, application services, or generation flows.
The native reconstructor needs a reproducible package boundary and dependency graph.

Add the Rust manifest, locked dependencies, and local target exclusion.

The reconstruction module can now build independently with deterministic inputs.
Explicit reconstruction must preserve source colors without creating dense-grid artifacts.

Cover exact cells, uncapped final palettes, bad points, input limits, and working-set rejection.

Color and resource regressions now fail before this module reaches the application layer.
The extracted reconstruction algorithm must remain traceable and license compliant.

Document its explicit-grid contract, two-stage color behavior, fixed upstream revision, and MIT terms.

Maintainers can review the reuse boundary without consulting the generation codebase.
The standalone reconstructor needs a narrow gate independent of backend CI.

Run format and locked release tests only for reconstructor paths and its workflow.

Reconstruction changes now receive isolated validation without touching generation jobs.
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

Deployment failed for project windup with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/huyan-s-projects1?upgradeToPro=build-rate-limit

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

审查了独立重建器的输入边界、两阶段标签/颜色恢复、透明度多数票、CLI 参数契约、工作集估算以及 path-filter CI。发现透明 PNG 的可见颜色恢复仍会受到透明像素 RGB 元数据影响,建议在合并前修正。固定 SHA 范围的 git diff --check 通过;本环境未安装 cargo,因此无法复跑 Rust 测试。

Comment thread native/pixel-perfect/crates/reconstructor/src/reconstruct.rs
Transparent pixel metadata could tint a cell that reconstructs as opaque.

Exclude non-visible pixels from selected and fallback visible color averages.

Opaque cell colors now reflect only pixels that contribute visible color.
The visible-color regression needs a fixture with conflicting hidden RGB data.

Add a majority-opaque red cell whose transparent pixels store blue channels.

The test prevents hidden PNG metadata from tinting reconstructed output.
The reconstructor is a native algorithm library rather than Python backend code.

Move the independent crate to the root native area and remove the retired CLI.

The later PyO3 binding can consume it without coupling this module to Python.
The reconstructor workflow still watched the retired backend-native path.

Point path filters and the working directory at the independent native crate.

Reconstruction checks now run for the relocated module.
@vercel

vercel Bot commented Aug 21, 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 4:16am

@huyanxius huyanxius changed the title feat(pixel-grid): add explicit grid reconstructor feat(pixel-grid): add independent native grid reconstructor Aug 21, 2026
The provenance note still claimed an algorithm change that has been withdrawn.

Remove the transparent-color fix statement from the native module documentation.

The pull request now describes only relocation and the existing algorithm.

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

这个没啥问题

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 their stale review 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 explicit grid reconstructor

3 participants