About PYTESSERACT (text OCR) in SPACE

#1
by JackWrion - opened

Help me, my app cannot use PYTESSERACT.

I deployed my app using PYTESSERACT to regconition text from image. Although I can run it on my own laptop win10, but it doesn't work on SPACE.
Here is my SPACE: https://huggingface.co/spaces/JackWrion/OCR

I included the "TESSERACT-OCR" folder in space for called by APP.PY.
In line 6 : pytesseract.pytesseract.tesseract_cmd = r'./Tesseract-OCR/tesseract.exe'

And the error:

Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/gradio/routes.py", line 437, in run_predict
output = await app.get_blocks().process_api(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1352, in process_api
result = await self.call_function(
File "/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1077, in call_function
prediction = await anyio.to_thread.run_sync(
File "/home/user/.local/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/home/user/.local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/home/user/.local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/home/user/app/app.py", line 32, in TextLineBox
texttest = pytesseract.image_to_string(img ,config=configname)
File "/home/user/.local/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 423, in image_to_string
return {
File "/home/user/.local/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 426, in
Output.STRING: lambda: run_and_get_output(*args),
File "/home/user/.local/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 288, in run_and_get_output
run_tesseract(**kwargs)
File "/home/user/.local/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 255, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "/usr/local/lib/python3.10/subprocess.py", line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/lib/python3.10/subprocess.py", line 1863, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: './Tesseract-OCR/tesseract.exe'

great I see you've solved that,
Tesseract-OCR/tesseract.exe' is only for a windows platform

here is a full functional example os Spaces Linux https://huggingface.co/spaces/radames/hello-pytesseract

Sign up or log in to comment