Small fixes ; Make annotating not threaded

This commit is contained in:
2026-02-28 15:02:32 +01:00
parent be390cfbb1
commit e610c80a69
4 changed files with 56 additions and 35 deletions
+5 -10
View File
@@ -254,9 +254,9 @@ def process_single_task(task_tuple):
d_data = {l[0]: (l[1], l[2], l[3]) for l in group_data}
total_height = group_data[-1][2]
use_flash = n >= 4 or total_height <= 500
if not use_flash and limit is not None:
if not use_flash:
with pro_lock:
if pro_count < limit:
if limit is None or pro_count < limit:
pro_count += 1
else:
# Limit reached, force switch to Flash
@@ -268,9 +268,9 @@ def process_single_task(task_tuple):
try:
contents, config = generate_request(file_path, label)
if use_flash:
print(f"Asking Flash Gemini: {label} {file_path}")
print(f"Asking Gemini Flash: {label} {group_name}")
else:
print(f"Asking Gemini: {label} {file_path}")
print(f"Asking Gemini Pro : {label} {group_name}")
full_response_text = ""
# Assuming client is thread-safe (usually is).
@@ -286,18 +286,13 @@ def process_single_task(task_tuple):
# Parse JSON
json_data = json.loads(full_response_text)
if use_flash:
print(f"Gemini Flash answered for {file_path}")
else:
print(f"Gemini answered for {file_path}")
# print("Debug : ", json_data)
# Ensure consistency of answer placements
for p in json_data:
pid = p["id"]
res = p["result"]
if res["error"] != "":
print("Error :", res["error"], "for Copie", pid, label, group_name)
print("\tError :", res["error"], "for Copie", pid, label, group_name)
for f in res["feedback"]:
b = f["box_2d"]
if b: