I am trying to run a PoC for extracting text from an image file using tesseract-ocr in a FastAPI python code file installed in a DigitalOcean FARM Linux droplet and I get an error, while running the same code in my local Mac environment works fine.
The code I am using is:
from fastapi import FastAPI, Request, HTTPException
from PIL import Image
import pytesseract
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
@app.get("/parseimgfile")
async def parseimage():
try:
res = pytesseract.image_to_string("sample.png", lang="grc")
return (res)
except Exception as e:
return(e)
When I call it locally in my Mac everything works fine. But when I call it from a DigitalOcean Linux server where I have installed a FARM droplet, after sometime I get the following error:
Failed to fetch.
Possible Reasons:
CORS
Network Failure
URL scheme must be "http" or "https" for CORS request.
In simple API calls works ok. Also when I run the following command on the server it works also fine so the module is installed ok.
tesseract sample.png out -l grc
I am trying to run a PoC for extracting text from an image file using tesseract-ocr in a FastAPI python code file installed in a DigitalOcean FARM Linux droplet and I get an error, while running the same code in my local Mac environment works fine.
The code I am using is:
from fastapi import FastAPI, Request, HTTPException
from PIL import Image
import pytesseract
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
@app.get("/parseimgfile")
async def parseimage():
try:
res = pytesseract.image_to_string("sample.png", lang="grc")
return (res)
except Exception as e:
return(e)
When I call it locally in my Mac everything works fine. But when I call it from a DigitalOcean Linux server where I have installed a FARM droplet, after sometime I get the following error:
Failed to fetch.
Possible Reasons:
CORS
Network Failure
URL scheme must be "http" or "https" for CORS request.
In simple API calls works ok. Also when I run the following command on the server it works also fine so the module is installed ok.
tesseract sample.png out -l grc
Share
Improve this question
asked yesterday
Panos KontopoulosPanos Kontopoulos
111 bronze badge
New contributor
Panos Kontopoulos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1 Answer
Reset to default 0ISSUE RESOLVED.
It seems that the Linux server I tried to deployed to needed to be enhanced in CPUs and Memory, tessaract has significant needs of resources.
I increased the droplet in 4 Dedicated CPUs and 8GB RAM and it worked fine.
However I need to work on a queueing solution to manage multiple concurrent OCR jobs.