@@ -26,6 +26,7 @@ def parse(matched):
2626
2727conv = re .compile (r'.*%(.+?) .+?(Conv).+?dilations=(\[\d+?, \d+?\]).+?strides=(\[\d+?, \d+?\]).+?(\(%.+?, %.+?, %.+?\)).+?\n' )
2828relu = re .compile (r'.*%(.+?) .+?(Relu)\(%(.+?)\).+?\n' )
29+ gap = re .compile (r'.*%(.+?) .+?(GlobalAveragePool)\(%(.+?)\).+?\n' )
2930sigmoid = re .compile (r'.*%(.+?) .+?(Sigmoid)\(%(.+?)\).+?\n' )
3031maxpool = re .compile (r'.*%(.+?) .+?(MaxPool).+?kernel_shape=(\[\d+?, \d+?\]).+?strides=(\[\d+?, \d+?\]).+?\(%(.+?)\).+?\n' )
3132upsample = re .compile (r'.*%.+? .+?Constant\[value=.+?(\d+\.?\d*) \[.+?\n.+?%(.+?) .+?(Upsample).+?\(%(.+?),.+?\n' )
@@ -36,7 +37,7 @@ def parse(matched):
3637add = re .compile (r'.*%(.+?) .+?(Add)(\(%.+?\)).+?\n' )
3738weight = re .compile (r'.*%(.+?) .+?(\(.*?\)).*\n' )
3839
39- res = (flatten , upsample , conv , relu , sigmoid , maxpool , dense , concat , add , batchnorm , weight )
40+ res = (flatten , upsample , conv , relu , gap , sigmoid , maxpool , dense , concat , add , batchnorm , weight )
4041
4142def read_onnx (path ):
4243 with open (path + '.txt' ) as f :
@@ -58,7 +59,7 @@ def read_onnx(path):
5859 flow .append ((i [4 ][0 ], ['conv_%s' % num ], i [0 ]))
5960 elif i [1 ]== 'Gemm' :
6061 num = len (body )
61- body .append (('dense_%s' % num , 'dense' , key [i [2 ][1 ][::- 1 ] ]))
62+ body .append (('dense_%s' % num , 'dense' , key [i [2 ][1 ]] [::- 1 ]))
6263 flow .append ((i [2 ][0 ], ['dense_%s' % num ], i [0 ]))
6364 elif i [1 ]== 'Sigmoid' :
6465 num = len (body )
@@ -68,6 +69,10 @@ def read_onnx(path):
6869 num = len (body )
6970 body .append (('relu_%s' % num , 'relu' , None ))
7071 flow .append ((i [2 ], ['relu_%s' % num ], i [0 ]))
72+ elif i [1 ]== 'GlobalAveragePool' :
73+ num = len (body )
74+ body .append (('gap_%s' % num , 'gap' , None ))
75+ flow .append ((i [2 ], ['gap_%s' % num ], i [0 ]))
7176 elif i [1 ]== 'Add' :
7277 num = len (body )
7378 body .append (('add_%s' % num , 'add' , None ))
@@ -93,8 +98,9 @@ def read_onnx(path):
9398 body .append (('flatten_%s' % num , 'flatten' , None ))
9499 flow .append ((i [2 ], ['flatten_%s' % num ], i [0 ]))
95100
96- #for i in body: print(i)
97- #for i in flow: print(i)
101+ # for i in body: print(i)
102+ # print("=============== ")
103+ # for i in flow: print(i)
98104
99105 net = Net ()
100106 net .load_json (body , flow )
0 commit comments