forked from PipelineAI/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added doppelganger sample from antje
- Loading branch information
Showing
23 changed files
with
1,514 additions
and
0 deletions.
There are no files selected for viewing
1,015 changes: 1,015 additions & 0 deletions
1,015
kubeflow/notebooks/doppelganger/Doppelganger_A.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
kubeflow/notebooks/doppelganger/code/inference/Dockerfile-v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:3.6-slim | ||
|
||
COPY ./requirements.txt /app/requirements.txt | ||
WORKDIR /app | ||
RUN pip install -r requirements.txt | ||
COPY DoppelgangerModel.py /app | ||
COPY pairwise_top_25_v1.json pairwise_top_25.json | ||
|
||
ENV MODEL_NAME DoppelgangerModel | ||
ENV API_TYPE REST | ||
ENV SERVICE_TYPE MODEL | ||
ENV PERSISTENCE 0 | ||
|
||
EXPOSE 5000 | ||
|
||
CMD exec seldon-core-microservice $MODEL_NAME $API_TYPE --service-type $SERVICE_TYPE --persistence $PERSISTENCE |
16 changes: 16 additions & 0 deletions
16
kubeflow/notebooks/doppelganger/code/inference/Dockerfile-v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:3.6-slim | ||
|
||
COPY ./requirements.txt /app/requirements.txt | ||
WORKDIR /app | ||
RUN pip install -r requirements.txt | ||
COPY DoppelgangerModel.py /app | ||
COPY pairwise_top_25_v2.json pairwise_top_25.json | ||
|
||
ENV MODEL_NAME DoppelgangerModel | ||
ENV API_TYPE REST | ||
ENV SERVICE_TYPE MODEL | ||
ENV PERSISTENCE 0 | ||
|
||
EXPOSE 5000 | ||
|
||
CMD exec seldon-core-microservice $MODEL_NAME $API_TYPE --service-type $SERVICE_TYPE --persistence $PERSISTENCE |
19 changes: 19 additions & 0 deletions
19
kubeflow/notebooks/doppelganger/code/inference/DoppelgangerModel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import keras | ||
import sys | ||
import numpy as np | ||
import json | ||
|
||
class DoppelgangerModel(object): | ||
def __init__(self): | ||
print("\n** LOADING MODEL from pairwise_top_25.json **") | ||
with open('pairwise_top_25.json') as fp: | ||
self.model = json.load(fp) | ||
print("\n** LOADED MODEL from pairwise_top_25.json **") | ||
|
||
def predict(self, X, feature_names): | ||
similar_image_arr = self.model[str(int(X[0]))] | ||
return similar_image_arr | ||
|
||
if __name__== "__main__": | ||
model = DoppelgangerModel() | ||
print(model.predict([0], ['image_id'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash -e | ||
|
||
docker build -t antjebarth/doppelganger-predict:1.0.0 -f Dockerfile-v1 . | ||
docker push antjebarth/doppelganger-predict:1.0.0 | ||
|
||
#kubectl create -f doppelganger-predict-deploy.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash -e | ||
|
||
docker build -t antjebarth/doppelganger-predict:2.0.0 -f Dockerfile-v2 . | ||
docker push antjebarth/doppelganger-predict:2.0.0 | ||
|
||
#kubectl create -f doppelganger-predict-deploy-ab-test.yaml |
169 changes: 169 additions & 0 deletions
169
kubeflow/notebooks/doppelganger/code/inference/doppelganger-predict-deploy-abtest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
apiVersion: machinelearning.seldon.io/v1alpha2 | ||
kind: SeldonDeployment | ||
metadata: | ||
generation: 1 | ||
labels: | ||
app: seldon | ||
name: abtest-model | ||
namespace: deployment | ||
spec: | ||
name: abtest-model | ||
predictors: | ||
- componentSpecs: | ||
- spec: | ||
containers: | ||
- env: | ||
- name: PREDICTIVE_UNIT_SERVICE_PORT | ||
value: "9000" | ||
- name: PREDICTIVE_UNIT_ID | ||
value: classifier-1 | ||
- name: PREDICTOR_ID | ||
value: abtest | ||
- name: SELDON_DEPLOYMENT_ID | ||
value: abtest-model | ||
image: antjebarth/doppelganger-predict:1.0.0 | ||
imagePullPolicy: Always | ||
lifecycle: | ||
preStop: | ||
exec: | ||
command: | ||
- /bin/sh | ||
- -c | ||
- /bin/sleep 10 | ||
livenessProbe: | ||
failureThreshold: 3 | ||
initialDelaySeconds: 60 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: http | ||
timeoutSeconds: 1 | ||
name: classifier-1 | ||
ports: | ||
- containerPort: 9000 | ||
name: http | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 3 | ||
initialDelaySeconds: 20 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: http | ||
timeoutSeconds: 1 | ||
resources: | ||
requests: | ||
memory: 1Mi | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
volumeMounts: | ||
- mountPath: /etc/podinfo | ||
name: podinfo | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
schedulerName: default-scheduler | ||
securityContext: {} | ||
terminationGracePeriodSeconds: 20 | ||
volumes: | ||
- downwardAPI: | ||
defaultMode: 420 | ||
items: | ||
- fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.annotations | ||
path: annotations | ||
name: podinfo | ||
- metadata: | ||
labels: | ||
version: v2 | ||
spec: | ||
containers: | ||
- env: | ||
- name: PREDICTIVE_UNIT_SERVICE_PORT | ||
value: "9000" | ||
- name: PREDICTIVE_UNIT_ID | ||
value: classifier-2 | ||
- name: PREDICTOR_ID | ||
value: abtest | ||
- name: SELDON_DEPLOYMENT_ID | ||
value: abtest-model | ||
image: antjebarth/doppelganger-predict:2.0.0 | ||
imagePullPolicy: Always | ||
lifecycle: | ||
preStop: | ||
exec: | ||
command: | ||
- /bin/sh | ||
- -c | ||
- /bin/sleep 10 | ||
livenessProbe: | ||
failureThreshold: 3 | ||
initialDelaySeconds: 60 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: http | ||
timeoutSeconds: 1 | ||
name: classifier-2 | ||
ports: | ||
- containerPort: 9000 | ||
name: http | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 3 | ||
initialDelaySeconds: 20 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: http | ||
timeoutSeconds: 1 | ||
resources: | ||
requests: | ||
memory: 1Mi | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
volumeMounts: | ||
- mountPath: /etc/podinfo | ||
name: podinfo | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
schedulerName: default-scheduler | ||
securityContext: {} | ||
terminationGracePeriodSeconds: 20 | ||
volumes: | ||
- downwardAPI: | ||
defaultMode: 420 | ||
items: | ||
- fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.annotations | ||
path: annotations | ||
name: podinfo | ||
graph: | ||
children: | ||
- children: [] | ||
endpoint: | ||
service_host: localhost | ||
service_port: 9000 | ||
type: REST | ||
implementation: UNKNOWN_IMPLEMENTATION | ||
name: classifier-1 | ||
type: MODEL | ||
- children: [] | ||
endpoint: | ||
service_host: localhost | ||
service_port: 9000 | ||
type: REST | ||
implementation: UNKNOWN_IMPLEMENTATION | ||
name: classifier-2 | ||
type: MODEL | ||
endpoint: {} | ||
implementation: RANDOM_ABTEST | ||
name: abtest-model | ||
parameters: | ||
- name: ratioA | ||
type: FLOAT | ||
value: "0.5" | ||
type: UNKNOWN_TYPE | ||
name: abtest | ||
replicas: 1 |
102 changes: 102 additions & 0 deletions
102
kubeflow/notebooks/doppelganger/code/inference/doppelganger-predict-deploy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
apiVersion: machinelearning.seldon.io/v1alpha2 | ||
kind: SeldonDeployment | ||
metadata: | ||
generation: 1 | ||
labels: | ||
app: seldon | ||
name: doppelganger-model | ||
namespace: deployment | ||
spec: | ||
annotations: | ||
seldon.io/engine-log-message-type: seldon.message.pair | ||
seldon.io/engine-log-messages-externally: "false" | ||
seldon.io/engine-log-requests: "false" | ||
seldon.io/engine-log-responses: "false" | ||
seldon.io/headless-svc: "false" | ||
name: doppelganger-model | ||
predictors: | ||
- componentSpecs: | ||
- spec: | ||
containers: | ||
- env: | ||
- name: LOG_LEVEL | ||
value: INFO | ||
- name: PREDICTIVE_UNIT_SERVICE_PORT | ||
value: "5000" | ||
- name: PREDICTIVE_UNIT_ID | ||
value: recommender | ||
- name: PREDICTOR_ID | ||
value: doppelganger-model | ||
- name: SELDON_DEPLOYMENT_ID | ||
value: doppelganger-model | ||
image: antjebarth/doppelganger-predict:1.0.0 | ||
imagePullPolicy: Always | ||
lifecycle: | ||
preStop: | ||
exec: | ||
command: | ||
- /bin/sh | ||
- -c | ||
- /bin/sleep 10 | ||
livenessProbe: | ||
failureThreshold: 3 | ||
initialDelaySeconds: 60 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: http | ||
timeoutSeconds: 1 | ||
name: recommender | ||
ports: | ||
- containerPort: 5000 | ||
name: http | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 3 | ||
initialDelaySeconds: 20 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: http | ||
timeoutSeconds: 1 | ||
resources: | ||
requests: | ||
memory: 1Mi | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
volumeMounts: | ||
- mountPath: /etc/podinfo | ||
name: podinfo | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
schedulerName: default-scheduler | ||
securityContext: {} | ||
terminationGracePeriodSeconds: 20 | ||
volumes: | ||
- downwardAPI: | ||
defaultMode: 420 | ||
items: | ||
- fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.annotations | ||
path: annotations | ||
name: podinfo | ||
graph: | ||
children: [] | ||
endpoint: | ||
service_host: localhost | ||
service_port: 5000 | ||
type: REST | ||
implementation: UNKNOWN_IMPLEMENTATION | ||
name: recommender | ||
type: MODEL | ||
labels: | ||
fluentd: "true" | ||
version: v1 | ||
name: doppelganger-model | ||
replicas: 1 | ||
svcOrchSpec: | ||
env: [] | ||
resources: | ||
requests: | ||
cpu: "0.1" |
1 change: 1 addition & 0 deletions
1
kubeflow/notebooks/doppelganger/code/inference/pairwise_top_25_v1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"0": ["http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02085620-Chihuahua/n02085620_10976.jpg", "http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02087046-toy_terrier/n02087046_3211.jpg", "http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02089973-English_foxhound/n02089973_2484.jpg", "http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02109047-Great_Dane/n02109047_9604.jpg", "http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02110185-Siberian_husky/n02110185_3406.jpg"]} |
1 change: 1 addition & 0 deletions
1
kubeflow/notebooks/doppelganger/code/inference/pairwise_top_25_v2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"0": ["http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02110185-Siberian_husky/n02110185_3406.jpg", "http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02109047-Great_Dane/n02109047_9604.jpg", "http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02085620-Chihuahua/n02085620_10976.jpg", "http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02089973-English_foxhound/n02089973_2484.jpg", "http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/notebook/doppelganger/doppelganger/view/doppelganger/code/training/images/n02087046-toy_terrier/n02087046_3211.jpg"]} |
8 changes: 8 additions & 0 deletions
8
kubeflow/notebooks/doppelganger/code/inference/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
tensorflow==1.13.1 | ||
keras==2.2.4 | ||
scikit-learn | ||
numpy | ||
pandas | ||
pillow | ||
flask | ||
seldon-core==0.4.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash -e | ||
docker run -p 4444:5000 antjebarth/doppelganger-predict:1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash -e | ||
|
||
curl -d 'json={"data":{"ndarray":[[0]]}}' http://0.0.0.0:4444/predict |
3 changes: 3 additions & 0 deletions
3
kubeflow/notebooks/doppelganger/code/inference/test-prod-abtest.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
curl http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/seldon/deployment/abtest-model/api/v0.1/predictions -d '{"data":{"ndarray":[[0]]}}' -H "Content-Type: application/json" | ||
|
||
# curl http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/seldon/deployment/abtest-model/api/v0.1/predictions -d '{"data":{"names":["image_id"],"tensor":{"shape":[1,1],"values":[0]}}}' -H "Content-Type: application/json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
curl http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/seldon/deployment/doppelganger-model/api/v0.1/predictions -d '{"data":{"ndarray":[[0]]}}' -H "Content-Type: application/json" | ||
|
||
# curl http://c0198e9d-istiosystem-istio-2af2-1928351968.eu-central-1.elb.amazonaws.com/seldon/deployment/doppelganger-model/api/v0.1/predictions -d '{"data":{"names":["id"],"tensor":{"shape":[1,1],"values":[0]}}}' -H "Content-Type: application/json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash -e | ||
|
||
curl -d 'json={"data":{"ndarray":[[0]]}}' http://0.0.0.0:4444/predict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
images/ | ||
Images/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3.6-slim | ||
|
||
COPY images/ images/ | ||
|
||
COPY requirements.txt requirements.txt | ||
RUN pip install -r requirements.txt | ||
|
||
COPY doppelganger-train.py doppelganger-train.py | ||
CMD [ "python", "doppelganger-train.py" ] | ||
|
Oops, something went wrong.