i want to connect computer vision’s model but je recontre plusieurs erreurs:
`import { Component } from ‘@angular/core’;
import * as tflite from ‘@tensorflow/tfjs-tflite’;
import { Camera, CameraResultType } from ‘@capacitor/camera’;
import * as tf from ‘@tensorflow/tfjs’;
@Component({
selector: ‘app-home’,
templateUrl: ‘home.page.html’,
styleUrls: [‘home.page.scss’],
})
export class HomePage {
model: any;
constructor() {
this.loadModel();
}
async loadModel() {
this.model = await tflite.loadTFLiteModel(‘assets/raisin.tflite’);
}`
async predict() {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: false,
resultType: CameraResultType.DataUrl
});
if (image && image.dataUrl) {
const img = new Image();
img.src = image.dataUrl;
img.onload = async () => {
const canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
const ctx = canvas.getContext('2d');
if (ctx) {
ctx.drawImage(img, 0, 0);
const imageData = ctx.getImageData(0, 0, img.width, img.height);
const inputTensor = tf.browser.fromPixels(imageData).expandDims(0).toFloat().div(tf.scalar(255.0));
const predictions = this.model.predict(inputTensor);
console.log(predictions);
} else {
console.error("Le contexte de rendu est null.");
}
};
} else {
console.error("Image dataUrl is undefined or null.");
}
}
}
in file home.ts`