Skip to content

Instantly share code, notes, and snippets.

View wronk's full-sized avatar

Mark Wronkiewicz wronk

  • Southern California
View GitHub Profile
@wronk
wronk / TF_servingPost_inference_payload.py
Created February 13, 2019 19:38
TF Serving blog post: sending payloads for inference
import json
import base64
import requests
# Modify the name of your model (`hv_grid` here) to match what you used in Section 2
server_endpoint = 'http://localhost:8501/v1/models/hv_grid:predict'
img_fpaths = ['path/to/my_image_1.png', 'path/to/my_image_2.png']
# Load and Base64 encode images
data_samples = []
@wronk
wronk / TF_servingPost_payload_format.json
Created February 13, 2019 19:40
TF Serving blog post: json payload example format
{
"instances": [
{
"image_bytes": {"b64": "iVBO...Oxs6"}
},
{
"image_bytes": {"b64": "0KGg...Pyg8"}
},
{
"image_bytes": {"b64": "AABr...EKA0"}
@wronk
wronk / TF_servingPost_send_inference_payload.py
Created February 13, 2019 19:42
TF Serving blog post: sending payload
# Send prediction request
r = requests.post(server_endpoint, data=payload)
print(json.loads(r.content)['predictions'])
@wronk
wronk / TF_servingPost_export_estimator_2.py
Created February 13, 2019 21:34
TF Serving blog post: export estimator after directory reorg
# The below function will be renamed to `estimator.export_saved_model` in TF 2.0
estimator.export_savedmodel(export_dir, serving_input_receiver_fn=serving_input_receiver_fn)