MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.28k stars 21.47k forks source link

HTTPError 400 Error - Computer Vision #13658

Closed vashish76 closed 5 years ago

vashish76 commented 6 years ago

Hi

I am getting the following error

"HTTPError: 400 Client Error: Bad Request for url: https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/recognizeText?mode=Handwritten"

Appreciate if you could help in solving the above issue.

BryanTrach-MSFT commented 6 years ago

@vashish76 Can you please provide us with the doc URL that you are having issues with? We look forward to your reply.

vashish76 commented 6 years ago

Sure. following is the code..

import requests import matplotlib.pyplot as plt from matplotlib.patches import Polygon from PIL import Image from io import BytesIO

subscription_key = "ceAbdcd9a601000XXXXXXXXXXXXXX" assert subscription_key vision_base_url = "https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/" text_recognition_url = vision_base_url + "recognizeText"

image_url = r"D:\Users\Downloads\r_001.jpeg" headers = {'Ocp-Apim-Subscription-Key': subscription_key} params = {'mode': 'Handwritten'} data = {'url': image_url} response = requests.post( text_recognition_url, headers=headers, params=params, json=data) response.raise_for_status()

vashish76 commented 6 years ago

Hi Bryan Awaiting for your feedback .

Looking forward for your response and guidance

YutongTie-MSFT commented 6 years ago

@vashish76 Can you please provide which document you are referring to? Thanks a lot!

vashish76 commented 6 years ago

Hi

I am trying to read handwritten digits from the attached image

test

YutongTie-MSFT commented 6 years ago

@vashish76 Hi, I am sorry. What I mean is, when you try to do your project, which Microsoft document you are using for guidance? Please share the Microsoft document URL to me so that I can look into it. Thanks a lot.

vashish76 commented 6 years ago

Hi

Following is the MS document I am referring..

https://docs.microsoft.com/en-us/azure/cognitive-services/Computer-vision/quickstarts/python-hand-text

vashish76 commented 6 years ago

YutongTie - Any feedback to be shared. I am stuck with this so appreciate if you could advise on this issue

YutongTie-MSFT commented 6 years ago

@vashish76 Can you please check if you are using a right key of Computer Vison? Please check the following document and make sure you are using CV key. https://blogs.msdn.microsoft.com/kwill/2017/05/17/http-401-access-denied-when-calling-azure-cognitive-services-apis/

vashish76 commented 6 years ago

Hi I am not getting 401 error but 400 client error: Bad request for url

https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/recognizeText?mode=Handwritten

Do you have troubleshooting guide for it ?

vashish76 commented 6 years ago

@YutongTie-MSFT - Now I am receiving the following error after inputting right key for subscription key

HTTPError: 404 Client Error: Resource Not Found for url: https://westcentralus.api.cognitive.microsoft.com/vision/v1.0recognizeText?mode=Handwritten

Does it mean that the end point url is not accessible ? I have this endpoint mentioned in keys section

Plz suggest

YutongTie-MSFT commented 6 years ago

@vashish76 Hi, I have followed the tutorials and it works for me. And you should use V2.0 API version. 1

You can run this quickstart in a step-by step fashion using a Jupyter notebook on MyBinder according to the document: https://docs.microsoft.com/en-us/azure/cognitive-services/Computer-vision/quickstarts/python-hand-text

vashish76 commented 6 years ago

HI YutongTie - I followed the quickstart and executed the code using Jupyter notebook but still i am receiving "Bad Request for url". I am pretty sure that something is wrong with the local image that i am trying to pass to the requests.post.

Please can you check the below code and advise where I am going wrong ? Appreciate your help

image

vashish76 commented 6 years ago

@YutongTie-MSFT - Please help me in identifying the issue in the above code

YutongTie-MSFT commented 6 years ago

@vashish76 Sorry for the delay. For now, we don't support local image. You need to upload the image. Thanks.

areed145 commented 5 years ago

@YutongTie-MSFT has local image support been enabled? If not, what are the plans/timing? Thanks!

v-thepet commented 5 years ago

@vashish76 @areed145 - Thank you for taking the time to share your product and documentation feedback with us. Your input is valued because it helps us create the right documentation for our customers.

Due to the volume of issues in our queue, we are closing open issues older than 90 days. We hope to continue hearing from you. Thank you.