입출력 로직 변경
This commit is contained in:
24
model_services/deepseek_ocr/main.py
Normal file
24
model_services/deepseek_ocr/main.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import os
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Run OCR based on file type.")
|
||||
parser.add_argument("input_path", type=str, help="Path to the input file (PDF or image).")
|
||||
args = parser.parse_args()
|
||||
|
||||
input_path = args.input_path
|
||||
file_extension = os.path.splitext(input_path)[1].lower()
|
||||
|
||||
if file_extension == '.pdf':
|
||||
print(f"Detected PDF file. Running PDF OCR script for: {input_path}")
|
||||
subprocess.run(["python", "run_dpsk_ocr_pdf.py", "--input", input_path])
|
||||
elif file_extension in ['.jpg', '.jpeg', '.png', '.bmp', '.gif']:
|
||||
print(f"Detected image file. Running image OCR script for: {input_path}")
|
||||
subprocess.run(["python", "run_dpsk_ocr_image.py", "--input", input_path])
|
||||
else:
|
||||
print(f"Unsupported file type: {file_extension}")
|
||||
print("Please provide a PDF or an image file (.jpg, .jpeg, .png, .bmp, .gif).")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user