@vladmandic/face-api loadImage is not a function

83 Views Asked by At

am building a nodejs function that compares two profile pictures and return the result using @vladmandic/face-api but it keeps giving me the error TypeError: loadImage is not a function

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);
// });

i have googled the error and have not been able to get a solution am actually trying to write a function that take in two profile pictures and compare them if it the same person in them

1

There are 1 best solutions below

0
Anton Trofymenko On

Looks like there is no function loadImage in the @vladmandic/face-api library. I'm using node.js with latest version @vladmandic/face-api v1.7.12 and latest version @tensorflow/tfjs-node v4.11.0 installed.

How do you install the lib? May you give a bit more information?