Skip to content

Commit

Permalink
Update hailo.js (#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Nov 28, 2023
1 parent 787bcc9 commit f61536f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
16 changes: 3 additions & 13 deletions source/hailo.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ hailo.Graph = class {
entry[1].name = entry[0];
return entry[1];
});
for (const layer of layers) {
for (let i = 0; i < layer.input.length; i++) {
const name = layer.input[i];
const shape = layer.input_shapes ? layer.input_shapes[i] : null;
const type = shape ? new hailo.TensorType('?', new hailo.TensorShape(shape)) : null;
arg(name, type);
}
}
for (const layer of layers) {
switch (layer.type) {
case 'input_layer':
Expand Down Expand Up @@ -243,13 +235,11 @@ hailo.Container = class {

static open(context) {
const identifier = context.identifier;
const parts = identifier.split('.');
const extension = parts.pop().toLowerCase();
const basename = parts.join('.');
if (extension === 'hn') {
const match = identifier.match(/^(.*?)\.(fp.hn|native\.hn|hn)$/);
if (match && match[2] === 'hn') {
const configuration = context.peek('json');
if (configuration && configuration.name && configuration.net_params && configuration.layers) {
return new hailo.Container(context, basename, configuration);
return new hailo.Container(context, match[1], configuration);
}
}
return null;
Expand Down
5 changes: 2 additions & 3 deletions source/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -5678,16 +5678,15 @@ view.ModelFactoryService = class {
matches.some((context) => context.identifier.toLowerCase().split('/').pop() === 'config.json')) {
matches = matches.filter((context) => context.identifier.toLowerCase().split('/').pop() == 'model.weights.h5' || context.identifier.toLowerCase().split('/').pop() === 'model.weights.npz');
}
if ((matches.length === 2) &&
if (matches.length === 2 &&
matches.some((context) => context.identifier.toLowerCase().split('/').pop() === 'config.json') &&
matches.some((context) => context.identifier.toLowerCase().split('/').pop() === 'metadata.json')) {
matches = matches.filter((context) => context.identifier.toLowerCase().split('/').pop() == 'config.json');
}
// Hailo
if (matches.length >= 2 &&
matches.some((context) => context.identifier.toLowerCase().endsWith('.hn'))) {
matches = matches.filter((context) => !context.identifier.toLowerCase().endsWith('.native.hn'));
matches = matches.filter((context) => !context.identifier.toLowerCase().endsWith('.npz'));
matches = matches.filter((context) => context.identifier.toLowerCase().endsWith('.hn'));
}
if (matches.length > 1) {
throw new view.ArchiveError('Archive contains multiple model files.');
Expand Down

0 comments on commit f61536f

Please sign in to comment.