Skip to content

Commit

Permalink
Update coreml.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Mar 3, 2024
1 parent cfea826 commit e3b9a09
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions source/coreml.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,13 @@ coreml.ModelFactory = class {
const extension = identifier.split('.').pop().toLowerCase();
const tags = context.tags('pb');
if (tags.get(1) === 0 && tags.get(2) === 2) {
if (extension === 'pb') {
const tags = context.tags('pb+');
const keys = Object.keys(tags).map((key) => parseInt(key, 10));
const match = (key) =>
(key >= 200 && key < 220) ||
(key >= 300 && key < 320) ||
(key >= 400 && key < 420) ||
(key >= 500 && key < 520) ||
(key >= 550 && key < 560) ||
(key >= 600 && key < 620) ||
(key === 900) ||
(key >= 2000 && key < 2010) ||
(key === 3000);
if (!keys.some((key) => match(key))) {
return;
}
const match = (key) =>
(key >= 200 && key < 220) || (key >= 300 && key < 320) || (key >= 400 && key < 420) ||
(key >= 500 && key < 520) || (key >= 550 && key < 560) || (key >= 600 && key < 620) ||
(key === 900) ||
(key >= 2000 && key < 2010) || (key === 3000);
if (extension === 'pb' && Array.from(tags.keys()).every((key) => !match(key))) {
return;
}
context.type = 'coreml.pb';
return;
Expand Down

0 comments on commit e3b9a09

Please sign in to comment.