I try to run deep lab model javascript on video here but I get the error Unhandled Rejection (Error): The dtype of dict['ImageTensor'] provided in model.execute(dict) must be int32, but was float32 , here is my code
import React,{useEffect,useRef} from "react";
import Webcam from "react-webcam";
import * as tf from "@tensorflow/tfjs"
import * as deeplab from "@tensorflow-models/deeplab"
const Webcamera = () => {
const webcamref = useRef(null)
const loadModel = async () => {
const modelName = 'ade20k'; // set to your preferred model, either `pascal`, `cityscapes` or `ade20k`
const quantizationBytes = 2; // either 1, 2 or 4
const model = await deeplab.load({base: modelName, quantizationBytes});
setInterval(() => {
detect(model)
},100)
};
const detect = async (model) => {
if(typeof webcamref.current!=undefined && webcamref.current!=null && webcamref.current.video.readyState === 4 ){
const video = webcamref.current.video
const videowidth = webcamref.current.video.videowidth
const videoheight = webcamref.current.video.videoheight
webcamref.current.video.videowidth = videowidth
webcamref.current.video.videoheight = videoheight
model.segment(video)
}
}
useEffect(()=>{loadModel()}, []);
return <Webcam ref={webcamref}/>
}
export default Webcamera