我正在构建一个nodejs函数,它比较两个配置文件图片,并使用@vladmandic/face-api返回结果,但它一直给我错误TypeError:loadImage不是函数
const { loadFaceApi, loadImage, FaceMatcher, createCanvas, saveFile } = require('@vladmandic/face-api');
exports.compareImages = async (source,uploaded)=>{
// Load the Face API model
const faceApi = await loadFaceApi;
// Load the images you want to compare
const image1 = await loadImage( "./uploads/pic1.jpg");
const image2 = await loadImage("./uploads/pic2.jpg");
// Detect faces in the images
const detections1 = await faceApi.detect(source);
const detections2 = await faceApi.detect(uploaded);
// Create FaceMatcher with the detected faces
const faceMatcher = new FaceMatcher(detections1);
// Find the best match for each face in the second image
const bestMatches = detections2.map((detection) => faceMatcher.findBestMatch(detection.descriptor));
// Output the best match results
bestMatches.forEach((match, index) => {
console.log(`Face ${index + 1}: ${match.toString()}`);
});
}
// Call the compareImages function to start the comparison
// compareImages().catch((error) => {
// console.error(error);
// });
我已经谷歌的错误,并没有能够得到一个解决方案,我实际上试图写一个函数,采取在两个个人资料图片和比较他们,如果它是同一个人在他们
1条答案
按热度按时间jyztefdp1#
看起来在@vladmandic/face-api库中没有函数loadImage。我正在使用node.js,安装了最新版本
@vladmandic/face-api v1.7.12
和最新版本@tensorflow/tfjs-node v4.11.0
。如何安装lib?你能给予更多的信息吗?