diff --git a/components/alibi-explain-server/alibiexplainer/server.py b/components/alibi-explain-server/alibiexplainer/server.py index 2075ba13e3..da1adf8e66 100644 --- a/components/alibi-explain-server/alibiexplainer/server.py +++ b/components/alibi-explain-server/alibiexplainer/server.py @@ -46,7 +46,7 @@ def __init__( def create_application(self): return tornado.web.Application( [ - (r"/v1/models/([a-zA-Z0-9_-]+):explain", + (r"/v1/models/([a-zA-Z0-9_-]*):explain", ExplainV2Handler, dict(model=self.registered_model)), (r"/api/v0.1/explain", ExplainHandler, dict(model=self.registered_model)), @@ -112,4 +112,3 @@ def post(self, model_name): ) response =self.model.explain(body, model_name=model_name) self.write(response) - diff --git a/doc/source/analytics/explainers.md b/doc/source/analytics/explainers.md index 2443ddd790..03ecbdf2d1 100644 --- a/doc/source/analytics/explainers.md +++ b/doc/source/analytics/explainers.md @@ -86,3 +86,4 @@ The explain method is also supported for tensorflow and v2 kfserving protocols. | kfserving | `http:////v2/models//explain` | +Note: for `tensorflow` protocol we support similar non-standard extension as for the [prediction API](../graph/protocols.md#rest-and-grpc-tensorflow-protocol), `http:////v1/models/:explain`. diff --git a/notebooks/explainer_examples.ipynb b/notebooks/explainer_examples.ipynb index b54a90c6ba..4bd48438bf 100644 --- a/notebooks/explainer_examples.ipynb +++ b/notebooks/explainer_examples.ipynb @@ -581,6 +581,27 @@ "plt.imshow(arr)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# or using non-standard seldon extension\n", + "\n", + "test_example = X_test[idx : idx + 1].tolist()\n", + "payload = '{\"instances\":' + f\"{test_example}\" + \" }\"\n", + "cmd = f\"\"\"curl -s -d '{payload}' \\\n", + " http://localhost:8003/seldon/seldon/cifar10-classifier-explainer/default/v1/models/:explain \\\n", + " -H \"Content-Type: application/json\"\n", + "\"\"\"\n", + "ret = Popen(cmd, shell=True, stdout=PIPE)\n", + "raw = ret.stdout.read().decode(\"utf-8\")\n", + "explanation = json.loads(raw)\n", + "arr = np.array(explanation[\"data\"][\"anchor\"])\n", + "plt.imshow(arr)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1758,7 +1779,7 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" },