Google Cloud Vision API error "Invalid language hints."

498 Views Asked by At

I am using vision api to extract text (document_text_detection) in my project for last two year and never faced this issue. Since yesterday the api is randomly responding with the error :

{ code: 3 message: "Invalid language hints." }

for the same image. I experimented with bunch of images, sometimes the api extracts text fine and sometimes throws "Invalid language hints" error for a same image.

I have tried updating vision api library from v1 to v2, sending language hints as 'en' still the same issue persist. I have looked into the Google documentation and checked StackOverFlow as well but unable to find any solution.

from google.cloud import vision
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = google_cred_file


vision_client = vision.ImageAnnotatorClient()
file = open(file_path,"rb")
image = vision.Image(content=file.read())

api_resp = vision_client.document_text_detection(image=image)
if api_resp.error.message:
    log.error(api_resp)
2

There are 2 best solutions below

1
On

@Manoj kumar - I tried to run code on my system with your image , I made change in one line and it executed successfully. Please find below.

enter image description here

0
On

I am part of Google Cloud Platform Support and the issue with Cloud Vision has been resolved for all affected users as of Monday, 2022-05-16 10:00 US/Pacific.

The issue is also removed from the Google Cloud Service Health page.

You may now try the Detect text Vision API Quickstart or try your own code.