Spaces:
Sleeping
Sleeping
File size: 1,963 Bytes
2cf467c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | """Global parameters for layout optimization."""
# Optimization resolution stages
OPT_RES_LIST = (1000,) # Reduced from (256, 512, 1000) for faster optimization
# Augmented Lagrangian parameters
OUTER_ROUNDS = 8 # augmented-lagrangian outer updates per stage (reduced from 5 for faster convergence)
INNER_STEPS = 30 # gradient steps per outer round (reduced from 50 for faster convergence)
RHO_INIT = 1e-4 # initial penalty parameter for constraint enforcement
RHO_MULT = 5.0 # multiplier for penalty parameter
# Optimizer parameters
LEARNING_RATE = 0.02
SIZE_MIN = 20.0 # minimum element size in pixels
# Penalty weights
PEN_WEIGHT = 1000.0 # weight for penetration penalty
PEN_ETA_PX = 1.0 # eta parameter for penetration penalty
# Loss weights
W_SIMILARITY = 0 # weight for position/size similarity loss
W_READABILITY = 0 # weight for readability loss (size hierarchy)
W_ALIGNMENT_CONSISTENCY = 10000.0 # weight for alignment consistency loss (hierarchical alignment)
W_ALIGNMENT_SIMILARITY = 0 # weight for alignment similarity loss (based on JSON constraint)
W_DATA_INK = 10 # weight for data ink loss (maximize union area, minimize white space)
W_VISUAL_BALANCE = 0.0 # weight for visual balance loss (centroid to center distance)
# Tau schedule for soft mask (controls boundary sharpness)
TAU_SCHEDULE = (2.0, 1.5, 1.2, 1.0, 0.8, 0.6, 0.5, 0.4, 0.35, 0.3, 0.25, 0.2)
# Pictogram dilation radius
PICTOGRAM_DILATION_RADIUS = 5.0 # pixels
# Readability threshold
SIZE_RATIO_THRESHOLD = 1.5 # minimum ratio to consider size difference significant
# Rules: if ratio >= 1.5 or ratio <= 1/1.5 (0.67), the size difference is significant
# Min size constraints (default values)
MIN_WIDTH_DEFAULT = 30.0
MIN_HEIGHT_DEFAULT = 30.0
# Proximity ratio loss parameters
W_PROXIMITY = 0 # Weight for proximity ratio loss (default disabled, can be enabled when needed)
PROXIMITY_EPSILON = 1e-6 # Small value to avoid division by zero
|