-
Notifications
You must be signed in to change notification settings - Fork 46
Add the OpenVINO.js framework #1383
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ class ImageClassificationExample extends BaseCameraExample { | |
case 'OpenCV.js': | ||
runner = new ImageClassificationOpenCVRunner(); | ||
break; | ||
case 'OpenVINO.js': | ||
runner = new ImageClassificationOpenVINORunner(); | ||
} | ||
runner.setProgressHandler(updateLoadingProgressComponent); | ||
return runner; | ||
|
@@ -28,6 +30,7 @@ class ImageClassificationExample extends BaseCameraExample { | |
/** @override */ | ||
_processExtra = (output) => { | ||
let labelClasses; | ||
console.log(output); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lionkunonly Please remove this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
switch (this._currentFramework) { | ||
case 'WebNN': | ||
const deQuantizeParams = this._runner.getDeQuantizeParams(); | ||
|
@@ -36,6 +39,8 @@ class ImageClassificationExample extends BaseCameraExample { | |
case 'OpenCV.js': | ||
labelClasses = getTopClasses(output.tensor, output.labels, 3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lionkunonly The case 'OpenVINO.js' uses the same code as case 'OpenCV.js', you could code as case 'OpenCV.js':
case 'OpenVINO.js': There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
break; | ||
case 'OpenVINO.js': | ||
labelClasses = getTopClasses(output.tensor, output.labels, 3); | ||
} | ||
$('#inferenceresult').show(); | ||
labelClasses.forEach((c, i) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class ImageClassificationOpenVINORunner extends OpenVINORunner { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
/** @override */ | ||
_getOutputTensor = () => { | ||
const postSoftmax = this._postOptions.softmax || false; | ||
let outputTensor; | ||
if(postSoftmax) { | ||
outputTensor = softmax(this._output); | ||
} else { | ||
outputTensor = this._output; | ||
} | ||
return outputTensor; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class SemanticSegmentationOpenVINORunner extends OpenVINORunner { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
/** @override */ | ||
_getOutputTensorTypedArray = () => { | ||
return Int32Array; | ||
}; | ||
|
||
/** @override */ | ||
_getOutputTensor = () => { | ||
let outputTensor = this._output; | ||
return outputTensor; | ||
}; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,14 @@ class SpeechCommandsExample extends BaseMircophoneExample { | |
|
||
/** @override */ | ||
_createRunner = () => { | ||
const runner = new WebNNRunner(); | ||
let runner; | ||
switch (this._currentFramework) { | ||
case 'WebNN': | ||
runner = new WebNNRunner(); | ||
break; | ||
case 'OpenVINO.js': | ||
runner = new OpenVINORunner(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lionkunonly Here missed a 'break' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
runner.setProgressHandler(updateLoadingProgressComponent); | ||
return runner; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,14 @@ class SpeechRecognitionExample extends BaseMircophoneExample { | |
|
||
/** @override */ | ||
_createRunner = () => { | ||
const runner = new SpeechRecognitionRunner(); | ||
let runner; | ||
switch (this._currentFramework) { | ||
case 'WebNN': | ||
runner = new SpeechRecognitionRunner(); | ||
break; | ||
case 'OpenVINO.js': | ||
runner = new SpeechRecognitionOpenVINORunner(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lionkunonly ditto. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
runner.setProgressHandler(updateLoadingProgressComponent); | ||
return runner; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class SpeechRecognitionOpenVINORunner extends OpenVINORunner { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
_getInputTensor = (input) => { | ||
let infer_req = this._execNet.createInferRequest(); | ||
const input_blob = infer_req.getBlob(this._inputInfo.name()); | ||
const input_data = new Float32Array(input_blob.wmap()); | ||
|
||
for(let index = 0; index < input.length; index++) { | ||
input_data[index] = input[index]; | ||
} | ||
input_blob.unmap(); | ||
this._inferReq = infer_req; | ||
}; | ||
|
||
_getOutputTensor = () => { | ||
let outputTensor = this._output; | ||
return outputTensor; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lionkunonly Here missed a 'break'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done