Skip to content

Restructure iris example #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func describeAPI(name string, resourcesRes *schema.GetResourcesResponse, flagVer
apiEndpoint := urls.Join(resourcesRes.APIsBaseURL, anyAPIStatus.Path)

out := "\nURL: " + apiEndpoint + "\n"
out += fmt.Sprintf("cURL: curl -k -X POST -H \"Content-Type: application/json\" %s -d @<json_file_path>\n", apiEndpoint)
out += fmt.Sprintf("cURL: curl -k -X POST -H \"Content-Type: application/json\" %s -d @samples.json\n", apiEndpoint)
out += "\n"
out += fmt.Sprintf("Status: %s\n", groupStatus.Message())
out += fmt.Sprintf("Available replicas: %s\n", s.Int32(groupStatus.Available()))
Expand Down
8 changes: 4 additions & 4 deletions docs/apis/packaging-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ with open("sklearn.onnx", "wb") as f:

Here are examples of converting models from some of the common ML frameworks to ONNX:

* [PyTorch](https://github.com/cortexlabs/cortex/blob/master/examples/iris/pytorch/model.py)
* [Sklearn](https://github.com/cortexlabs/cortex/blob/master/examples/iris/sklearn/model.py)
* [XGBoost](https://github.com/cortexlabs/cortex/blob/master/examples/iris/xgboost/model.py)
* [Keras](https://github.com/cortexlabs/cortex/blob/master/examples/iris/keras/model.py)
* [PyTorch](https://github.com/cortexlabs/cortex/blob/master/examples/iris/models/pytorch_model.py)
* [Sklearn](https://github.com/cortexlabs/cortex/blob/master/examples/iris/models/sklearn_model.py)
* [XGBoost](https://github.com/cortexlabs/cortex/blob/master/examples/iris/models/xgboost_model.py)
* [Keras](https://github.com/cortexlabs/cortex/blob/master/examples/iris/models/keras_model.py)

Upload your trained model in ONNX format to Amazon S3:

Expand Down
8 changes: 4 additions & 4 deletions examples/iris/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
- kind: api
name: pytorch
model: s3://cortex-examples/iris/pytorch.onnx
request_handler: pytorch/handler.py
request_handler: handlers/pytorch.py

- kind: api
name: xgboost
model: s3://cortex-examples/iris/xgboost.onnx
request_handler: xgboost/handler.py
request_handler: handlers/xgboost.py

- kind: api
name: sklearn
model: s3://cortex-examples/iris/sklearn.onnx
request_handler: sklearn/handler.py
request_handler: handlers/sklearn.py

- kind: api
name: keras
model: s3://cortex-examples/iris/keras.onnx
request_handler: keras/handler.py
request_handler: handlers/keras.py
11 changes: 11 additions & 0 deletions examples/iris/keras/handler.py → examples/iris/handlers/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
iris_labels = ["Iris-setosa", "Iris-versicolor", "Iris-virginica"]


def pre_inference(sample, metadata):
return {
metadata[0].name: [
sample["sepal_length"],
sample["sepal_width"],
sample["petal_length"],
sample["petal_width"],
]
}


def post_inference(prediction, metadata):
probabilites = prediction[0][0]
predicted_class_id = int(np.argmax(probabilites))
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions examples/iris/handlers/xgboost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import numpy as np

iris_labels = ["Iris-setosa", "Iris-versicolor", "Iris-virginica"]


def pre_inference(sample, metadata):
return {
metadata[0].name: [
sample["sepal_length"],
sample["sepal_width"],
sample["petal_length"],
sample["petal_width"],
]
}


def post_inference(prediction, metadata):
predicted_class_id = prediction[0][0]
return {"class_label": iris_labels[predicted_class_id], "class_index": predicted_class_id}
16 changes: 0 additions & 16 deletions examples/iris/keras/irises.json

This file was deleted.

4 changes: 0 additions & 4 deletions examples/iris/keras/requirements.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions examples/iris/models/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
keras
keras2onnx
tensorflow
torch
pandas
skl2onnx
sklearn
onnxmltools
xgboost
File renamed without changes.
File renamed without changes.
File renamed without changes.