Add an `empty-answer' error type and remove images in this case.
This commit is contained in:
+10
-4
@@ -270,7 +270,8 @@ def render_score_text(label, score, error, width_px, fontsize=18,
|
||||
def compose_label_image(base_img, label, result, hmin,
|
||||
render_fn=render_latex_text,
|
||||
draw_callback=None,
|
||||
with_error=True):
|
||||
with_error=True,
|
||||
with_empty=False):
|
||||
"""
|
||||
Composes the final image with annotations.
|
||||
|
||||
@@ -287,6 +288,10 @@ def compose_label_image(base_img, label, result, hmin,
|
||||
error = result.get('error', "")
|
||||
feedbacks = result.get('feedback', [])
|
||||
|
||||
if error == "empty-answer" and not with_empty:
|
||||
return None, 0
|
||||
|
||||
|
||||
# Filter deleted items (used by reading_annotations.py)
|
||||
feedbacks = [f for f in feedbacks if "to_delete" not in f]
|
||||
|
||||
@@ -436,12 +441,13 @@ def process_student(student_id, labels_data, root_dir, all_labels, overwrite):
|
||||
score = result.get('score', 0)
|
||||
d_notes[label] = str(score)
|
||||
|
||||
final_img, _ = compose_label_image(base_img, label, result, coordinates[0])
|
||||
|
||||
final_img, _ = compose_label_image(base_img, label, result, coordinates[0],
|
||||
with_empty=True)
|
||||
# 7. Save Image
|
||||
save_path = os.path.join(output_dir, f"{label}.jpg")
|
||||
final_img.save(save_path)
|
||||
label_images.append(final_img)
|
||||
if result.get('error', "") != "empty-answer":
|
||||
label_images.append(final_img)
|
||||
|
||||
# Save scores
|
||||
with open(os.path.join(output_dir, "score.json"), "w") as f:
|
||||
|
||||
Reference in New Issue
Block a user