File tree Expand file tree Collapse file tree 2 files changed +48
-5
lines changed Expand file tree Collapse file tree 2 files changed +48
-5
lines changed Original file line number Diff line number Diff line change 1+ # MobileNet tfjs-backend-nodegl Demo
2+
3+ * This is a very early demo to show how tfjs-backend-nodegl can be used for headless WebGL acceleration.*
4+
5+ To run this demo, perform the following:
6+
7+ 1 . Move into ` tfjs-backend-nodegl ` (parent directory of this demo folder):
8+ ``` sh
9+ $ cd tfjs-backend-nodegl
10+ ```
11+
12+ 2 . Build package and compile TypeScript:
13+ ``` sh
14+ $ yarn && yarn tsc
15+ ```
16+
17+ 3 . Move into the demo directory:
18+ ``` sh
19+ $ cd demo
20+ ```
21+
22+ 4 . Prep and build demo:
23+ ``` sh
24+ $ yarn
25+ ```
26+
27+ 5 . Run demo:
28+ ``` sh
29+ $ node run_mobilenet_inference.js dog.jpg
30+ ```
31+
32+ Expected output:
33+ ``` sh
34+ $ node run_mobilenet_inference.js dog.jpg
35+ Platform node has already been set. Overwriting the platform with [object Object].
36+ - gl.VERSION: OpenGL ES 3.0 (ANGLE 2.1.0.9512a0ef062a)
37+ - gl.RENDERER: ANGLE (Intel Inc., Intel(R) Iris(TM) Plus Graphics 640, OpenGL 4.1 core)
38+ - Loading model...
39+ - Mobilenet load: 6450.763924002647ms
40+ - Coldstarting model...
41+ - Mobilenet cold start: 297.92842200398445ms
42+ - Running inference (100x) ...
43+ - Mobilenet inference: (100x) : 35.75772546708584ms
44+ ```
Original file line number Diff line number Diff line change @@ -22,13 +22,12 @@ const jpeg = require('jpeg-js');
2222
2323const backendNodeGL = require ( './../dist/index' ) ;
2424
25- console . log ( ` - gl.VERSION: ${
26- backendNodeGL . gl . getParameter ( backendNodeGL . gl . VERSION ) } `) ;
27- console . log ( ` - gl.RENDERER: ${
28- backendNodeGL . gl . getParameter ( backendNodeGL . gl . RENDERER ) } `) ;
25+ const gl = tf . backend ( ) . getGPGPUContext ( ) . gl ;
26+ console . log ( ` - gl.VERSION: ${ gl . getParameter ( gl . VERSION ) } ` ) ;
27+ console . log ( ` - gl.RENDERER: ${ gl . getParameter ( gl . RENDERER ) } ` ) ;
2928
3029const NUMBER_OF_CHANNELS = 3 ;
31- const PREPROCESS_DIVISOR = tf . scalar ( 255 / 2 ) ;
30+ const PREPROCESS_DIVISOR = 255 / 2 ;
3231
3332function readImageAsJpeg ( path ) {
3433 return jpeg . decode ( fs . readFileSync ( path ) , true ) ;
You can’t perform that action at this time.
0 commit comments