mirror of
https://github.com/hanzo-ml/kserve.git
synced 2026-10-30 20:53:49 +00:00
* feat: Support customizable deployment strategy for RawDeployment mode Signed-off-by: Yuan Tang <[email protected]> * regen Signed-off-by: Yuan Tang <[email protected]> * lint Signed-off-by: Yuan Tang <[email protected]> * Correctly apply rollingupdate Signed-off-by: Yuan Tang <[email protected]> * address comments Signed-off-by: Yuan Tang <[email protected]> * Add validation Signed-off-by: Yuan Tang <[email protected]> --------- Signed-off-by: Yuan Tang <[email protected]>
5.6 KiB
5.6 KiB
In [ ]:
!pygmentize cifar10.yamlIn [ ]:
!kubectl apply -f cifar10.yaml -n defaultIn [ ]:
!kubectl wait --for condition=ready --timeout=600s pods --all -n defaultIn [ ]:
CLUSTER_IPS = !(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
CLUSTER_IP = CLUSTER_IPS[0]
print(CLUSTER_IP)In [ ]:
SERVICE_HOSTNAMES = !(kubectl get inferenceservice cifar10 -n default -o jsonpath='{.status.url}' | cut -d "/" -f 3)
SERVICE_HOSTNAME = SERVICE_HOSTNAMES[0]
print(SERVICE_HOSTNAME)In [ ]:
import sys
sys.path.append("../")
from alibi_helper import *In [ ]:
import os
import matplotlib.pyplot as plt
import tensorflow as tf
train, test = tf.keras.datasets.cifar10.load_data()
X_train, y_train = train
X_test, y_test = test
X_train = X_train.astype("float32") / 255
X_test = X_test.astype("float32") / 255
print(X_train.shape, y_train.shape, X_test.shape, y_test.shape)
class_names = [
"airplane",
"automobile",
"bird",
"cat",
"deer",
"dog",
"frog",
"horse",
"ship",
"truck",
]In [ ]:
import json
from subprocess import PIPE, Popen, run
import numpy as np
idx = 12
test_example = X_test[idx : idx + 1].tolist()
payload = '{"instances":' + f"{test_example}" + " }"
cmd = f"""curl -s -d '{payload}' \
http://{CLUSTER_IP}/v1/models/cifar10:predict \
-H "Host: {SERVICE_HOSTNAME}" \
-H "Content-Type: application/json"
"""
ret = Popen(cmd, shell=True, stdout=PIPE)
raw = ret.stdout.read().decode("utf-8")
res = json.loads(raw)
print(res)
arr = np.array(res["predictions"])
X = X_test[idx].reshape(1, 32, 32, 3)
plt.imshow(X.reshape(32, 32, 3))
plt.axis("off")
plt.show()
print("class:", class_names[y_test[idx][0]])
print("prediction:", class_names[arr[0].argmax()])In [ ]:
test_example = X_test[idx : idx + 1].tolist()
payload = '{"instances":' + f"{test_example}" + " }"
cmd = f"""curl -s -d '{payload}' \
http://{CLUSTER_IP}/v1/models/cifar10:explain \
-H "Host: {SERVICE_HOSTNAME}" \
-H "Content-Type: application/json"
"""
ret = Popen(cmd, shell=True, stdout=PIPE)
raw = ret.stdout.read().decode("utf-8")
explanation = json.loads(raw)
arr = np.array(explanation["data"]["anchor"])
plt.imshow(arr)In [ ]:
!kubectl delete -f cifar10.yaml -n default