annotating with checks : support sinle file
This commit is contained in:
@@ -198,7 +198,7 @@ def process_student(args):
|
||||
c.drawImage(temp_img_path, 0, 0, width=w, height=h)
|
||||
c.save()
|
||||
|
||||
print("Debug : size", w, h)
|
||||
# print("Debug : size", w, h)
|
||||
# Ancien code, avec du drift
|
||||
# concat_img.save(os.path.join(output_dir, "Concat.pdf"), "PDF", resolution=DPI)
|
||||
# concat_img.save(os.path.join(output_dir, "Reference.png"))
|
||||
@@ -209,12 +209,34 @@ def process_student(args):
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python annotating_with_checks.py <Dir>")
|
||||
print("Usage: python annotating_with_checks.py <Dir> or <File>")
|
||||
sys.exit(1)
|
||||
|
||||
root_dir = sys.argv[1]
|
||||
input_path = sys.argv[1]
|
||||
target_id = None
|
||||
|
||||
# Detect if input is a specific file
|
||||
if os.path.isfile(input_path):
|
||||
root_dir = os.path.dirname(input_path) or "."
|
||||
# Extract ID from filename (e.g., Copie40.pdf -> 40)
|
||||
match = re.search(r'Copie(\d+)', os.path.basename(input_path))
|
||||
if match:
|
||||
target_id = match.group(1)
|
||||
else:
|
||||
print("Error: Could not extract student ID from filename.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
root_dir = input_path
|
||||
|
||||
results = annotating.make_dictionary(root_dir)
|
||||
|
||||
# Filter results if a specific target ID was requested
|
||||
if target_id:
|
||||
if target_id in results:
|
||||
results = {target_id: results[target_id]}
|
||||
else:
|
||||
print(f"Student ID {target_id} not found in directory scan.")
|
||||
results = {}
|
||||
|
||||
tasks = [(root_dir, sid, lbls) for sid, lbls in results.items()]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user