-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Blob is not defined" fetching local images #194
Comments
Just added const Blob = require('node-fetch'); before bufferToImage function located at build/commonjs/dom/bufferToImage.js and worked fine.. |
Ahh, currently face.env.monkeyPatch doesn't patch Blob, thanks for pointing this out. Maybe as for now you could simply try to expose Blob to the global scope? |
After i define as global i get
|
@justadudewhohacks Hi, I'm getting the same error as well. the fetchImage function isnt working after monkey patching fetch |
Hi @enecumene, @justadudewhohacks I had a similar issue a few minutes ago. The only difference is that I was trying to fetch the image from the cloud (cloudinary). I solved it by using the 'loadImage' function from the node 'canvas' package i.e import { loadImage } from 'canvas'; const referenceImage = await loadImage(refImageUrl); It might work for local images. Hope this helps |
Hi! I'm working on API REST (Node v12.9.1 and Express 4.17.1) and have the same problem "Blob is not defined" when trying to fetch images from URL. I have tried all suggestions in this issue comments: 1.
2.
If i add //@ts-ignore , then i get:
I also tried creating new Image() like this:
Result:
If you have any other suggestion I would be happy to try! Thanks in advance for your amazing work @justadudewhohacks |
Same scenario with @sebacampos currently I am building rest api with node. then I encountered this. |
I am using this library in react and getting same problem with fetchImage function, could you please help me on this? |
I did this long time ago so I don't remember very well, but this was my working implementation: monkeypatching fetch AND canvas classes: import { loadImage, Canvas, Image, ImageData } from 'canvas';
// @ts-ignore
faceapi.env.monkeyPatch({ Canvas, Image, ImageData, fetch });
export const detect = async (imageUrl: string): Promise<WithFaceDescriptor<any>> => {
let canvasImage;
try {
canvasImage = await loadImage(imageUrl);
if (!canvasImage) {
throw new Error("Canvas not loaded.");
}
} catch (error) {
throw new Error("Could not load image.");
}
const faces = await detectFaces(canvasImage);
return faces[0];
}
const detectFaces = (image: any): any => faceapi.detectAllFaces(image).withFaceLandmarks().withFaceDescriptors(); Hope it helps |
Actually the issue is i am fetching my labeled faces , from node api and I
want to fetch that images with fetchImage , and it's not working,
Thanks
…On Mon, 24 Aug 2020, 7:29 p.m. Sebastian Campos, ***@***.***> wrote:
I did this long time ago so I don't remember very well, but this was my
working implementation: *monkeypatching fetch AND canvas classes:*
import { loadImage, Canvas, Image, ImageData } from 'canvas';
// @ts-ignorefaceapi.env.monkeyPatch({ Canvas, Image, ImageData, fetch });
export const detect = async (imageUrl: string): Promise<WithFaceDescriptor<any>> => {
let canvasImage;
try {
canvasImage = await loadImage(imageUrl);
if (!canvasImage) {
throw new Error("Canvas not loaded.");
}
} catch (error) {
throw new Error("Could not load image.");
}
const faces = await detectFaces(canvasImage);
return faces[0];}
const detectFaces = (image: any): any => faceapi.detectAllFaces(image).withFaceLandmarks().withFaceDescriptors();
Hope it helps
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#194 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHIVDUMFBRQ7HH6TUMZNWVTSCJW2LANCNFSM4GQETFOQ>
.
|
Hi, i testing face-api.js and trying loading a local image for make face similarity and is throw me "Blob is not defined" in my nodeJS application, here the function where i try computing descriptors:
node-fetch and blob is installed and monkeyPatched and referenceErros is still there.
Thanks
The text was updated successfully, but these errors were encountered: