Miscs fixes
parent
f16c0273bd
commit
bc59b2aeea
|
|
@ -108,7 +108,7 @@ def main():
|
||||||
all_labels = os.path.join(root_dir, "labels")
|
all_labels = os.path.join(root_dir, "labels")
|
||||||
|
|
||||||
if not os.path.exists(label_groups):
|
if not os.path.exists(label_groups):
|
||||||
print(f"Warning: Labels file '{label_groups}' not found, making it out of '{all_labels}' (do check it…)")
|
print(f"Warning: Labels file '{label_groups}' not found, making it out of '{all_labels}'")
|
||||||
if not os.path.exists(all_labels):
|
if not os.path.exists(all_labels):
|
||||||
print(f"Error: {all_labels} not found.")
|
print(f"Error: {all_labels} not found.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ def tprint(*args, **kwargs):
|
||||||
thread_logs[tid] = []
|
thread_logs[tid] = []
|
||||||
thread_logs[tid].append(msg)
|
thread_logs[tid].append(msg)
|
||||||
|
|
||||||
Optional: Keep printing to console but prefix with thread name
|
# Optional: Keep printing to console but prefix with thread name
|
||||||
print(f"[{tid}] {msg}", **kwargs)
|
print(f"[{tid}] {msg}", **kwargs)
|
||||||
|
|
||||||
def flush_thread_log(tid=None):
|
def flush_thread_log(tid=None):
|
||||||
|
|
@ -192,7 +192,7 @@ def flush_thread_log(tid=None):
|
||||||
tid = tid or threading.current_thread().name
|
tid = tid or threading.current_thread().name
|
||||||
with log_lock:
|
with log_lock:
|
||||||
if thread_logs.get(tid):
|
if thread_logs.get(tid):
|
||||||
with open("correction_log", "a", encoding="utf-8") as f:
|
with open(Path(INPUT_DIR) / "correction_log", "a", encoding="utf-8") as f:
|
||||||
f.write(f"--- Task Log [{tid}] ---\n")
|
f.write(f"--- Task Log [{tid}] ---\n")
|
||||||
f.write("\n".join(thread_logs[tid]) + "\n\n")
|
f.write("\n".join(thread_logs[tid]) + "\n\n")
|
||||||
thread_logs[tid].clear()
|
thread_logs[tid].clear()
|
||||||
|
|
@ -313,7 +313,7 @@ def call_gemini_with_retries(model_id, contents, config,
|
||||||
|
|
||||||
# Immediately fallback to Flash without waiting if it's a Pro quota error
|
# Immediately fallback to Flash without waiting if it's a Pro quota error
|
||||||
if is_quota_error and model_id == MODEL_ID_pro and fallback_model_id:
|
if is_quota_error and model_id == MODEL_ID_pro and fallback_model_id:
|
||||||
tprint(f"\tGemini Pro quota hit ({e}). Falling back to Flash permanently...")
|
tprint(f"\tGemini Pro quota hit ({e}). \n\n\tFalling back to Flash permanently...")
|
||||||
model_id = fallback_model_id
|
model_id = fallback_model_id
|
||||||
pro_quota_exhausted = True
|
pro_quota_exhausted = True
|
||||||
continue # Retry immediately with Flash
|
continue # Retry immediately with Flash
|
||||||
|
|
@ -591,7 +591,7 @@ def process_single_task(task_tuple):
|
||||||
yming, ymaxg, width_r = d_data[pid]
|
yming, ymaxg, width_r = d_data[pid]
|
||||||
|
|
||||||
pdf_path = Path(INPUT_DIR) / f"Copie{pid}" / f"{label}.pdf"
|
pdf_path = Path(INPUT_DIR) / f"Copie{pid}" / f"{label}.pdf"
|
||||||
if !can_spawn_tasks and res["error"] == "additional-answer":
|
if (not can_spawn_tasks) and res["error"] == "additional-answer":
|
||||||
tprint("\tSwallowing an additional-answer from a subsequent task.")
|
tprint("\tSwallowing an additional-answer from a subsequent task.")
|
||||||
res["error"]= ""
|
res["error"]= ""
|
||||||
if res["error"] != "":
|
if res["error"] != "":
|
||||||
|
|
@ -602,7 +602,7 @@ def process_single_task(task_tuple):
|
||||||
|
|
||||||
needs_correction = []
|
needs_correction = []
|
||||||
for (i,f) in enumerate(res["feedback"]):
|
for (i,f) in enumerate(res["feedback"]):
|
||||||
b = f["box_2d"]
|
b = f.get("box_2d")
|
||||||
if b:
|
if b:
|
||||||
ymin, xmin, ymax, xmax = b
|
ymin, xmin, ymax, xmax = b
|
||||||
ymin = ymin * total_height // 1000
|
ymin = ymin * total_height // 1000
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue