Skip to content

Commit

Permalink
kubeflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Grigorev committed Apr 3, 2021
1 parent 90d2e44 commit 634bea3
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
35 changes: 35 additions & 0 deletions chapter-09-kubeflow/test-plain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import requests
from keras_image_helper import create_preprocessor

preprocessor = create_preprocessor('xception', target_size=(299, 299))


url = 'https://clothing-model.default.kubeflow.mlbookcamp.com/v1/models/clothing-model:predict'

image_url = "http://bit.ly/mlbookcamp-pants"
X = preprocessor.from_url(image_url)

data = {
"instances": X.tolist()
}

resp = requests.post(url, json=data)

results = resp.json()
pred = results['predictions'][0]

labels = [
'dress',
'hat',
'longsleeve',
'outwear',
'pants',
'shirt',
'shoes',
'shorts',
'skirt',
't-shirt'
]

result = {c: p for c, p in zip(labels, pred)}
print(result)
15 changes: 15 additions & 0 deletions chapter-09-kubeflow/test-transformer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import requests

data = {
"instances": [
{"url": "http://bit.ly/mlbookcamp-pants"},
]
}

# url = 'http://localhost:8080/v1/models/clothing-model:predict'

url = 'https://clothing-model.default.kubeflow.mlbookcamp.com/v1/models/clothing-model:predict'

result = requests.post(url, json=data).json()

print(result)
10 changes: 10 additions & 0 deletions chapter-09-kubeflow/tf-clothes-plain.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: "serving.kubeflow.org/v1beta1"
kind: "InferenceService"
metadata:
name: "clothing-model"
spec:
default:
predictor:
serviceAccountName: sa
tensorflow:
storageUri: "s3://mlbookcamp-models-alexey/clothing-model"
22 changes: 22 additions & 0 deletions chapter-09-kubeflow/tf-clothes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: "serving.kubeflow.org/v1alpha2"
kind: "InferenceService"
metadata:
name: "clothing-model"
spec:
default:
predictor:
serviceAccountName: sa
tensorflow:
storageUri: "s3://mlbookcamp-models-alexey/clothing-model"
transformer:
custom:
container:
image: "agrigorev/kfserving-keras-transformer:0.0.1"
name: user-container
env:
- name: MODEL_INPUT_SIZE
value: "299,299"
- name: KERAS_MODEL_NAME
value: "xception"
- name: MODEL_LABELS
value: "dress,hat,longsleeve,outwear,pants,shirt,shoes,shorts,skirt,t-shirt"

0 comments on commit 634bea3

Please sign in to comment.