Skip to content

Commit 5887995

Browse files
Update app.py
1 parent f1d082c commit 5887995

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
#Added for script detection functionality by using script.tessdata on streamlit cloud
1313
import os
1414
import urllib.request
15+
import pytesseract
16+
# Use `/tmp/tessdata` (writable directory)
17+
tessdata_dir = "/tmp/tessdata"
18+
os.makedirs(tessdata_dir, exist_ok=True) # This should now work
1519

16-
tessdata_dir = "/app/tessdata" # Streamlit Cloud's writable directory
17-
os.makedirs(tessdata_dir, exist_ok=True)
18-
19-
# Download traineddata file if it doesn't exist
20+
#To Download traineddata if not present
2021
traineddata_path = os.path.join(tessdata_dir, "script.traineddata")
2122
if not os.path.exists(traineddata_path):
2223
urllib.request.urlretrieve("URL_TO_SCRIPT.TRAINEDDATA", traineddata_path)
2324

24-
# Set Tesseract to use this tessdata folder
25-
os.environ["TESSDATA_PREFIX"] = tessdata_dir
25+
# Set Tesseract environment variable
26+
os.environ["TESSDATA_PREFIX"] = "/tmp/"
2627
config = f"--tessdata-dir {tessdata_dir}"
2728

2829
# Below remains the same

0 commit comments

Comments
 (0)