I would like to post an image file using the restful sensor component, and parse the returned json. The python code for what I want is below, but note that the file in IMAGE_PATH
may change, so I would use a template to insert the IMAGE_PATH
. I am unsure how to configure this, in particular what format the overall template should take?
KERAS_REST_API_URL = "http://localhost:5000/predict"
IMAGE_PATH = "dog.jpg"
# load the input image and construct the payload for the request
image = open(IMAGE_PATH, "rb").read()
payload = {"image": image}
# submit the request
response = requests.post(KERAS_REST_API_URL, files=payload).json()
I then want to parse the response
.
If this is not possible with the resful sensor, I could use the following cURL (with the command line sensor component?), although again the IMAGE_PATH
may change and Iām unsure of the template:
curl -X POST -F [email protected] 'http://localhost:5000/predict'