You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an error when attempting to use face-api.js in a Node.js environment with a node-canvas generated canvas. The error occurs when trying to pass a canvas to the toNetInput function. The error message is:
Error: toNetInput - expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id at /path/to/node_modules/face-api.js/build/commonjs/dom/toNetInput.js:38:35 ...
I'm using node-canvas to load an image, resize it, and then create a canvas using createCanvas from the node-canvas package.
The canvas (localCanvas) is created and drawn onto, but when I try to pass it to face-api.js via the toNetInput function, it throws the above error.
} catch (error) {
console.error('Error in loginFacial:', error);
res.status(500).json({ message: 'Internal Server Error' });
}
};
`
I am passing the localCanvas (created by node-canvas) directly to face-api.js via faceapi.toNetInput(localCanvas). Even though localCanvas is a valid canvas object from node-canvas, the error suggests that face-api.js does not accept it as valid input. The toNetInput function seems to expect a standard HTMLCanvasElement, HTMLImageElement, or HTMLVideoElement from the browser context, but this is not a browser environment.
face-api.js should accept a node-canvas canvas object when running in a Node.js environment, as it can handle it properly for face detection.
I'm encountering an error when attempting to use face-api.js in a Node.js environment with a node-canvas generated canvas. The error occurs when trying to pass a canvas to the toNetInput function. The error message is:
Error: toNetInput - expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id at /path/to/node_modules/face-api.js/build/commonjs/dom/toNetInput.js:38:35 ...
I'm using node-canvas to load an image, resize it, and then create a canvas using createCanvas from the node-canvas package.
The canvas (localCanvas) is created and drawn onto, but when I try to pass it to face-api.js via the toNetInput function, it throws the above error.
`export const loginFacial = async (req, res) => {
try {
const { username } = req.body;
} catch (error) {
console.error('Error in loginFacial:', error);
res.status(500).json({ message: 'Internal Server Error' });
}
};
`
I am passing the localCanvas (created by node-canvas) directly to face-api.js via faceapi.toNetInput(localCanvas). Even though localCanvas is a valid canvas object from node-canvas, the error suggests that face-api.js does not accept it as valid input. The toNetInput function seems to expect a standard HTMLCanvasElement, HTMLImageElement, or HTMLVideoElement from the browser context, but this is not a browser environment.
face-api.js should accept a node-canvas canvas object when running in a Node.js environment, as it can handle it properly for face detection.
face-api.js version: 0.22.2
node-canvas version: 3.1.0
Node.js version: 18.20.4
The text was updated successfully, but these errors were encountered: