File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 1212#Added for script detection functionality by using script.tessdata on streamlit cloud
1313import os
1414import 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
2021traineddata_path = os .path .join (tessdata_dir , "script.traineddata" )
2122if 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/"
2627config = f"--tessdata-dir { tessdata_dir } "
2728
2829# Below remains the same
You can’t perform that action at this time.
0 commit comments