From 428692f6c81859c38ab7593a117a8986f5f44917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= Date: Mon, 4 May 2026 14:13:48 +0200 Subject: [PATCH] Yellow labels, and injected error for new spawned tasks. --- Readme.org | 6 +++--- correction.py | 12 +++++++++++- plotting.py | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Readme.org b/Readme.org index 77727b4..8c984cd 100644 --- a/Readme.org +++ b/Readme.org @@ -1,7 +1,7 @@ #+title: Script #+author: Sébastien Miquel #+date: 14-03-2026 -# Time-stamp: <01-05-26 22:35> +# Time-stamp: <02-05-26 13:44> #+OPTIONS: * Quézaco @@ -252,8 +252,8 @@ groupée into refaire !! + =python plotting.py InterroTest/Copie01.pdf= + =python splitting_int.py InterroTest/Copie20.pdf= 2. Créer =refaire.json=, avec un contenu comme - [["Copie01", []], - ["Copie01", ["Ex 1 : 1)"]]] + : [["Copie01", []], + : ["Copie01", ["Ex 1 : 1)"]]] 3. Appeler =correction= avec --refaire. Il doit créer des groupes individuels, faire des requêtes, et remplacer les corrections précédentes (à sauver ailleurs). diff --git a/correction.py b/correction.py index deaf78c..620fb58 100644 --- a/correction.py +++ b/correction.py @@ -582,7 +582,7 @@ Here is a list of all possible labels. You need to answer with a list one of the height = grouping.get_pdf_height(str(new_pdf_path)) grouping.create_jpg(add_label, idx, [(pid, str(new_pdf_path), height)], INPUT_DIR) new_tasks.append((str(Path(INPUT_DIR) / add_label / f"Group_{idx+1}.jpg"), - add_label, False)) + add_label, False, f"{label}(->)")) error += f"(->){add_label}" keep_error = True else: @@ -603,6 +603,7 @@ def process_single_task(task_tuple, precomputed_response=None): file_path = task_tuple[0] label = task_tuple[1] can_spawn_tasks = task_tuple[2] if len(task_tuple) > 2 else True + injected_error = task_tuple[3] if len(task_tuple) > 3 else "" group_name = os.path.splitext(file_path)[0] json_path = group_name + '.json' @@ -648,6 +649,15 @@ def process_single_task(task_tuple, precomputed_response=None): for p in json_data: pid = p["id"] res = p["result"] + + # Inject additional error if present + if injected_error: + if res["error"]: + res["error"] = f"{injected_error} {res['error']}" + else: + res["error"] = injected_error + + yming, ymaxg, width_r = d_data[pid] pdf_path = Path(INPUT_DIR) / f"Copie{pid}" / f"{label}.pdf" diff --git a/plotting.py b/plotting.py index db2f092..ab7b203 100644 --- a/plotting.py +++ b/plotting.py @@ -79,6 +79,8 @@ def prepare_image(image_path: str, bounding_boxes, all_labels, nb_pages, last_la current_index = all_labels.index(label) if current_index < last_label_index or (last_label_index == -1 and current_index != 0): color = "red" + elif current_index > last_label_index + 1: + color = "yellow" last_label_index = current_index draw.rectangle(((abs_x_min, abs_y_min), (abs_x_max, abs_y_max)), outline=color, width=4)