Skip to content

Commit

Permalink
Add Caffe test file
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Dec 20, 2020
1 parent f11c219 commit f3c676d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 15 additions & 3 deletions source/caffe.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ caffe.ModelFactory = class {
file = file.split('/').pop();
return context.request(file, null).then((stream) => {
const buffer = stream.peek();
return this._openNetParameterText(metadata, buffer);
return this._openNetParameterText(metadata, file, buffer);
}).catch((error) => {
if (error) {
const message = error && error.message ? error.message : error.toString();
Expand All @@ -73,7 +73,7 @@ caffe.ModelFactory = class {
}
}
else if (tags.has('layer') || tags.has('layers')) {
return this._openNetParameterText(metadata, context.stream.peek());
return this._openNetParameterText(metadata, context.identifier, context.stream.peek());
}
else {
let netParameter = null;
Expand All @@ -91,7 +91,7 @@ caffe.ModelFactory = class {
});
}

_openNetParameterText(metadata, buffer) {
_openNetParameterText(metadata, identifier, buffer) {
let netParameter = null;
try {
const reader = protobuf.TextReader.create(buffer);
Expand Down Expand Up @@ -128,6 +128,18 @@ caffe.ModelFactory = class {
}
return type[token];
};
if (/MobileNetSSD_train_template.prototxt/.exec(identifier)) {
reader.integer = function() {
const token = this.token();
const value = Number.parseInt(token, 10);
this.next();
this.semicolon();
if (Number.isNaN(token - value)) {
return token;
}
return value;
};
}
netParameter = caffe.proto.NetParameter.decodeText(reader);
}
catch (error) {
Expand Down
7 changes: 7 additions & 0 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,13 @@
"format": "Caffe v2",
"link": "https://github.com/lutzroeder/netron/issues/358"
},
{
"type": "caffe",
"target": "MobileNetSSD_train_template.prototxt",
"source": "https://raw.githubusercontent.com/chuanqi305/MobileNet-SSD/master/template/MobileNetSSD_train_template.prototxt",
"format": "Caffe v2",
"link": "https://github.com/chuanqi305/MobileNet-SSD"
},
{
"type": "caffe",
"target": "mnist_siamese_solver.prototxt,mnist_siamese_train_test.prototxt",
Expand Down

0 comments on commit f3c676d

Please sign in to comment.