I need to run Azure Computer Vision on an image via a URL. The URL can only be accessed via a VPN. I'm connected to the VPN when I run this.
im = Image.open(requests.get(path, stream=True).raw)
buffer = io.BytesIO()
im.save(buffer, 'jpeg')
buffer.seek(0)
image = buffer
results = computervision_client.read_in_stream(image, raw=True)
object_results = computervision_client.detect_objects_in_stream(image, raw=True)
operation_location_local = results.headers["Operation-Location"]
operation_id_local = operation_location_local.split("/")[-1]
I get the following error:
Traceback (most recent call last):
File "path of above code", line 505, in url_detector
object_results = computervision_client.detect_objects_in_stream(image, raw=True)
File "c:\snip\azure\cognitiveservices\vision\computervision\operations\_computer_vision_cl
ient_operations.py", line 1263, in detect_objects_in_stream
raise models.ComputerVisionErrorResponseException(self._deserialize, response)
azure.cognitiveservices.vision.computervision.models._models_py3.ComputerVisionErrorResponseException: (InvalidRequest) Input data is not a valid image.
The problem arises only with detect_objects_in_stream, read_in_stream works perfectly. Where am I going wrong?
I've tried using the im object too. I cannot pass the URL path directly in my case.