Created
January 22, 2018 06:51
-
-
Save bitchwhocodes/2b0197a8c7ef261eaf503fef2fd60f0e to your computer and use it in GitHub Desktop.
Custom Vision API Prediction - PYthon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
url="YOUR_PREDICTION_ENDPOINT _ AVAIL customvision.ai" | |
headers={'content-type':'application/octet-stream','Prediction-Key':'YOUR_PREDICTION_KEY'} | |
r =requests.post(url,data=open("YOUR_LOCAL_IMAGE.jpg","rb"),headers=headers) | |
print(r.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this gist! The Microsoft documentation for using the API with a local file is lacking when using Python and the standard requests library. I tried many different ways to loading the image to bytes and sending with different requests keywords that did not work, your method works perfectly.