Skip to content

Commit

Permalink
Merge pull request #425 from mellistibco/master
Browse files Browse the repository at this point in the history
update sample app model and inference activity input
  • Loading branch information
abramvandergeest authored Oct 25, 2018
2 parents cc88f14 + 26dabb4 commit c170b24
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 83 deletions.
13 changes: 9 additions & 4 deletions samples/tensorflow/cnnUnitTest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ func handler(ctx context.Context, inputs map[string]*data.Attribute) (map[string
modelPath := "Archive_simpleCNN.zip"
framework := "Tensorflow"

var features []map[string]interface{}
features = append(features, make(map[string]interface{}))
features[0]["name"] = "X"
// features is the array that will be used to hold the input feature set that we pass into the inference activity
var features []interface{}

// So I read in the list of gaussin arrays from the POST request, but I need to convert them to the form the CNN model expects
// (for an array of shape [x,10] to a tensor of shape [x,10,1,1] where x is the number of gaussians sent)
Expand All @@ -70,7 +69,13 @@ func handler(ctx context.Context, inputs map[string]*data.Attribute) (map[string
}
datafeat = append(datafeat, gaus)
}
features[0]["data"] = datafeat

// Now append the input feature with the name X to the features array. This will be passed into
// the inference activity.
features = append(features, map[string]interface{}{
"name": "X",
"data": datafeat,
})

// defining a map containing all the inputs to send to inference activity.
// The keys correspond to inputs defined in the activity.json file for the inference activity
Expand Down
137 changes: 59 additions & 78 deletions samples/tensorflow/helloworld/PredictMovement.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,96 +12,77 @@
"id": "cli_trigger",
"handlers": [
{
"settings": {
"command": null,
"default": null
},
"actionId": "tensor_flow_predict",
"actionMappings": {
"input": [],
"output": []
"action": {
"ref": "github.com/TIBCOSoftware/flogo-contrib/action/flow",
"data": {
"flowURI": "res://flow:tensor_flow_predict"
},
"mappings": {
"input": [],
"output": []
},
"settings": {
"command": null,
"default": null
}
}
}
]
}
],
"actions": [
"resources": [
{
"id": "flow:tensor_flow_predict",
"data": {
"flow": {
"name": "TensorFlowPredict",
"type": 1,
"attributes": [],
"rootTask": {
"id": "root",
"type": 1,
"tasks": [
{
"id": "inference_2",
"name": "Invoke ML Model",
"description": "Basic inferencing activity to invoke ML model using the flogo-ml framework.",
"type": 1,
"activityType": "flogo-inference",
"activityRef": "github.com/TIBCOSoftware/flogo-contrib/activity/inference",
"attributes": [
"name": "TensorFlowPredict",
"metadata": {},
"tasks": [
{
"id": "inference_2",
"name": "Invoke ML Model",
"activity": {
"ref": "github.com/TIBCOSoftware/flogo-contrib/activity/inference",
"input": {
"model": "Archive.zip",
"framework": "Tensorflow"
},
"mappings": {
"input": [
{
"name": "model",
"value": "Archive.zip",
"required": true,
"type": "string"
},
{
"name": "inputName",
"value": "inputs",
"required": true,
"type": "string"
},
{
"name": "framework",
"value": "Tensorflow",
"required": true,
"type": "string"
}
],
"inputMappings": [
{
"type": 4,
"value": {
"z-axis-q75": 4.140586,
"corr-x-z": 0.1381063882214782,
"x-axis-mean": 1.7554575428900194,
"z-axis-sd": 4.6888631696380765,
"z-axis-skew": -0.3619011587545954,
"y-axis-sd": -7.959084724314854,
"y-axis-q75": 16.467001,
"corr-z-y": 0.3467060369518231,
"x-axis-sd": 6.450293741961166,
"x-axis-skew": 0.09756801680727022,
"y-axis-mean": 9.389463650669393,
"y-axis-skew": -0.49036224958471764,
"z-axis-mean": 1.1226106985139188,
"x-axis-q25": -3.1463003,
"x-axis-q75": 6.3198414,
"y-axis-q25": 3.0645783,
"z-axis-q25": -1.9477097,
"corr-x-y": 0.08100326860866637
},
"type": "assign",
"value": [
{
"name": "inputs",
"data": {
"z-axis-q75": 4.140586,
"corr-x-z": 0.1381063882214782,
"x-axis-mean": 1.7554575428900194,
"z-axis-sd": 4.6888631696380765,
"z-axis-skew": -0.3619011587545954,
"y-axis-sd": -7.959084724314854,
"y-axis-q75": 16.467001,
"corr-z-y": 0.3467060369518231,
"x-axis-sd": 6.450293741961166,
"x-axis-skew": 0.09756801680727022,
"y-axis-mean": 9.389463650669393,
"y-axis-skew": -0.49036224958471764,
"z-axis-mean": 1.1226106985139188,
"x-axis-q25": -3.1463003,
"x-axis-q75": 6.3198414,
"y-axis-q25": 3.0645783,
"z-axis-q25": -1.9477097,
"corr-x-y": 0.08100326860866637
}
}
],
"mapTo": "features"
}
]
}
],
"links": [],
"attributes": []
}
}
}
},
"id": "tensor_flow_predict",
"metadata": {
"input": [],
"output": []
},
"ref": "github.com/TIBCOSoftware/flogo-contrib/action/flow"
]
}
}
]
}
}
4 changes: 3 additions & 1 deletion samples/tensorflow/helloworld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ This sample Flogo application is used to demonstrate some key Flogo constructs:
To build via the Flogo CLI, simply download the PredictMovement.json to your local machine and create the app structure:

```{r, engine='bash', count_lines}
flogo create -f ~/Downloads/PredictMovement.json
flogo create -flv github.com/TIBCOSoftware/flogo-contrib/action/flow@master,github.com/TIBCOSoftware/flogo-lib/engine@master -f PredictMovement.json
cd PredictMovement
```

Note that the above command indicates that the master branch of flogo-lib & flogo-contrib should be used when the dependencies are fetched.

You can now build the application and target the CLI trigger as the entrypoint. When targeting a specific trigger, the resulting binary will include only the flow(s) where the trigger is mapped will be included.

```{r, engine='bash', count_lines}
Expand Down

0 comments on commit c170b24

Please sign in to comment.