Model Explanations with Image Data

In this demo we will:

  • Launch an image classification model

  • Send prediction requests to the model

  • Create an explainer for the model

  • Generate explanations for previously sent prediction requests

The model used in this demo was trained to classify images based on the CIFAR10 dataset.

The explainer uses the anchors technique to provide insight into why a particular classification was made by the model. We’ll see the segments in an input image that are the most relevant to the prediction outcome.

Create Model

  1. Click on Create. Click Create button

  2. Enter the deployment details as follows:

  • name: cifar10-classifier

  • namespace: seldon

  • Type: Seldon Deployment

  • Protocol: Tensorflow Deployment details

  1. Configure the default predictor as follows:

  • runtime: Tensorflow

  • Model Project: default

  • uri:

     gs://seldon-models/tfserving/cifar10/resnet32
    
  • Storage Secret: (leave blank/none) Default predictor spec

  1. Skip to the end and click Launch. Launch deployment

  2. If your deployment is launched successfully, it will have Available status. Deployment dashboard showing newly created deployment with available status

Get Predictions

We will make a prediction request using the image of a truck. The image is a JSON file in Tensorflow Serving protocol format.

  1. Click on the cifar10-classifier deployment created in the previous section to enter the deployment dashboard.

  2. Inside the deployment dashboard, click on the Predict button.

  3. On the Predict page, click on Upload JSON file and upload the truck image.

  4. Click the Predict button. A screenshot showing the Predict page with the textarea prepopulated

Add an Anchor Images Explainer

  1. From the cifar10-classifier deployment dashboard, click Create inside the Model Explanation card. The "Create" button inside the Model Explanation card being clicked

  2. For step 1 of the Explainer Configuration Wizard, select Image then click Next. Text radio option selected

  3. For step 2, click make sure Anchors is selected, then click Next. Anchors option selected

  4. For step 3, enter the following value for the Explainer URI:

    gs://seldon-models/tfserving/cifar10/cifar10_anchor_image_py3.7_alibi-0.7.0
    
    

    click Next. Next button clicked

  5. For step 4, click Next. (Do not change any fields). Next button clicked

  6. For step 5, click Next. (Do not change any fields). You may wish to enter a comment here for a gitops enabled namespace. Next button clicked

  7. For step 6, click Launch. Next button clicked

After a short while, the explainer should become available.

Explainer status showing Available

Get Explanation for one Request

Navigate to the Requests page using the left navigation drawer.

navigating to the Requests page

Click on the magnifying glass icon to generate explanations for the request.

Explaining the request

Congratulations, you’ve created an explanation for the request! 🥳

If you make a request in the Predict tab, you can also generate an explanation for it immediately by clicking on the same icon under the Explain section below the response.

Next Steps

Why not try our other demos? Ready do dive in? Read our operations guide to learn more about how to use Deploy.