face-api.js load image file from disk

喜你入骨 提交于 2020-01-16 08:14:07

问题


I tried the following to load an image from disk using face-api.js:

faceapi.fetchImage(path.resolve(INPUT_DIR, 'input1.jpg');

It throws the following error: Error: fetch - missing fetch implementation for nodejs environment

Is there any other way of load image from disk and displaying using nodejs?


回答1:


The reason it fails because you need to implements the fetch function for it to work. FetchImage should be used when you are trying to retrieve the image from online. If you are using the image from local disk, then do this:

  1. Load the modules from local disk.

    await faceapi.nets.ssdMobilenetv1.loadFromDisk(path.join(__dirname, 'models'));
    

    // for me, I have put all the modules in src/models/

  2. Load the canvas

  3. Pass the canvas and modules option (if any)

    let detectionresult = awaitfaceapi.detectAllFaces(canvas, this.getSSNMobileOptions())
    


来源:https://stackoverflow.com/questions/53685344/face-api-js-load-image-file-from-disk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!