gpt4 book ai didi

node.js - face-api.js 从磁盘加载图像文件

转载 作者:太空宇宙 更新时间:2023-11-03 22:58:34 25 4
gpt4 key购买 nike

我尝试使用face-api.js从磁盘加载图像:

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

它抛出以下错误:错误:fetch - 缺少 Nodejs 环境的 fetch 实现

还有其他方法可以从磁盘加载图像并使用nodejs显示吗?

最佳答案

documentation建议您使用canvas做这样的事情:

const canvas = require('canvas');
faceapi.env.monkeyPatch({ Canvas, Image })
const img = await canvas.loadImage('./img.jpg');
const detections = await faceapi.detectSingleFace(img);

fetchImage will not work with local files :

faceapi.fetchImage as the name implies uses fetch under the hood, thus it doesn't work with filepaths to local files.

关于node.js - face-api.js 从磁盘加载图像文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53685344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com