From 1218b157732e23562118f544864e6d90971d2ae1 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 22 Apr 2026 09:25:07 +0100 Subject: [PATCH] Tune relaxation for stronger coherence --- src/repixelizer/continuous.py | 14 +++++++------- src/repixelizer/params.py | 12 ++++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/repixelizer/continuous.py b/src/repixelizer/continuous.py index 8067b42..a144031 100644 --- a/src/repixelizer/continuous.py +++ b/src/repixelizer/continuous.py @@ -532,15 +532,15 @@ def _relax_candidate_selection( desired_delta_y, desired_delta_diag, desired_delta_anti, - orthogonal_weight=solver_params.refine_orthogonal_weight, - diagonal_weight=solver_params.refine_diagonal_weight, + orthogonal_weight=solver_params.relax_orthogonal_weight, + diagonal_weight=solver_params.relax_diagonal_weight, ) - if solver_params.refine_motif_weight > 0.0: + if solver_params.relax_motif_weight > 0.0: motif_energy = _motif_candidate_energy(torch, candidate_colors, context_colors, anchor) - final_energy = final_energy + motif_energy * solver_params.refine_motif_weight - if solver_params.refine_line_weight > 0.0: + final_energy = final_energy + motif_energy * solver_params.relax_motif_weight + if solver_params.relax_line_weight > 0.0: line_energy = _line_candidate_energy(torch, candidate_colors, context_colors, anchor) - final_energy = final_energy + line_energy * solver_params.refine_line_weight + final_energy = final_energy + line_energy * solver_params.relax_line_weight alpha = 1.0 if iterations <= 1 else step / float(iterations - 1) temperature = start_temp + (end_temp - start_temp) * alpha @@ -831,7 +831,7 @@ def _discrete_refine_output( selected, relax_history = _relax_candidate_selection( torch, candidate_colors, - anchor_energy + distance_energy * 0.05, + base_energy, anchor, desired_delta_x, desired_delta_y, diff --git a/src/repixelizer/params.py b/src/repixelizer/params.py index b3f1650..daae45a 100644 --- a/src/repixelizer/params.py +++ b/src/repixelizer/params.py @@ -22,10 +22,14 @@ class SolverHyperParams: refine_diagonal_weight: float = 0.08 refine_motif_weight: float = 0.12 refine_line_weight: float = 0.10 - relax_iterations: int = 8 - relax_start_temperature: float = 0.55 - relax_end_temperature: float = 0.10 - relax_damping: float = 0.35 + relax_iterations: int = 24 + relax_start_temperature: float = 0.95 + relax_end_temperature: float = 0.18 + relax_damping: float = 0.10 + relax_orthogonal_weight: float = 0.34 + relax_diagonal_weight: float = 0.12 + relax_motif_weight: float = 0.22 + relax_line_weight: float = 0.06 structure_boundary_weight: float = 0.60 structure_anchor_adjacency_weight: float = 0.15 structure_anchor_motif_weight: float = 0.20