Let dense inference candidates exceed legacy cap
This commit is contained in:
parent
8915a776b9
commit
831c92156a
8 changed files with 62 additions and 14 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 741 KiB After Width: | Height: | Size: 741 KiB |
|
|
@ -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.")
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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."}
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
8
tests/fixtures/real/dense-landscape.json
vendored
8
tests/fixtures/real/dense-landscape.json
vendored
|
|
@ -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."
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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={}),
|
||||
|
|
|
|||
Loading…
Reference in a new issue