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

[Article request] Chalice with TF Serving payload format #30

Open
austinmw opened this issue Jan 22, 2019 · 0 comments
Open

[Article request] Chalice with TF Serving payload format #30

austinmw opened this issue Jan 22, 2019 · 0 comments

Comments

@austinmw
Copy link

austinmw commented Jan 22, 2019

Hi, I've followed along with your Medium article successfully. I've also done this sagemaker tutorial: tensorflow_bring_your_own/tensorflow_bring_your_own.ipynb. The format required to send an image to the TF Serving RESTful endpoint in this tutorial is:

import json
import numpy as np
from PIL import Image
img_path = './img.jpg'
image = np.asarray(Image.open(img_path)).astype(np.float32)
image = np.expand_dims(image, axis=0)
data = {'instances': image}
data = json.dumps({k: _ndarray_to_list(v) for k, v in six.iteritems(data)}) # or sagemaker.predictor.json_serializer
request_args = {}
request_args['Body'] = data
request_args['EndpointName'] = 'my-endpoint-name'
request_args['ContentType'] = 'application/json'
request_args['Accept'] = 'application/json'
response = sagemaker_session.sagemaker_runtime_client.invoke_endpoint(**request_args)

I'm struggling to figure out how I can send either a jpg or image as numpy array to Chalice in order to preprocess the image into this format required for TF serving. Any chance you might be able to help?

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

1 participant