Face-Recognition-JavaScript icon indicating copy to clipboard operation
Face-Recognition-JavaScript copied to clipboard

Cannot read property 'descriptor' of undefined

Open ersaurabh101 opened this issue 4 years ago • 3 comments

Hii,

I added new folder name

const labels = ['Black Widow', 'Captain America', 'Captain Marvel', 'Hawkeye', 'Jim Rhodes', 'Thor', 'Tony Stark','Bhaiya']

It has 2 images 1.jpg , 2.jpg

After adding this in labels, page is showing error in console.log

script.js:46 Uncaught (in promise) TypeError: Cannot read property 'descriptor' of undefined at script.js:46 at async Promise.all (/tensorflow-web/index 7) at async start (script.js:13)

what is wrong i am doing, here is the entire function-

function loadLabeledImages() {
  const labels = ['Black Widow', 'Captain America', 'Captain Marvel', 'Hawkeye', 'Jim Rhodes', 'Thor', 'Tony Stark','Bhaiya']
  return Promise.all(
    labels.map(async label => {
      const descriptions = []
      for (let i = 1; i <= 2; i++) {
        const img = await faceapi.fetchImage(`labeled_images/${label}/${i}.jpg`)
        const detections = await faceapi.detectSingleFace(img).withFaceLandmarks().withFaceDescriptor()
        descriptions.push(detections.descriptor)
      }

      return new faceapi.LabeledFaceDescriptors(label, descriptions)
    })
  )
}

ersaurabh101 avatar May 07 '20 20:05 ersaurabh101

have you resolve it,l got a new problem l can`t fetch the picture :|

yx-yangxiao avatar Oct 09 '20 12:10 yx-yangxiao

@ersaurabh101 This happens when it cant find a face in the image, just use clearer images

Purukitto avatar Oct 21 '20 07:10 Purukitto

i am facing the same issue, after searching it said descriptor is the numeric vector for the image it detected , since it is undefined means it did not detect any face at all, i dont know how to resolve it either.

deepsingh245 avatar Apr 18 '23 12:04 deepsingh245