Skip to content

Commit 93f21e9

Browse files
vishalbolludeliahu
authored andcommitted
Restructure iris example (#270)
1 parent 1b737d4 commit 93f21e9

File tree

16 files changed

+48
-29
lines changed

16 files changed

+48
-29
lines changed

cli/cmd/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ func describeAPI(name string, resourcesRes *schema.GetResourcesResponse, flagVer
490490
apiEndpoint := urls.Join(resourcesRes.APIsBaseURL, anyAPIStatus.Path)
491491

492492
out := "\nURL: " + apiEndpoint + "\n"
493-
out += fmt.Sprintf("cURL: curl -k -X POST -H \"Content-Type: application/json\" %s -d @<json_file_path>\n", apiEndpoint)
493+
out += fmt.Sprintf("cURL: curl -k -X POST -H \"Content-Type: application/json\" %s -d @samples.json\n", apiEndpoint)
494494
out += "\n"
495495
out += fmt.Sprintf("Status: %s\n", groupStatus.Message())
496496
out += fmt.Sprintf("Available replicas: %s\n", s.Int32(groupStatus.Available()))

docs/apis/packaging-models.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ with open("sklearn.onnx", "wb") as f:
4747
4848
Here are examples of converting models from some of the common ML frameworks to ONNX:
4949
50-
* [PyTorch](https://github.com/cortexlabs/cortex/blob/master/examples/iris/pytorch/model.py)
51-
* [Sklearn](https://github.com/cortexlabs/cortex/blob/master/examples/iris/sklearn/model.py)
52-
* [XGBoost](https://github.com/cortexlabs/cortex/blob/master/examples/iris/xgboost/model.py)
53-
* [Keras](https://github.com/cortexlabs/cortex/blob/master/examples/iris/keras/model.py)
50+
* [PyTorch](https://github.com/cortexlabs/cortex/blob/master/examples/iris/models/pytorch_model.py)
51+
* [Sklearn](https://github.com/cortexlabs/cortex/blob/master/examples/iris/models/sklearn_model.py)
52+
* [XGBoost](https://github.com/cortexlabs/cortex/blob/master/examples/iris/models/xgboost_model.py)
53+
* [Keras](https://github.com/cortexlabs/cortex/blob/master/examples/iris/models/keras_model.py)
5454
5555
Upload your trained model in ONNX format to Amazon S3:
5656

examples/iris/cortex.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
- kind: api
99
name: pytorch
1010
model: s3://cortex-examples/iris/pytorch.onnx
11-
request_handler: pytorch/handler.py
11+
request_handler: handlers/pytorch.py
1212

1313
- kind: api
1414
name: xgboost
1515
model: s3://cortex-examples/iris/xgboost.onnx
16-
request_handler: xgboost/handler.py
16+
request_handler: handlers/xgboost.py
1717

1818
- kind: api
1919
name: sklearn
2020
model: s3://cortex-examples/iris/sklearn.onnx
21-
request_handler: sklearn/handler.py
21+
request_handler: handlers/sklearn.py
2222

2323
- kind: api
2424
name: keras
2525
model: s3://cortex-examples/iris/keras.onnx
26-
request_handler: keras/handler.py
26+
request_handler: handlers/keras.py

examples/iris/keras/handler.py renamed to examples/iris/handlers/keras.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
iris_labels = ["Iris-setosa", "Iris-versicolor", "Iris-virginica"]
44

55

6+
def pre_inference(sample, metadata):
7+
return {
8+
metadata[0].name: [
9+
sample["sepal_length"],
10+
sample["sepal_width"],
11+
sample["petal_length"],
12+
sample["petal_width"],
13+
]
14+
}
15+
16+
617
def post_inference(prediction, metadata):
718
probabilites = prediction[0][0]
819
predicted_class_id = int(np.argmax(probabilites))
File renamed without changes.
File renamed without changes.

examples/iris/handlers/xgboost.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import numpy as np
2+
3+
iris_labels = ["Iris-setosa", "Iris-versicolor", "Iris-virginica"]
4+
5+
6+
def pre_inference(sample, metadata):
7+
return {
8+
metadata[0].name: [
9+
sample["sepal_length"],
10+
sample["sepal_width"],
11+
sample["petal_length"],
12+
sample["petal_width"],
13+
]
14+
}
15+
16+
17+
def post_inference(prediction, metadata):
18+
predicted_class_id = prediction[0][0]
19+
return {"class_label": iris_labels[predicted_class_id], "class_index": predicted_class_id}

examples/iris/keras/irises.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/iris/keras/requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)