最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - FastAPI using tesseract-ocr works fine in localhost Mac but not in DigitalOcean Linux server - Stack Overflow

programmeradmin2浏览0评论

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.
Add a comment  | 

1 Answer 1

Reset to default 0

ISSUE 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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论