Move to real LaTeX rendering

This commit is contained in:
2026-03-03 19:25:05 +01:00
parent 6222ba5dac
commit 2677e41b04
4 changed files with 119 additions and 6 deletions
+23 -1
View File
@@ -226,6 +226,7 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
# --- 2. Process Images (Cut notes, Regenerate, Concatenate) ---
concat_list = []
concat_list_F = []
d_notes = dict.fromkeys(all_labels, "")
# Iterate over images defined in bnote.json to maintain order/geometry
@@ -235,7 +236,8 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
# Update scores dict
content = labels_data[label]
d_notes[label] = str(content['result'].get('score', 0))
result = content['result']
d_notes[label] = str(result.get('score', 0))
# A. Cut Manual Notes
hmin, hmax = img_info["hmin"], img_info["hmax"]
@@ -272,6 +274,14 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
concat_list.append(final_img)
perfect_no_comment = True
if float(d_notes[label]) != 4.0:
perfect_no_comment = False
if len(result.get('feedback', [])) != 0:
perfect_no_comment = False
if not perfect_no_comment:
concat_list_F.append(final_img)
# --- 3. Save Final Outputs ---
with open(score_path, "w") as f:
json.dump(d_notes, f, indent=4)
@@ -289,6 +299,18 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
full_img.save(os.path.join(output_dir, "Concat.jpg"))
print(f" Saved regenerated Concat.jpg")
if concat_list_F:
max_w = max(i.width for i in concat_list_F)
total_h = sum(i.height for i in concat_list_F)
full_img = Image.new("RGB", (max_w, total_h), "white")
y = 0
for img in concat_list_F:
full_img.paste(img, (0, y))
y += img.height
full_img.save(os.path.join(output_dir, "Concat_F.jpg"))
print(f" Saved regenerated Concat_F.jpg")
from pathlib import Path