Miscs changes (Interro22)
This commit is contained in:
+10
-5
@@ -263,7 +263,11 @@ def process_copy_group(group_key, files):
|
||||
|
||||
print(f"[{group_key}] Processing {image_file.name} with {len(accumulated_labels)} accumulated labels...")
|
||||
|
||||
for attempt in range(2):
|
||||
attempt = -1
|
||||
while True:
|
||||
attempt += 1
|
||||
if attempt > 0:
|
||||
time.sleep(10 * attempt)
|
||||
try:
|
||||
contents, config = generate_request(image_file, labels_txt, names_txt, accumulated_labels)
|
||||
|
||||
@@ -278,15 +282,16 @@ def process_copy_group(group_key, files):
|
||||
name = annota.name
|
||||
if unknown:
|
||||
print(f"Error: {image_file.name} contained unknown labels: {unknown}")
|
||||
if attempt == 0:
|
||||
print("Retrying request...")
|
||||
continue # Retry immediately
|
||||
print("Retrying request...")
|
||||
continue # Retry immediately
|
||||
|
||||
if name not in valid_names_set:
|
||||
print(f"Error: {image_file.name} returned unknown name : {name}")
|
||||
if attempt == 0:
|
||||
print("Retrying request...")
|
||||
continue # Retry immediately
|
||||
else:
|
||||
name = "Unknown"
|
||||
|
||||
# Save result
|
||||
with open(output_json, "w", encoding="utf-8") as f:
|
||||
@@ -305,7 +310,7 @@ def process_copy_group(group_key, files):
|
||||
|
||||
# Run ThreadPool on GROUPS (Copies), not individual files
|
||||
# Each thread handles one student's full exam copy sequentially
|
||||
with ThreadPoolExecutor(max_workers=8) as executor:
|
||||
with ThreadPoolExecutor(max_workers=12) as executor:
|
||||
# Convert dict items to arguments for map
|
||||
# executor.map expects a function and an iterable.
|
||||
# We use a lambda or separate function to unpack the tuple if needed,
|
||||
|
||||
Reference in New Issue
Block a user