Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
ipitio committed Oct 9, 2024
1 parent 6dac7df commit 7cf2c54
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ def predict(input_file: Path, output_file: Path):
doc.insert_pdf(fitz.open("pdf", prediction))
gc.collect()

# Save the OCR results to a new PDF file
doc.save(output_file, garbage=4, deflate=True)
doc.close()
input_file.unlink()
print(f"Processed {relative_path}")
try:
input_file.unlink()
finally:
# Save the OCR results to a new PDF file
doc.save(output_file, garbage=4, deflate=True)
doc.close()
print(f"Processed {relative_path}")

Parallel(n_jobs=-1)(
delayed(predict)(Path(root) / file, Path(root.replace("todo", "done")) / file)
Expand Down

0 comments on commit 7cf2c54

Please sign in to comment.