forked from alibaba/pipcook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline-databinding-image-classification.js
67 lines (56 loc) · 3.3 KB
/
pipeline-databinding-image-classification.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* This is an example Pipcook file. This pipeline is used to train the image classification task. We have several plugins used in this pipeline:
*
* - imageClassDataCollect: used to collect the image classification data. This is a general-purpose image classification collect plugin.
* The user can specify the url of their own dataset instead of ours as long as the dataset conforms to the plugin's expectation. For more information
* of this plugin, Please refer to https://github.com/alibaba/pipcook/wiki/pipcook-plugins-image-class-data-collect
*
* - imageClassDataAccess: used to access the expected image dataset format (PASCOL VOC) and access these images into the pipeline. This is the uniform data
* access plugin for image and make sure that pipcook has uniform dataset that can be published and communicated later in data world. For more information
* about this plugin, Please refer to https://github.com/alibaba/pipcook/wiki/pipcook-plugins-image-class-data-access
*
* - mobileNetLoad: used to load the mobile net specifically. For more information about this plguin ,Please refer to
* https://github.com/alibaba/pipcook/wiki/pipcook-plugins-local-mobilenet-model-load
*
* - modelTrainPlugin: uesd to train the model. Currently it supports models of tf.LayersModel. For more information, Please refer to
* https://github.com/alibaba/pipcook/wiki/pipcook-plugins-model-train
*
* - modelEvaluatePlugin: used to evaluate the model. Currently it supports models of tf.LayersModel and classification model which implements
* predict interface we defined for model. For more information, Please refer to https://github.com/alibaba/pipcook/wiki/pipcook-plugins-model-evaluate
*
*/
const {DataCollect, DataAccess, ModelLoad, ModelTrain, ModelEvaluate, PipcookRunner, ModelDeploy} = require('@pipcook/pipcook-core');
const imageClassDataAccess = require('@pipcook/pipcook-plugins-image-class-data-access').default;
const mobileNetLoad = require('@pipcook/pipcook-plugins-local-mobilenet-model-load').default;
const modelTrainPlugin = require('@pipcook/pipcook-plugins-model-train').default;
const modelEvaluatePlugin = require('@pipcook/pipcook-plugins-model-evaluate').default;
const imageClassDataCollect = require('@pipcook/pipcook-plugins-image-class-data-collect').default
const imageClassLocalModelDeploy = require('@pipcook/pipcook-plugins-image-class-local-model-deploy').default;
async function startPipeline() {
// collect mnist data
const dataCollect = DataCollect(imageClassDataCollect, {
url: 'http://ai-sample.oss-cn-hangzhou.aliyuncs.com/image_classification/datasets/eCommerceImageClassification.zip'
});
// access mnist data into our specifiction
const dataAccess = DataAccess(imageClassDataAccess, {
imgSize:[256, 256],
});
// load mobile net model
const modelLoad = ModelLoad(mobileNetLoad, {
isFreeze: false
});
// train the model
const modelTrain = ModelTrain(modelTrainPlugin, {
epochs: 15,
batchSize: 16
});
// evaluate the model
const modelEvaluate = ModelEvaluate(modelEvaluatePlugin);
// deploy into local
const modelDeploy = ModelDeploy(imageClassLocalModelDeploy);
const runner = new PipcookRunner({
predictServer: true
});
runner.run([dataCollect, dataAccess, modelLoad, modelTrain, modelEvaluate, modelDeploy])
}
startPipeline();