Я преобразовал модель Keras в tf js и при запуске в браузере получаю следующее предупреждение:
topology.ts: 1114 Форма входного тензора ([null, 1024 ]) не соответствует ожиданию плотного слоя: [null, [224,224,3]]
Сводка модели выглядит следующим образом:
_________________________________________________________________
Layer (type) Output shape Param #
=================================================================
mobilenet_1.00_224 (Model) [null,1024] 3228864
_________________________________________________________________
dense (Dense) [null,256] 262400
_________________________________________________________________
dropout (Dropout) [null,256] 0
_________________________________________________________________
dense_1 (Dense) [null,512] 131584
_________________________________________________________________
dropout_1 (Dropout) [null,512] 0
_________________________________________________________________
dense_2 (Dense) [null,7] 3591
=================================================================
Total params: 3626439
Trainable params: 397575
Non-trainable params: 3228864
Для прогноза, который я реализовал следующий метод:
async function classifyImage() {
const cam = await tf.data.webcam(video); //video is a webcam element with 224x224 pixels
const img = await cam.capture();
console.log(img.shape);
let new_frame = img.reshape([1, 224, 224, 3]);
predictions = await model.predict(new_frame).print();
}
Как я могу решить предупреждение?