unknown data layer name converting caffe2 to dlc
Join Date: 7 May 18
Posts: 4
Posted: Wed, 2018-05-09 13:09
Hi,
I'm trying to convert caffe2 model to dlc. This caffe2 model is converted from ONNX and I have no idea what is the data layer name, which is required as an argument to the dlc conversion tool.
looking at the caffe2 model graph, it already starts with conv as first layer:
name: "torch-jit-export_predict"
2 op {
3 input: "0"
4 input: "1"
5 output: "288"
6 name: ""
7 type: "Conv"
8 arg {
9 name: "strides"
10 ints: 1
11 ints: 1
12 }
13 arg {
14 name: "dilations"
15 ints: 1
16 ints: 1
17 }
18 arg {
19 name: "group"
20 i: 1
21 }
22 arg {
23 name: "kernels"
24 ints: 3
25 ints: 3
26 }
27 arg {
28 name: "pads"
29 ints: 1
30 ints: 1
31 ints: 1
32 ints: 1
33 }
34 }
35 op {
36 input: "288"
37 input: "2"
38 input: "3"
39 input: "4"
40 input: "5"
41 output: "289"
42 name: ""
43 type: "SpatialBN"
44 arg {
45 name: "is_test"
46 i: 1
47 }
48 arg {
49 name: "momentum"
50 f: 0.899999976158
51 }
52 arg {
53 name: "epsilon"
54 f: 9.99999974738e-06
55 }
56 }
I'm trying to convert by typing:
snpe-caffe2-to-dlc -e as_init_net.pb -p as_predict_net.pb -d antispoof.dlc -i data 3,128,128
and get the following error:
File "/home/or/Downloads/snpe-1.15.0/lib/python/snpe/snpe_caffe2_to_dlc.py", line 717, in convert
raise ValueError(code_to_message.get_message('ERROR_CAFFE2_DATA_NOT_AN_EXTERNAL_DATA_INPUT')(data_in[0]))
ValueError: ERROR_CAFFE2_DATA_NOT_AN_EXTERNAL_DATA_INPUT: is not an external data input.
Any idea how to fix this?
Thanks!
You must be converting pytorch model to caffe2 model, and then caffe2 to dlc.
It seems that "0" or "1" is the input layer of your dlc model. So you can run your code like
snpe-caffe2-to-dlc -e as_init_net.pb -p as_predict_net.pb -d antispoof.dlc -i 0 3,128,128
or
snpe-caffe2-to-dlc -e as_init_net.pb -p as_predict_net.pb -d antispoof.dlc -i 1 3,128,128
Or, you can set the input/output node name when you convert pytorch model to onnx:
torch_out = torch.onnx._export(torch_model, x, onnx_export_path, export_params=True, input_names=['data'], output_names=['output'])
then you can get dlc by using:
snpe-caffe2-to-dlc -e as_init_net.pb -p as_predict_net.pb -d antispoof.dlc -i data 3,128,128
I hope it helps!
Good Luck!