usmanyousaf commited on
Commit
a354097
·
verified ·
1 Parent(s): ce93d33

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +10 -2
main.py CHANGED
@@ -9,8 +9,16 @@ import numpy as np
9
  # Initialize FastAPI app
10
  app = FastAPI()
11
 
12
- # Inform pytesseract where Tesseract is installed
13
- pytesseract.pytesseract.tesseract_cmd = "/usr/local/bin/tesseract"
 
 
 
 
 
 
 
 
14
 
15
  # Serve static files (images, etc.)
16
  # app.mount("/static", StaticFiles(directory="static"), name="static") # Not needed if you're not saving the images
 
9
  # Initialize FastAPI app
10
  app = FastAPI()
11
 
12
+ import subprocess
13
+
14
+ def install_tesseract():
15
+ try:
16
+ subprocess.run(['apt-get', 'update'], check=True)
17
+ subprocess.run(['apt-get', 'install', '-y', 'tesseract-ocr'], check=True)
18
+ except subprocess.CalledProcessError as e:
19
+ print(f"Error installing Tesseract: {e}")
20
+
21
+ install_tesseract()
22
 
23
  # Serve static files (images, etc.)
24
  # app.mount("/static", StaticFiles(directory="static"), name="static") # Not needed if you're not saving the images