Skip to content

Instantly share code, notes, and snippets.

@zldrobit
Created December 29, 2018 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zldrobit/341115918cbec825d21d023cbc8a9626 to your computer and use it in GitHub Desktop.
Save zldrobit/341115918cbec825d21d023cbc8a9626 to your computer and use it in GitHub Desktop.
import base64
import requests
file = 'image.jpeg'
# predict is the method name
# /models/detection is the model path
url = 'http://localhost:8501/v1/models/detection:predict'
content = open(file, 'rb').read()
# encode binary data to b64 before json encode
content = base64.b64encode(content)
r = requests.post(url, json = {
'signature_name': 'sig_name',
'inputs': {
'images':[{"b64": content}]
}
})
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment