oracle / graphpipe

Machine Learning Model Deployment Made Simple
https://oracle.github.io/graphpipe
Other
720 stars 103 forks source link

value inputs for onnx #14

Open NonaryR opened 5 years ago

NonaryR commented 5 years ago

Hello! I want to use graphpipe with sklearn model, converted by this I can save model.onnx, but what can I use for model-inputs? I'm trying to save my model as pipeline.json with this function and runnig docker container:

docker run -it --rm \
    -e https_proxy=${https_proxy} \
    -p 9000:9000 \
    sleepsonthefloor/graphpipe-onnx:cpu \
    --model=pipeline.onnx \
    --value-inputs=pipeline.json \
    --listen=0.0.0.0:9000
INFO[0000] Setting MKL_NUM_THREADS=4.  You can override this variable in your environment.
INFO[0000] Starting graphpipe-caffe2 version 1.0.0.4.0a1675f.dev (built from sha 0a1675f)
WARNING: Logging before InitGoogleLogging() is written to STDERR
E1212 14:07:32.760521     1 c2_api.cc:309] Binary compiled without cuda support.  Using cpu backend.
INFO[0000] Loading file %!(EXTRA string=pipeline.json)
FATA[0000] Could not load value_input: open pipeline.json: no such file or directory

But have this error logs, and I'm confused this message:

FATA[0000] Could not load value_input: open pipeline.json: no such file or directory

This is not correct, while pipeline.onnx in the same directory as pipeline.json, also trying this command:

 --value-inputs=$PWD/pipeline.json \

Maybe I should provide some volume for docker? But then how the model is available and model-inputs is not? And what I should provide in model-inputs? Something like this in caffe-exampe?

convert-caffe2-to-onnx predict_net.pb --caffe2-init-net init_net.pb --value-info '{"data": [1, [1, 3, 224, 224]]}' -o sqeezenet.onnx
NonaryR commented 5 years ago

I can pass model and values into docker by mounting volume:

docker run -it --rm -v $PWD:/root \
    -e https_proxy=${https_proxy} \
    -p 9000:9000 \
    sleepsonthefloor/graphpipe-onnx:cpu \
    --model=/root/pipeline.onnx \
    --value-inputs=/root/model.json \
    --listen=0.0.0.0:9000

But when I run this ValidationError occurs:

Unrecognized type value case (value_info name: probabilities): 0

Logs:

INFO[0000] Setting MKL_NUM_THREADS=4.  You can override this variable in your environment.
INFO[0000] Starting graphpipe-caffe2 version 1.0.0.4.0a1675f.dev (built from sha 0a1675f)
WARNING: Logging before InitGoogleLogging() is written to STDERR
E1213 12:32:57.650635     1 c2_api.cc:309] Binary compiled without cuda support.  Using cpu backend.
INFO[0000] Loading file %!(EXTRA string=/root/model.json)
INFO[0000] Loading file %!(EXTRA string=/root/pipeline.onnx)
terminate called after throwing an instance of 'onnx_c2::checker::ValidationError'
  what():  Unrecognized type value case (value_info name: probabilities): 0
*** Aborted at 1544704377 (unix time) try "date -d @1544704377" if you are using GNU date ***
PC: @     0x7f79c1b27428 gsignal
*** SIGABRT (@0x1) received by PID 1 (TID 0x7f79c3b04b40) from PID 1; stack trace: ***

In my onnx model I have two outputs -- label and probabilties:

output {
    name: "label"
    type {
      tensor_type {
        elem_type: INT64
        shape {
          dim {
            dim_value: 1
          }}}}}
  output {
    name: "probabilities"
    type {
      sequence_type {
        elem_type {
          map_type {
            key_type: INT64
            value_type {
              tensor_type {
                elem_type: FLOAT
              }}}}}}}}

How can I resolve this?