Skip to content

Commit

Permalink
Fix DeepLearning4j Zip detection
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Jan 27, 2020
1 parent cce1991 commit 8722cd7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1375,17 +1375,19 @@ view.ModelFactoryService = class {
else {
if (matches.length == 0) {
return Promise.resolve(sourceContext);
// return Promise.reject(new ArchiveError('Archive does not contain model file.'));
}
else if (matches.length > 1) {
if (matches.length == 2 &&
matches.some((e) => e.name.endsWith('.params')) &&
matches.some((e) => e.name.endsWith('-symbol.json'))) {
matches = matches.filter((e) => e.name.endsWith('.params'));
}
else {
return Promise.reject(new ArchiveError('Archive contains multiple model files.'));
}
if (matches.length > 0 &&
matches.some((e) => e.name.endsWith('.bin')) &&
archive.entries.some((e) => e.name.endsWith('.json'))) {
return Promise.resolve(context); // dl4j
}
if (matches.length == 2 &&
matches.some((e) => e.name.endsWith('.params')) &&
matches.some((e) => e.name.endsWith('-symbol.json'))) {
matches = matches.filter((e) => e.name.endsWith('.params'));
}
else {
return Promise.reject(new ArchiveError('Archive contains multiple model files.'));
}
const match = matches[0];
return Promise.resolve(new ModelContext(new ArchiveContext(archive.entries, rootFolder, match.name, match.data)));
Expand Down

0 comments on commit 8722cd7

Please sign in to comment.