Skip to content

Remove response key #478

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

Merged
merged 2 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/image-classifier/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ def pre_inference(sample, metadata):


def post_inference(prediction, metadata):
classes = prediction["response"]["classes"]
return labels[np.argmax(classes)]
return labels[np.argmax(prediction["classes"])]
2 changes: 1 addition & 1 deletion examples/iris-classifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ labels = ["iris-setosa", "iris-versicolor", "iris-virginica"]


def post_inference(prediction, metadata):
label_index = int(prediction["response"]["class_ids"][0])
label_index = int(prediction["class_ids"][0])
return labels[label_index]
```

Expand Down
2 changes: 1 addition & 1 deletion examples/iris-classifier/handlers/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


def post_inference(prediction, metadata):
predicted_class_id = int(prediction["response"]["class_ids"][0])
predicted_class_id = int(prediction["class_ids"][0])
return labels[predicted_class_id]
2 changes: 1 addition & 1 deletion examples/sentiment-analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def pre_inference(sample, metadata):


def post_inference(prediction, metadata):
return labels[prediction["response"]["labels"][0]]
return labels[prediction["labels"][0]]
```

## Deploy to AWS
Expand Down
2 changes: 1 addition & 1 deletion examples/sentiment-analysis/sentiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def pre_inference(sample, metadata):


def post_inference(prediction, metadata):
return labels[prediction["response"]["labels"][0]]
return labels[prediction["labels"][0]]
2 changes: 1 addition & 1 deletion examples/text-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def pre_inference(sample, metadata):


def post_inference(prediction, metadata):
response = prediction["response"]["sample"]
response = prediction["sample"]
return {encoder.decode(response)}
```

Expand Down
2 changes: 1 addition & 1 deletion examples/text-generator/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ def pre_inference(sample, metadata):


def post_inference(prediction, metadata):
response = prediction["response"]["sample"]
response = prediction["sample"]
return {encoder.decode(response)}
6 changes: 2 additions & 4 deletions pkg/workloads/cortex/tf_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@ def run_get_model_metadata():
def parse_response_proto(response_proto):
results_dict = json_format.MessageToDict(response_proto)
outputs = results_dict["outputs"]

outputs_simplified = {}
for key in outputs.keys():
for key in outputs:
value_key = DTYPE_TO_VALUE_KEY[outputs[key]["dtype"]]
outputs_simplified[key] = outputs[key][value_key]

return {"response": outputs_simplified}
return outputs_simplified


def run_predict(sample, debug=False):
Expand Down