@@ -81,26 +81,6 @@ async function fetchLabels(url) {
81
81
return data . split ( '\n' ) ;
82
82
}
83
83
84
- function displayAvailableModels ( modelList , deviceType , dataType ) {
85
- let models = [ ] ;
86
- if ( dataType == '' ) {
87
- models = models . concat ( modelList [ deviceType ] [ 'float32' ] ) ;
88
- models = models . concat ( modelList [ deviceType ] [ 'float16' ] ) ;
89
- } else {
90
- models = models . concat ( modelList [ deviceType ] [ dataType ] ) ;
91
- }
92
- // Remove duplicate ids.
93
- models = [ ...new Set ( models ) ] ;
94
- // Display available models.
95
- for ( const model of modelIds ) {
96
- if ( models . includes ( model ) ) {
97
- $ ( `#${ model } ` ) . parent ( ) . show ( ) ;
98
- } else {
99
- $ ( `#${ model } ` ) . parent ( ) . hide ( ) ;
100
- }
101
- }
102
- }
103
-
104
84
$ ( document ) . ready ( async ( ) => {
105
85
$ ( '.icdisplay' ) . hide ( ) ;
106
86
if ( await utils . isWebNN ( ) ) {
@@ -114,24 +94,25 @@ $('#backendBtns .btn').on('change', async (e) => {
114
94
if ( inputType === 'camera' ) {
115
95
await stopCamRender ( ) ;
116
96
}
117
- layout = utils . getDefaultLayout ( $ ( e . target ) . attr ( 'id' ) ) ;
118
- [ backend , deviceType ] = $ ( e . target ) . attr ( 'id' ) . split ( '_' ) ;
97
+ const backendId = $ ( e . target ) . attr ( 'id' ) ;
98
+ layout = utils . getDefaultLayout ( backendId ) ;
99
+ [ backend , deviceType ] = backendId . split ( '_' ) ;
119
100
// Only show the supported models for each deviceType. Now fp16 nchw models
120
101
// are only supported on gpu/npu.
121
- if ( deviceType == 'gpu ' ) {
102
+ if ( backendId == 'webnn_gpu ' ) {
122
103
ui . handleBtnUI ( '#float16Label' , false ) ;
123
104
ui . handleBtnUI ( '#float32Label' , false ) ;
124
- displayAvailableModels ( modelList , deviceType , dataType ) ;
125
- } else if ( deviceType == 'npu ' ) {
105
+ utils . displayAvailableModels ( modelList , modelIds , deviceType , dataType ) ;
106
+ } else if ( backendId == 'webnn_npu ' ) {
126
107
ui . handleBtnUI ( '#float16Label' , false ) ;
127
108
ui . handleBtnUI ( '#float32Label' , true ) ;
128
109
$ ( '#float16' ) . click ( ) ;
129
- displayAvailableModels ( modelList , deviceType , 'float16' ) ;
110
+ utils . displayAvailableModels ( modelList , modelIds , deviceType , 'float16' ) ;
130
111
} else {
131
112
ui . handleBtnUI ( '#float16Label' , true ) ;
132
113
ui . handleBtnUI ( '#float32Label' , false ) ;
133
114
$ ( '#float32' ) . click ( ) ;
134
- displayAvailableModels ( modelList , deviceType , 'float32' ) ;
115
+ utils . displayAvailableModels ( modelList , modelIds , deviceType , 'float32' ) ;
135
116
}
136
117
137
118
// Uncheck selected model
@@ -163,7 +144,7 @@ $('#modelBtns .btn').on('change', async (e) => {
163
144
164
145
$ ( '#dataTypeBtns .btn' ) . on ( 'change' , async ( e ) => {
165
146
dataType = $ ( e . target ) . attr ( 'id' ) ;
166
- displayAvailableModels ( modelList , deviceType , dataType ) ;
147
+ utils . displayAvailableModels ( modelList , modelIds , deviceType , dataType ) ;
167
148
// Uncheck selected model
168
149
if ( modelId != '' ) {
169
150
$ ( `#${ modelId } ` ) . parent ( ) . removeClass ( 'active' ) ;
0 commit comments