@@ -104,7 +104,7 @@ export async function buildConstantByNpy(builder, url, targetType = 'float32') {
104
104
if ( ! dataTypeMap . has ( npArray . dataType ) ) {
105
105
throw new Error ( `Data type ${ npArray . dataType } is not supported.` ) ;
106
106
}
107
- const dimensions = npArray . shape ;
107
+ const shape = npArray . shape ;
108
108
let type = dataTypeMap . get ( npArray . dataType ) . type ;
109
109
const TypedArrayConstructor = dataTypeMap . get ( npArray . dataType ) . array ;
110
110
const dataView = new Uint8Array ( npArray . data . buffer ) ;
@@ -121,7 +121,8 @@ export async function buildConstantByNpy(builder, url, targetType = 'float32') {
121
121
throw new Error ( `Conversion from ${ npArray . dataType } ` +
122
122
`to ${ targetType } is not supported.` ) ;
123
123
}
124
- return builder . constant ( { dataType : type , dimensions} , typedArray ) ;
124
+ return builder . constant (
125
+ { dataType : type , dimensions : shape , shape} , typedArray ) ;
125
126
}
126
127
127
128
// Convert video frame to a canvas element
@@ -162,7 +163,7 @@ export function stopCameraStream(id, stream) {
162
163
* input element.
163
164
* inputOptions = {
164
165
* inputLayout {String}, // input layout of tensor.
165
- * inputDimensions : {!Array<number>}, // dimensions of input tensor.
166
+ * inputShape : {!Array<number>}, // shape of input tensor.
166
167
* mean: {Array<number>}, // optional, mean values for processing the input
167
168
* element. If not specified, it will be set to [0, 0, 0, 0].
168
169
* std: {Array<number>}, // optional, std values for processing the input
@@ -190,16 +191,16 @@ export function stopCameraStream(id, stream) {
190
191
* @return {Object } tensor, an object of input tensor.
191
192
*/
192
193
export function getInputTensor ( inputElement , inputOptions ) {
193
- const inputDimensions = inputOptions . inputDimensions ;
194
+ const inputShape = inputOptions . inputShape ;
194
195
const tensor = new Float32Array (
195
- inputDimensions . slice ( 1 ) . reduce ( ( a , b ) => a * b ) ) ;
196
+ inputShape . slice ( 1 ) . reduce ( ( a , b ) => a * b ) ) ;
196
197
197
198
inputElement . width = inputElement . videoWidth ||
198
199
inputElement . naturalWidth ;
199
200
inputElement . height = inputElement . videoHeight ||
200
201
inputElement . naturalHeight ;
201
202
202
- let [ channels , height , width ] = inputDimensions . slice ( 1 ) ;
203
+ let [ channels , height , width ] = inputShape . slice ( 1 ) ;
203
204
const mean = inputOptions . mean || [ 0 , 0 , 0 , 0 ] ;
204
205
const std = inputOptions . std || [ 1 , 1 , 1 , 1 ] ;
205
206
const normlizationFlag = inputOptions . norm || false ;
@@ -209,7 +210,7 @@ export function getInputTensor(inputElement, inputOptions) {
209
210
const imageChannels = 4 ; // RGBA
210
211
const drawOptions = inputOptions . drawOptions ;
211
212
if ( inputLayout === 'nhwc' ) {
212
- [ height , width , channels ] = inputDimensions . slice ( 1 ) ;
213
+ [ height , width , channels ] = inputShape . slice ( 1 ) ;
213
214
}
214
215
const canvasElement = document . createElement ( 'canvas' ) ;
215
216
canvasElement . width = width ;
0 commit comments