wallpaper: tweak again scoring

This commit is contained in:
Vincent Bernat 2024-08-15 18:59:12 +02:00
parent 4a685dd932
commit b5a27b0a17

View file

@ -234,8 +234,8 @@ def get_best_parts(
groups: set[tuple[Rectangle, ...]], groups: set[tuple[Rectangle, ...]],
images: list[Image], images: list[Image],
ratio_score: int = 100, ratio_score: int = 100,
scale_score: int = 5, scale_score: int = 10,
wallpaper_score: int = 2, multiple_wallpaper_score: int = -50,
) -> Optional[list[WallpaperPart]]: ) -> Optional[list[WallpaperPart]]:
"""Find optimal association for images for the groups of covering rectangles. """Find optimal association for images for the groups of covering rectangles.
@ -309,7 +309,7 @@ def get_best_parts(
if r >= 1: if r >= 1:
r = 1 r = 1
score += r * scale_score score += r * scale_score
score /= pow(len(group), wallpaper_score) score += (len(group) - 1) * multiple_wallpaper_score
logger.debug("association: %s, score %.2f", association_, score) logger.debug("association: %s, score %.2f", association_, score)
if score > best_score or best_association is None: if score > best_score or best_association is None:
best_association = association_ best_association = association_
@ -390,9 +390,9 @@ if __name__ == "__main__":
help="multiplicative weight applied to pixel matching for score", help="multiplicative weight applied to pixel matching for score",
) )
group.add_argument( group.add_argument(
"--wallpaper-score", "--multiple-wallpaper-score",
default=params["wallpaper_score"].default, default=params["multiple_wallpaper_score"].default,
help="invert power weight applied to the number of wallpapers used", help="additive weight for each additional wallpaper used",
) )
group = parser.add_argument_group("image output") group = parser.add_argument_group("image output")
group.add_argument( group.add_argument(
@ -435,7 +435,7 @@ if __name__ == "__main__":
images, images,
ratio_score=options.ratio_score, ratio_score=options.ratio_score,
scale_score=options.scale_score, scale_score=options.scale_score,
wallpaper_score=options.wallpaper_score, multiple_wallpaper_score=options.multiple_wallpaper_score,
) )
assert wallpaper_parts is not None assert wallpaper_parts is not None
for part in wallpaper_parts: for part in wallpaper_parts: