diff --git a/source/caffe.js b/source/caffe.js index 1e41576748..1a8a542d31 100644 --- a/source/caffe.js +++ b/source/caffe.js @@ -151,8 +151,9 @@ caffe.Model = class { constructor(metadata, net) { this.name = net.name; - let version = -1; this.format = 'Caffe'; + this.graphs = []; + let version = -1; if (net.layers && net.layers.length > 0) { if (net.layers.every((layer) => Object.prototype.hasOwnProperty.call(layer, 'layer'))) { version = 0; @@ -176,7 +177,6 @@ caffe.Model = class { if (phases.size === 0) { phases.add(-1); } - this.graphs = []; for (const phase of phases) { const graph = new caffe.Graph(metadata, phase, net, version); this.graphs.push(graph); @@ -254,15 +254,16 @@ caffe.Graph = class { lastLayer.chain = lastLayer.chain || []; lastLayer.chain.push(layer); } else { - if (layer.type === 'Input' || layer.type === 'Data') { - if (layer.input.length === 0 && layer.output.length === 1 && - layer.input_param && layer.input_param.shape && - layer.input_param.shape.length === 1 && layer.input_param.shape[0].dim) { - const shape = new caffe.TensorShape(layer.input_param.shape[0].dim.map((dim) => dim.toNumber())); - const type = new caffe.TensorType(null, shape); - this.inputs.push(new caffe.Argument(layer.output[0], [value(layer.output[0], type)])); - layer = null; + if (layer.type === 'Input' && layer.input.length === 0) { + for (let i = 0; i < layer.output.length; i++) { + const output = layer.output[i]; + const dim = layer.input_param && layer.input_param.shape && i < layer.input_param.shape.length ? layer.input_param.shape[i].dim : null; + const shape = dim ? new caffe.TensorShape(dim.map((dim) => dim.toNumber())) : null; + const type = shape ? new caffe.TensorType(null, shape) : null; + const argument = new caffe.Argument(output, [value(output, type)]); + this.inputs.push(argument); } + layer = null; } if (layer) { nodes.push(layer); diff --git a/test/models.json b/test/models.json index dba42f9a92..757096629e 100644 --- a/test/models.json +++ b/test/models.json @@ -329,13 +329,6 @@ "format": "Caffe v2", "link": "https://github.com/lutzroeder/netron/issues/276" }, - { - "type": "caffe", - "target": "caffenet.prototxt", - "source": "https://raw.githubusercontent.com/cwlacewe/netscope/master/presets/caffenet.prototxt", - "format": "Caffe v2", - "link": "https://github.com/cwlacewe/netscope" - }, { "type": "caffe", "target": "cifar10_full_sigmoid_solver_bn.prototxt,cifar10_full_sigmoid_train_test_bn.prototxt", @@ -350,13 +343,6 @@ "format": "Caffe v2", "link": "https://github.com/lutzroeder/netron/issues/276" }, - { - "type": "caffe", - "target": "conv.prototxt", - "source": "https://raw.githubusercontent.com/BVLC/caffe/master/examples/net_surgery/conv.prototxt", - "format": "Caffe v2", - "link": "https://github.com/BVLC/caffe/tree/master/examples/net_surgery" - }, { "type": "caffe", "target": "deepyeast.caffemodel.zip", @@ -399,13 +385,6 @@ "format": "Caffe v2", "link": "https://github.com/cwlacewe/netscope" }, - { - "type": "caffe", - "target": "fasterRCNN_VGG.prototxt", - "source": "https://raw.githubusercontent.com/cwlacewe/netscope/master/presets/fasterRCNN_VGG.prototxt", - "format": "Caffe v2", - "link": "https://github.com/cwlacewe/netscope" - }, { "type": "caffe", "target": "fasterRCNN_ZynqNet.prototxt", @@ -448,13 +427,6 @@ "format": "Caffe v2", "link": "https://github.com/cwlacewe/netscope" }, - { - "type": "caffe", - "target": "inceptionv3_orig.prototxt", - "source": "https://raw.githubusercontent.com/cwlacewe/netscope/master/presets/inceptionv3_orig.prototxt", - "format": "Caffe v2", - "link": "https://github.com/cwlacewe/netscope" - }, { "type": "caffe", "target": "inceptionv4.prototxt", @@ -469,13 +441,6 @@ "format": "Caffe v2", "link": "https://github.com/cwlacewe/netscope" }, - { - "type": "caffe", - "target": "inceptionv4_resnet.prototxt", - "source": "https://raw.githubusercontent.com/cwlacewe/netscope/master/presets/inceptionv4_resnet.prototxt", - "format": "Caffe v2", - "link": "https://github.com/cwlacewe/netscope" - }, { "type": "caffe", "target": "lenet_consolidated_solver.prototxt", @@ -483,13 +448,6 @@ "format": "Caffe v1", "link": "https://github.com/BVLC/caffe/tree/master/examples/mnist" }, - { - "type": "caffe", - "target": "lenet.prototxt", - "source": "https://raw.githubusercontent.com/BVLC/caffe/master/examples/mnist/lenet.prototxt", - "format": "Caffe v2", - "link": "https://github.com/BVLC/caffe/tree/master/examples/mnist" - }, { "type": "caffe", "target": "linreg.prototxt",