This file contains hidden or 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 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 = [] |
This file contains hidden or 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
| { | |
| "instances": [ | |
| { | |
| "image_bytes": {"b64": "iVBO...Oxs6"} | |
| }, | |
| { | |
| "image_bytes": {"b64": "0KGg...Pyg8"} | |
| }, | |
| { | |
| "image_bytes": {"b64": "AABr...EKA0"} |
This file contains hidden or 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
| # Send prediction request | |
| r = requests.post(server_endpoint, data=payload) | |
| print(json.loads(r.content)['predictions']) |
This file contains hidden or 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
| # 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) |
OlderNewer