diff --git a/README.md b/README.md index 492d5ab..4e4b611 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ If you want to support the official hosted deployment and help us scale the poor This sheet carries two cases: the ugly fake-pixel badge and a dense higher-resolution landscape. The badge row shows the core salvage story. The landscape row shows a different failure mode: auto lattice inference still -undershoots that source badly, so the `phase-field` panel is the tracked fixed +undershoots that source, so the `phase-field` panel is the tracked fixed `512x512` result next to the same cheap Lanczos baseline. Each row carries its own inset, so the tiny details have nowhere to hide. diff --git a/docs/readme-assets/badge-example-sheet.png b/docs/readme-assets/badge-example-sheet.png index 15b3a23..d8494e1 100644 Binary files a/docs/readme-assets/badge-example-sheet.png and b/docs/readme-assets/badge-example-sheet.png differ diff --git a/scripts/generate_readme_previews.py b/scripts/generate_readme_previews.py index f46306a..8cfebf7 100644 --- a/scripts/generate_readme_previews.py +++ b/scripts/generate_readme_previews.py @@ -121,13 +121,13 @@ def _parse_args() -> argparse.Namespace: parser.add_argument( "--dense-auto-inferred-width", type=int, - default=251, + default=418, help="Current automatic lattice width guess for the dense landscape case.", ) parser.add_argument( "--dense-auto-inferred-height", type=int, - default=251, + default=418, help="Current automatic lattice height guess for the dense landscape case.", ) parser.add_argument("--steps", type=int, default=48, help="Optimizer step budget for both runs.") diff --git a/src/repixelizer/inference.py b/src/repixelizer/inference.py index d007c00..fcd2ebc 100644 --- a/src/repixelizer/inference.py +++ b/src/repixelizer/inference.py @@ -63,14 +63,14 @@ def _candidate_dims( return [(max(1, round(width * target_size / height)), target_size)] max_dim = max(width, height) min_size = max(12, int(round(max_dim / 48))) - max_size = min(256, max(24, int(round(max_dim / 2.5)))) - step = 2 if max_size <= 96 else 4 - size_values = set(range(min_size, max_size + 1, step)) + capped_max_size = min(256, max(24, int(round(max_dim / 2.5)))) + step = 2 if capped_max_size <= 96 else 4 + size_values = set(range(min_size, capped_max_size + 1, step)) if hinted_sizes: for hinted_size in hinted_sizes: for delta in range(-2, 3): candidate = int(hinted_size) + delta - if min_size <= candidate <= max_size: + if min_size <= candidate <= max_dim: size_values.add(candidate) dims: list[tuple[int, int]] = [] for size in sorted(size_values): diff --git a/state/evidence.jsonl b/state/evidence.jsonl index e9a31eb..17bf121 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -6,3 +6,4 @@ {"ts": "2026-04-26T04:52:53+00:00", "type": "design", "status": "accepted", "note": "Hosted convenience is the monetization path for Repixelizer; keep the code open, let self-hosting remain the escape hatch, and do not prioritize native desktop packaging unless it clearly beats hosted access on revenue, support burden, or strategy."} {"ts": "2026-04-26T12:56:28+00:00", "type": "research", "status": "ok", "note": "Added dense landscape fixture tests/fixtures/real/dense-landscape.png plus tracked fixed-512 output. Current automatic lattice inference on the 1254px source undershoots to 251x251, so README previews now include that case with the fixed 512x512 result beside Lanczos."} {"ts": "2026-04-26T13:14:17+00:00", "type": "research", "status": "ok", "note": "Dense landscape auto inference misses high because spacing stats split between false small-cell harmonics and mushier real-cell intervals. The spacing spectrum actually guides toward 415/418 and 251, but src/repixelizer/inference.py caps automatic major-axis candidates at 256, silently discarding the denser 415/418 branch; among the surviving sizes, reranking picks 251. Current phase/coherence scoring on the fixture is much stronger around 415-418 than at 251."} +{"ts": "2026-04-26T13:53:17+00:00", "type": "research", "status": "ok", "note": "Relaxed automatic candidate search so high guided sizes from the spacing spectrum can survive above the old 256 cap. On tests/fixtures/real/dense-landscape.png, auto inference now lands at 418x418 instead of 251x251; still short of the fixed 512x512 target, but no longer throwing away most of the detail before scoring starts."} diff --git a/tests/fixtures/real/dense-landscape-focus.json b/tests/fixtures/real/dense-landscape-focus.json index 22ed35c..4ecb5c8 100644 --- a/tests/fixtures/real/dense-landscape-focus.json +++ b/tests/fixtures/real/dense-landscape-focus.json @@ -2,8 +2,8 @@ "description": "Focused preview crop for the dense fixed-512 landscape row. Use this when comparing high-density detail retention against Lanczos and when checking the known size-inference miss.", "input": "tests/fixtures/real/dense-landscape.png", "fixed_output": "tests/fixtures/real/dense-landscape-fixed-512.png", - "auto_inferred_width": 251, - "auto_inferred_height": 251, + "auto_inferred_width": 418, + "auto_inferred_height": 418, "target_width": 512, "target_height": 512, "cell_bbox": [44, 396, 124, 476] diff --git a/tests/fixtures/real/dense-landscape.json b/tests/fixtures/real/dense-landscape.json index 82d3c57..302f7a6 100644 --- a/tests/fixtures/real/dense-landscape.json +++ b/tests/fixtures/real/dense-landscape.json @@ -8,15 +8,15 @@ "expected_target_height": 512, "auto_inference_snapshot": { "date": "2026-04-26", - "target_width": 251, - "target_height": 251, - "phase_x": 0.0, + "target_width": 418, + "target_height": 418, + "phase_x": 0.2, "phase_y": -0.2 }, "preview_focus_cell_bbox": [44, 396, 124, 476], "notes": [ "Use this when testing dense higher-resolution pixel art that already has a coherent lattice but still fools the current size inference search.", "The tracked phase-field output was produced from a fixed 512x512 lattice and is kept around so README preview generation does not depend on rerunning that exact pass.", - "The current automatic lattice guess on the source fixture undershoots badly at 251x251, which makes this a useful regression case for future inference work." + "The current automatic lattice guess on the source fixture still undershoots at 418x418, which keeps this useful as a regression case for high-density lattice inference." ] } diff --git a/tests/test_inference.py b/tests/test_inference.py index a501832..f335da1 100644 --- a/tests/test_inference.py +++ b/tests/test_inference.py @@ -1,10 +1,14 @@ from __future__ import annotations +from pathlib import Path + import numpy as np import pytest from repixelizer.inference import ( SpacingEstimate, + _estimate_lattice_spacing_details, + _estimate_lattice_prior_details, _axis_prior_from_estimates, _candidate_dims, _combine_axis_priors, @@ -14,9 +18,10 @@ from repixelizer.inference import ( infer_fixed_lattice, infer_lattice, ) +from repixelizer.io import load_rgba from repixelizer.observe import PipelineCancelled -from repixelizer.types import InferenceCandidate from repixelizer.synthetic import fake_pixelize, make_emblem +from repixelizer.types import InferenceCandidate def _make_spacing_estimate( @@ -72,6 +77,15 @@ def test_spacing_hints_can_add_dense_candidates_around_true_size() -> None: assert 128 in sizes +def test_spacing_hints_can_break_major_axis_cap_for_dense_candidates() -> None: + dims = _candidate_dims(1254, 1254, None, hinted_sizes=[418]) + sizes = {width for width, _ in dims} + assert 418 in sizes + assert 416 in sizes + assert 420 in sizes + assert 512 not in sizes + + def test_strong_spacing_signal_can_collapse_candidate_search_to_single_size() -> None: dims = _resolve_candidate_dims_from_spacing( 1024, @@ -125,6 +139,39 @@ def test_weak_spacing_signal_uses_spectrum_modes_to_keep_candidate_search_compac assert all(any(abs(size - target) <= 2 for target in (64, 128, 256)) for size in sizes) +def test_dense_landscape_candidate_search_keeps_high_guided_sizes() -> None: + rgba = load_rgba(Path("tests/fixtures/real/dense-landscape.png")) + spacing_x_estimate, spacing_y_estimate = _estimate_lattice_spacing_details(rgba) + spacing_x = (spacing_x_estimate.spacing, spacing_x_estimate.confidence) + spacing_y = (spacing_y_estimate.spacing, spacing_y_estimate.confidence) + hinted_sizes = _hint_target_sizes_from_spacing( + rgba.shape[1], + rgba.shape[0], + spacing_x, + spacing_y, + ) + _prior_x, _prior_y, prior_reliability = _estimate_lattice_prior_details( + rgba, + spacing_x=spacing_x, + spacing_y=spacing_y, + ) + dims = _resolve_candidate_dims_from_spacing( + rgba.shape[1], + rgba.shape[0], + None, + hinted_sizes=hinted_sizes, + spacing_x=spacing_x, + spacing_y=spacing_y, + prior_reliability=prior_reliability, + spacing_x_estimate=spacing_x_estimate, + spacing_y_estimate=spacing_y_estimate, + ) + sizes = {width for width, _ in dims} + assert any(size > 256 for size in sizes) + assert any(abs(size - 418) <= 1 for size in sizes) + assert any(abs(size - 251) <= 1 for size in sizes) + + def test_top_candidates_are_diversified_by_size() -> None: candidates = [ InferenceCandidate(target_width=113, target_height=113, phase_x=0.0, phase_y=0.0, score=0.90, breakdown={}),