【发布时间】:2021-09-13 19:10:15
【问题描述】:
我是 TensorFlowJS 的新手。我使用 Google Colab 使用 TensorFlow Lite Model Maker 创建和训练模型,将其转换为 TFJS,然后在 Angular 应用程序中使用它。
在 colab 中,模型达到了很高的准确率。我已经使用以下方法保存了模型:
model.export(export_dir='.', export_format=ExportFormat.SAVED_MODEL);
然后我用
tfjs.converters.convert_tf_saved_model('saved_model','tfjsconvertido');
为了获得tfjs。在角度,我正在使用:
async fazerPrevisao(modelo: tf.GraphModel){
const batched = tf.tidy(() => {
const im = new Image();
im.src = this.foto.webviewPath;
im.height = 224;
im.width = 224;
const imagem = tf.cast(tf.browser.fromPixels(im).reshape([-1,224,224,3]),'float32');
this.prediction = modelo.predict(imagem);
this.prediction.print();
});
}
角度结果与 Colab 相差太大。在某些情况下,结果标签不正确,甚至得到正确的标签,概率的值也完全不同。会是什么?
提前致谢。
【问题讨论】:
标签: angular prediction tensorflow.js