Score more right on annotating, and ID at the left.
This commit is contained in:
+19
-5
@@ -301,7 +301,7 @@ def color(score):
|
||||
|
||||
def render_score_text(label, score, error, width_px, fontsize=18,
|
||||
bg_color=(255, 255, 255, 255),
|
||||
with_error=True):
|
||||
with_error=True, id=None):
|
||||
# 1. Calculate Color Gradient
|
||||
|
||||
# 2. Build highlight-text String & Properties
|
||||
@@ -313,6 +313,9 @@ def render_score_text(label, score, error, width_px, fontsize=18,
|
||||
score_str += f" <{error}>"
|
||||
hl_props.append({"color": "orange", "fontweight": "bold"})
|
||||
|
||||
if id:
|
||||
score_str = f"{id} " + score_str
|
||||
|
||||
# 3. Wrap Text
|
||||
dpi = 100
|
||||
fig_width = width_px / dpi
|
||||
@@ -353,7 +356,9 @@ def compose_label_image(base_img, label, result, hmin,
|
||||
render_fn=render_latex_text,
|
||||
draw_callback=None,
|
||||
with_error=True,
|
||||
with_empty=False):
|
||||
with_empty=False,
|
||||
more_right=False,
|
||||
with_id=None):
|
||||
"""
|
||||
Composes the final image with annotations.
|
||||
|
||||
@@ -384,8 +389,13 @@ def compose_label_image(base_img, label, result, hmin,
|
||||
# 1. Prepare Headers
|
||||
header_elements = []
|
||||
|
||||
img_score = render_score_text(label, score, error, base_img.width // 2,
|
||||
fontsize=18, with_error=with_error)
|
||||
if more_right:
|
||||
width = base_img.width // 2
|
||||
else:
|
||||
width = base_img.width // 2 - 150
|
||||
img_score = render_score_text(label, score, error, width,
|
||||
fontsize=18, with_error=with_error,
|
||||
id=with_error)
|
||||
header_elements.append({"type": "score", "img": img_score, "data": result})
|
||||
|
||||
# Global Feedbacks
|
||||
@@ -405,7 +415,11 @@ def compose_label_image(base_img, label, result, hmin,
|
||||
draw = ImageDraw.Draw(final_img, "RGBA")
|
||||
|
||||
for el in header_elements:
|
||||
final_img.paste(el["img"], (0, current_y))
|
||||
if el["type"] == "score" and more_right:
|
||||
final_img.paste(el["img"], (150, current_y))
|
||||
else:
|
||||
final_img.paste(el["img"], (0, current_y))
|
||||
|
||||
|
||||
if draw_callback:
|
||||
# Hook for checkboxes
|
||||
|
||||
Reference in New Issue
Block a user