Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object DeserializationError / unicode #107

Closed
jtlz2 opened this issue Jun 18, 2018 · 3 comments
Closed

Object DeserializationError / unicode #107

jtlz2 opened this issue Jun 18, 2018 · 3 comments

Comments

@jtlz2
Copy link

jtlz2 commented Jun 18, 2018

I have modified the example image_analysis_in_stream at https://github.com/Azure-Samples/cognitive-services-python-sdk-samples/blob/master/samples/vision/computer_vision_samples.py to rather carry out OCR, i.e.

with open(os.path.join(IMAGES_FOLDER, "image.jpg"), "rb") as image_stream:
        image_response = client.recognize_printed_text_in_stream(image_stream,language='en')

This gives the following Traceback:

  File "/anaconda2/lib/python2.7/site-packages/azure/cognitiveservices/vision/computervision/computer_vision_api.py", line 962, in recognize_printed_text_in_stream
    deserialized = self._deserialize('OcrResult', response)
  File "/anaconda2/lib/python2.7/site-packages/msrest/serialization.py", line 1179, in __call__
    return self._deserialize(target_obj, data)
  File "/anaconda2/lib/python2.7/site-packages/msrest/serialization.py", line 1245, in _deserialize
    value = self.deserialize_data(raw_value, attr_desc['type'])
  File "/anaconda2/lib/python2.7/site-packages/msrest/serialization.py", line 1433, in deserialize_data
    return self._deserialize(obj_type, data)
  File "/anaconda2/lib/python2.7/site-packages/msrest/serialization.py", line 1249, in _deserialize
    raise_with_traceback(DeserializationError, msg, err)
  File "/anaconda2/lib/python2.7/site-packages/msrest/exceptions.py", line 57, in raise_with_traceback
    raise error
msrest.exceptions.DeserializationError: Unable to deserialize to object: type, AttributeError: 'unicode' object has no attribute 'get

Line 962 requires a response code of 200, so can I assume image_stream is valid?

How do I then deserialize OcrResult to JSON?

Is this an API version mismatch..?

Thanks for any speedy help.

(This is a cross-posting of Azure/azure-sdk-for-python#2769)

@lmazuel
Copy link
Member

lmazuel commented Jun 21, 2018

So, that's deserialization issue, and seeing the trace you received something from the server. That something wasn't matching the expected behavior it seems.
Could you enable HTTP logs to see what you received from the server? To do that, turn on the HTTP logging (disabled by default):

client.config.enable_http_logger = True

and log using logging as usual in DEBUG mode.

I will try to see if I find time myself to reproduce it.

Edit: let's keep both issue opened until I know if it's msrest, or SDK or server.

@lmazuel
Copy link
Member

lmazuel commented Jun 21, 2018

It seems the service team did an update in the dev branch I didn't release yet:
Azure/azure-sdk-for-python#2614

That updates OCRResult. Could you try from that PR? You will find a direct wheel download from that PR, no need to use pip black magic to install from git.

@lmazuel
Copy link
Member

lmazuel commented Jun 22, 2018

After investigation, not a msrest issue but really a generated SDK. Track the fix in the SDK repo.

@lmazuel lmazuel closed this as completed Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants