CIFAR10 Image Classifier Explanations

We will use a Tensorflow classifier built on CIFAR10 image dataset which is a 10 class image dataset to show the example of explanation on image data.

Create the InferenceService with Alibi Explainer

  1. apiVersion: "serving.kserve.io/v1beta1"
  2. kind: "InferenceService"
  3. metadata:
  4. name: "cifar10"
  5. spec:
  6. predictor:
  7. tensorflow:
  8. storageUri: "gs://seldon-models/tfserving/cifar10/resnet32"
  9. resources:
  10. requests:
  11. cpu: 0.1
  12. memory: 5Gi
  13. limits:
  14. memory: 10Gi
  15. explainer:
  16. alibi:
  17. type: AnchorImages
  18. storageUri: "gs://seldon-models/tfserving/cifar10/explainer-py36-0.5.2"
  19. config:
  20. batch_size: "40"
  21. stop_on_first: "True"
  22. resources:
  23. requests:
  24. cpu: 0.1
  25. memory: 5Gi
  26. limits:
  27. memory: 10Gi

Note

The InferenceService resource describes:

  • A pretrained tensorflow model stored on a Google bucket
  • An AnchorImage Seldon Alibi Explainer, see the Alibi Docs for further details.

Test on notebook

Run this example using the Jupyter notebook.

Once created you will be able to test the predictions:

prediction

And then get an explanation for it:

explanation