mirror of
https://github.com/KrisKennaway/ii-pix.git
synced 2024-06-07 15:46:54 +00:00
Add a --show-final-score to output the final image quality score.
This is useful when used as part of an image repository build pipeline, to avoid replacing existing images if the new score is higher. Hide intermediate output behind --verbose
This commit is contained in:
parent
0036ee9522
commit
9a77af37aa
10
convert.py
10
convert.py
|
@ -143,7 +143,6 @@ class ClusterPalette:
|
|||
|
||||
outer_iterations_since_improvement = 0
|
||||
while outer_iterations_since_improvement < max_outer_iterations:
|
||||
print("New iteration")
|
||||
inner_iterations_since_improvement = 0
|
||||
self._palette_lines = self._init_palette_lines()
|
||||
|
||||
|
@ -336,6 +335,10 @@ def main():
|
|||
help='Whether to save a .PNG rendering of the output image (default: '
|
||||
'True)'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--show-final-score', type=bool, default=False,
|
||||
help='Whether to output the final image quality score (default: False)'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
if args.lookahead < 1:
|
||||
parser.error('--lookahead must be at least 1')
|
||||
|
@ -382,7 +385,7 @@ def main():
|
|||
palettes_rgb12_iigs, palettes_linear_rgb) in cluster_palette.iterate(
|
||||
penalty, inner_iterations, outer_iterations):
|
||||
|
||||
if total_image_error is not None:
|
||||
if args.verbose and total_image_error is not None:
|
||||
print("Improved quality +%f%% (%f)" % (
|
||||
(1 - new_total_image_error / total_image_error) * 100,
|
||||
new_total_image_error))
|
||||
|
@ -427,6 +430,7 @@ def main():
|
|||
|
||||
unique_colours = np.unique(
|
||||
palettes_rgb12_iigs.reshape(-1, 3), axis=0).shape[0]
|
||||
if args.verbose:
|
||||
print("%d unique colours" % unique_colours)
|
||||
|
||||
seq += 1
|
||||
|
@ -443,6 +447,8 @@ def main():
|
|||
with open(args.output, "wb") as f:
|
||||
f.write(bytes(screen.memory))
|
||||
|
||||
if args.show_final_score:
|
||||
print("FINAL_SCORE:", total_image_error)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue
Block a user