input_path = os.path.join(root, file_name)
output_path = os.path.join(root, file_name.replace('.', '_ocr.'))
- # Perform OCR on the image
- text = ocr_image(ocr, input_path)
-
+ text = None
+ if os.path.exists(output_path):
+ print(f'{output_path} exists.')
+ else:
+ # Perform OCR on the image
+ text = ocr_image(ocr, input_path)
if text:
# Write the OCR result to a JSON file
json_output_path = output_path.rsplit('.', 1)[0] + '.json'