Simplify lattice inference and hosted landing

This commit is contained in:
Meta Vens 2026-04-28 14:55:35 +01:00
commit 16c86d54aa
46 changed files with 1844 additions and 1492 deletions

View file

@ -23,9 +23,9 @@ The live pipeline is:
Inference now splits three ways:
- fixed lattice when the caller pins size and/or phase explicitly
- fixed lattice when the caller pins size explicitly
- searched lattice for the full local workflow
- direct autocorr lattice for the hosted demo path: one consensus size, one cheap phase probe, no size search, no phase rerank
- direct autocorr lattice for the hosted demo path: one consensus size, no size search, no candidate rerank
The hosted web shell now also has an auth seam:
@ -36,7 +36,7 @@ The hosted web shell now also has an auth seam:
## What is working
- lattice size and phase inference are still shared and still CUDA-capable
- lattice size inference are still shared and still CUDA-capable
- `phase-field` is the only canonical reconstruction path and produces the best-looking badge result in the repo so far
- compare mode, benchmark mode, diagnostics writing, and tuning all still work after the optimizer cutover
- the repo now reports both:
@ -53,7 +53,7 @@ Pinned badge case:
- fixture: `tests/fixtures/real/ai-badge-cleaned.png`
- lattice: `126x126`
- phase: `(0.0, -0.2)`
- initial lattice centers: canonical
- steps: `48`
Useful artifacts:
@ -108,17 +108,17 @@ Current stance:
- keep the shipped searched path grounded in autocorrelation only
- let autocorr keep a small near-best lag plateau and use cross-axis consensus before collapsing to one lattice family
- the hosted demo path now skips multi-size search entirely and uses one autocorr-consensus size plus the cheap inferred phase, capped by the hosted output limit
- the hosted demo path now skips multi-size search entirely and uses one autocorr-consensus size , capped by the hosted output limit
- do not trust the old pixel-walk / change-interval spacing path; it was cut after it kept pruning the badge away from the `126` family
- do not keep the projected edge-energy spectral pass; it floor-hugged to `2px` / `626`-family nonsense on the dense landscape fixture and did not earn its keep
- treat phase rerank as optional scaffolding, not sacred machinery
- treat candidate rerank as optional scaffolding, not sacred machinery
Future options worth exploring, if autocorr stops carrying its weight:
- distance-transform / medial-radius blob sizing on softened interiors
- small scale-space blob-size detection (`LoG` / `DoG`)
- blur-aware correction of observed blob width before converting to lattice size
- tiny learned size-and-phase prior trained on synthetic fake-pixel-art fixtures
- tiny learned size prior trained on synthetic fake-pixel-art fixtures
### 3. Keep phase-field honest

View file

@ -24,7 +24,7 @@ The solver nails a regular grid over the source, gives every output cell a tiny
These are the pieces that actually matter:
- `inference`: chosen lattice width, height, phase, confidence, and optional top candidates
- `inference`: chosen lattice width, height, confidence, and optional top candidates
- `edge_map`: one normalized scout map of where the source image has strong luminance/alpha changes
- `uv0_px`: the fixed source-space center for each output cell before any optimization
- `disp_t`: the live displacement field, one `(dx, dy)` vector per output cell
@ -65,22 +65,20 @@ That means the solver is not maintaining alternate per-cell candidate sets or se
- `run_pipeline(...)` in `src/repixelizer/pipeline.py`
- `_resolve_requested_target_dims(...)` in `src/repixelizer/pipeline.py`
- `infer_lattice(...)` and `infer_fixed_lattice(...)` in `src/repixelizer/inference.py`
- `_select_phase_candidate_with_reconstruction(...)` in `src/repixelizer/pipeline.py`
- `_select_candidate_with_reconstruction(...)` in `src/repixelizer/pipeline.py`
### Inputs
- source RGBA image
- optional pinned target size / width / height / phase
- optional `--skip-phase-rerank`
- optional pinned target size / width / height
- optional `--skip-candidate-rerank`
### Outputs
- `InferenceResult`
- `target_width`
- `target_height`
- `phase_x`
- `phase_y`
- `confidence`
- `confidence`
- `top_candidates`
### What the source actually does
@ -88,17 +86,17 @@ That means the solver is not maintaining alternate per-cell candidate sets or se
The pipeline first decides whether the lattice is:
- fixed explicitly by the caller, using `infer_fixed_lattice(...)`, or
- inferred directly from autocorr consensus with one cheap phase probe, using `infer_autocorr_lattice(...)`, or
- inferred directly from autocorr consensus, using `infer_autocorr_lattice(...)`, or
- searched automatically by `infer_lattice(...)`
The two automatic paths split like this:
- both paths estimate rough cell spacing from source edge-profile autocorrelation
- both paths keep a tiny near-best lag plateau long enough to find cross-axis consensus instead of collapsing instantly to one lag
- `infer_autocorr_lattice(...)` takes one consensus size, scores one small phase grid, and stops there
- `infer_lattice(...)` still builds a small candidate size family, scores a small phase grid for each size, and keeps the best candidate plus top alternates
- `infer_autocorr_lattice(...)` takes one consensus size, scores the canonical center-grid size check, and stops there
- `infer_lattice(...)` still builds a small candidate size family, scores the canonical center-grid size check for each size, and keeps the best candidate plus top alternates
After that, phase rerank may still happen, but only for `phase-field`, only when confidence is low, and only when rerank is enabled. The rerank probe is a short preview solve. It calls `_run_reconstruction(...)` with a small bounded step count, capped by both the requested solver steps and `phase_rerank_preview_steps`.
After that, candidate rerank may still happen, but only for `phase-field`, only when confidence is low, and only when rerank is enabled. The rerank probe is a short preview solve. It calls `_run_reconstruction(...)` with a small bounded step count, capped by both the requested solver steps and `candidate_rerank_preview_steps`.
That part matters. The pipeline is effectively asking:
@ -189,7 +187,7 @@ Prep does a few brutally practical things:
2. Builds the fixed lattice centers with `_make_regular_uv_px(...)`.
- `cell_x = source_width / target_width`
- `cell_y = source_height / target_height`
- `phase_x` and `phase_y` shift those centers before clipping to image bounds
- centers are placed at the canonical middle of each inferred output cell before clipping to image bounds
3. Converts the source, edge map, and lattice centers to torch tensors.
@ -339,7 +337,7 @@ Code:
Meaning:
The field pays a small tax for wandering too far. Motion has to earn its keep, but the leash is long enough to recover from moderate phase error instead of dying half a cell short of the right blob.
The field pays a small tax for wandering too far. Motion has to earn its keep, but the leash is long enough to recover from moderate starting-grid error instead of dying half a cell short of the right blob.
### Metaphor
@ -528,7 +526,7 @@ The solver also reports displacement statistics like:
- local residual
- dominant offset ratio
Those are the closest thing this machine has to an X-ray of its phase drift.
Those are the closest thing this machine has to an X-ray of its field drift.
### Metaphor
@ -551,7 +549,7 @@ These pieces all belong to the same model of the machine.
## Current seams
- low-confidence phase rerank uses only a short preview solve, not the full optimized field
- low-confidence candidate rerank uses only a short preview solve, not the full optimized field
- the edge scout only knows edge magnitude, not direction, so the solver still struggles with along-stroke versus across-stroke behavior near tapered contours
These are the places where the current implementation is still a little awkward or incomplete.

View file

@ -57,7 +57,7 @@ Repixelizer treats this as lattice inference plus reconstruction rather than a r
The canonical workflow should be fully automatic:
1. load the source image
2. infer lattice size and phase
2. infer lattice size
3. analyze source structure
4. run the `phase-field` reconstruction over the inferred lattice
5. project that result to a real pixel grid
@ -104,10 +104,10 @@ The tool must estimate the resolution of the fake lattice being mimicked.
Requirements:
- search over candidate target sizes
- search over subpixel phase offsets for each candidate
- use canonical cell centers for each candidate
- score candidates using coherence-oriented metrics rather than reconstruction alone
- expose the top-ranked alternatives in diagnostics
- if `--target-size` is provided, skip size search but still estimate phase
- if `--target-size` is provided, skip size search
Scoring goals:
- low isolated-pixel rate