Trim tile-graph to edge-only analysis

This commit is contained in:
Meta Vens 2026-04-23 03:56:03 +01:00
commit cd09307367
9 changed files with 104 additions and 82 deletions

View file

@ -18,3 +18,17 @@ def test_analyze_source_cpu_device_matches_default_path() -> None:
assert np.allclose(accelerated.alpha_map, default.alpha_map, atol=1e-5)
assert accelerated.cluster_map.shape == default.cluster_map.shape
assert accelerated.cluster_preview.shape == default.cluster_preview.shape
def test_analyze_source_can_skip_cluster_analysis() -> None:
source = np.zeros((8, 8, 4), dtype=np.float32)
source[..., 3] = 1.0
source[2:6, 3:5, :3] = np.asarray([1.0, 0.8, 0.2], dtype=np.float32)
analysis = analyze_source(source, seed=7, device="cpu", include_clusters=False)
assert analysis.edge_map.shape == source.shape[:2]
assert np.allclose(analysis.alpha_map, source[..., 3], atol=1e-5)
assert analysis.cluster_centers.size == 0
assert np.all(analysis.cluster_map == -1)
assert np.count_nonzero(analysis.cluster_preview) == 0

View file

@ -47,6 +47,31 @@ def test_tile_graph_model_extracts_candidates_and_adjacency_from_lattice_proposa
assert model.model_device == "cpu"
def test_tile_graph_model_works_with_edge_only_analysis() -> None:
lowres = np.zeros((4, 4, 4), dtype=np.float32)
lowres[..., 3] = 1.0
lowres[1:3, 1:3] = np.asarray([1.0, 0.7, 0.2, 1.0], dtype=np.float32)
source = np.repeat(np.repeat(lowres, 8, axis=0), 8, axis=1)
inference = InferenceResult(
target_width=4,
target_height=4,
phase_x=0.0,
phase_y=0.0,
confidence=1.0,
top_candidates=[],
)
model = build_tile_graph_model(
source,
inference=inference,
analysis=analyze_source(source, seed=5, device="cpu", include_clusters=False),
device="cpu",
)
assert model.candidate_rgba.shape[0] > 0
assert model.model_device == "cpu"
def test_tile_graph_candidates_use_literal_source_pixel_colors() -> None:
source = np.zeros((8, 8, 4), dtype=np.float32)
source[..., 3] = 1.0