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

Error: 'faceapi' is not defined.

Open yinglanh opened this issue 6 years ago • 38 comments

Hi thanks for your sharing, but I don't know why this can't work. Could you help me? Any advice will be appreciate!

/script.js faceapi is not defined browser 'faceapi' is not defined. (no-undef) eslint

Screen Shot 2019-10-03 at 9 01 04 am

yinglanh avatar Oct 02 '19 23:10 yinglanh

It looks like you are not including the faceapi script in your HTML file.

On Wed, Oct 2, 2019 at 6:04 PM yinglanh [email protected] wrote:

Hi thanks for your sharing, but I don't know why this can't work. Could you help me? Any advice will be appreciate!

/script.js faceapi is not defined browser 'faceapi' is not defined. (no-undef) eslint

[image: Screen Shot 2019-10-03 at 9 01 04 am] https://user-images.githubusercontent.com/48505160/66087958-af597a80-e5bc-11e9-9faa-7b99646aa7a9.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/8?email_source=notifications&email_token=AJPAR22S3PTUL2RRL3OSMJ3QMUSJRA5CNFSM4I44NEK2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HPIMOUQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AJPAR2ZUGXHO5WTEJBDWOBLQMUSJRANCNFSM4I44NEKQ .

WebDevSimplified avatar Oct 02 '19 23:10 WebDevSimplified

It looks like you are not including the faceapi script in your HTML file.

I do. But I don't know for some reason it just doesn't work.

Screen Shot 2019-10-03 at 9 09 11 am

yinglanh avatar Oct 02 '19 23:10 yinglanh

Interesting. Could it possible be the editor you are using? I am not sure what editor you are using, but it is much different than anything I have ever seen.

On Wed, Oct 2, 2019 at 6:11 PM yinglanh [email protected] wrote:

It looks like you are not including the faceapi script in your HTML file. … <#m_6062900433162855676_>

I do. But I don't know for some reason it just doesn't work.

[image: Screen Shot 2019-10-03 at 9 09 11 am] https://user-images.githubusercontent.com/48505160/66088166-900f1d00-e5bd-11e9-9f66-78253745afb1.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/8?email_source=notifications&email_token=AJPAR265DWMJEXOVQV7PCQLQMUTAXA5CNFSM4I44NEK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAGPDYI#issuecomment-537719265, or mute the thread https://github.com/notifications/unsubscribe-auth/AJPAR26SX4PZGOCBGCSN4ZLQMUTAXANCNFSM4I44NEKQ .

WebDevSimplified avatar Oct 03 '19 12:10 WebDevSimplified

Interesting. Could it possible be the editor you are using? I am not sure what editor you are using, but it is much different than anything I have ever seen. On Wed, Oct 2, 2019 at 6:11 PM yinglanh @.***> wrote: It looks like you are not including the faceapi script in your HTML file. … <#m_6062900433162855676_> I do. But I don't know for some reason it just doesn't work. [image: Screen Shot 2019-10-03 at 9 09 11 am] https://user-images.githubusercontent.com/48505160/66088166-900f1d00-e5bd-11e9-9f66-78253745afb1.png — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#8?email_source=notifications&email_token=AJPAR265DWMJEXOVQV7PCQLQMUTAXA5CNFSM4I44NEK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAGPDYI#issuecomment-537719265>, or mute the thread https://github.com/notifications/unsubscribe-auth/AJPAR26SX4PZGOCBGCSN4ZLQMUTAXANCNFSM4I44NEKQ .

I tried to just clone this and ran in the codesandbox and webstorm, it seems like something run with the face-api.min.js file, both editors cannot load this file. But I solved it by deleting this file and add a new dependency to the face-api. Anyway, thanks for your reply, really appreciate it.

yinglanh avatar Oct 04 '19 02:10 yinglanh

@yinglanh can you please post the code of how you solved it.

foluwright avatar Oct 05 '19 03:10 foluwright

how did you add a dependency to the file face-api?

Bea98 avatar Oct 14 '19 10:10 Bea98

The HTML has a script tag for the face-api library which is included in this repository.

On Mon, Oct 14, 2019 at 5:45 AM Bea98 [email protected] wrote:

how did you add a dependency to the file face-api?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/8?email_source=notifications&email_token=AJPAR24HGWMVS7VCTNI6NL3QORET3A5CNFSM4I44NEK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBEEEHY#issuecomment-541606431, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPAR25CVIAPLXOMXN3FS6TQORET3ANCNFSM4I44NEKQ .

WebDevSimplified avatar Oct 14 '19 23:10 WebDevSimplified

So I'm still getting this error. MY script tag looks like this: <script defer src="./face-api.min.js"></script> what's wrong with it

Stanlyhalo avatar Oct 15 '19 02:10 Stanlyhalo

Did you copy the code from the repository to ensure it is the same? Also have you checked the logs in your console to ensure that the path to the face-api library is correct and loading correctly?

On Mon, Oct 14, 2019, 9:01 PM Stanlyhalo [email protected] wrote:

So I'm still getting this error. MY script tag looks like this:

what's wrong with it

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/8?email_source=notifications&email_token=AJPAR2YCUX2KHTGFVJGA3GDQOUP7DA5CNFSM4I44NEK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBHEXJQ#issuecomment-542002086, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPAR26AABA7SMMH2DQAHL3QOUP7DANCNFSM4I44NEKQ .

WebDevSimplified avatar Oct 15 '19 10:10 WebDevSimplified

right! so now I have another problem. I can't run it cause it gives me an eror in the script that says : " document is not defined". How can I fix it? (sorry I'm new at this)

Bea98 avatar Oct 17 '19 08:10 Bea98

Sounds like you didn't defer your script tag in the HTML.

On Thu, Oct 17, 2019, 3:39 AM Bea98 [email protected] wrote:

right! so now I have another problem. I can't run it cause it gives me an eror in the script that says : " document is not defined". How can I fix it? (sorry I'm new at this)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/8?email_source=notifications&email_token=AJPAR2ZRJL26CNXDP5OFV53QPAQDTA5CNFSM4I44NEK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBPJR4Q#issuecomment-543070450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPAR2YUEXI4E4YTRIAX74TQPAQDTANCNFSM4I44NEKQ .

WebDevSimplified avatar Oct 17 '19 10:10 WebDevSimplified

I have it's there... and when I run the HTML it doesn't appear anything and gives me this error now: "Failed to load resource: the server responded with a status of 404 (Not Found)" " Uncaught (in promise) Error: failed to fetch: (404) Not Found, from url: http://localhost:63342/models/tiny_face_detector_model-weights_manifest.json at face-api.min.js:1 at face-api.min.js:1 at Object.next (face-api.min.js:1) at n (face-api.min.js:1)"

Bea98 avatar Oct 17 '19 10:10 Bea98

This is most likely because the root of your server is not at the root of your application. Try changing the path to the 404 files by add ./ at the beginning of them.

On Thu, Oct 17, 2019, 5:13 AM Bea98 [email protected] wrote:

I have it's there... and when I run the HTML it doesn't appear anything and gives me this error now: Failed to load resource: the server responded with a status of 404 (Not Found)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/8?email_source=notifications&email_token=AJPAR27TABT3Y73STW2LBZTQPA3FDA5CNFSM4I44NEK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBPSL7A#issuecomment-543106556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPAR2YYZEXBZCRDKTBFOEDQPA3FDANCNFSM4I44NEKQ .

WebDevSimplified avatar Oct 17 '19 10:10 WebDevSimplified

it works now thank you so much!

Bea98 avatar Oct 17 '19 10:10 Bea98

hey i m getting a script error : faceapi not defined Screenshot (77) evenly i added all the faceapi files Screenshot (78) Screenshot (79) could you please help me out

JSM2512 avatar Dec 20 '19 05:12 JSM2512

This is most likely because the root of your server is not at the root of your application. Try changing the path to the 404 files by add ./ at the beginning of them.(./models on the javasrcipt)

Bea98 avatar Dec 22 '19 15:12 Bea98

Screenshot (465)

Uncaught ReferenceError: faceapi is not defined at script.js:4

please help i'm new to git

mAasim1026 avatar Feb 08 '20 22:02 mAasim1026

Hi... can someone please help me with the error experience , the same as @mAasim1026 ..

Descande avatar Mar 09 '20 13:03 Descande

Hi, I am experiencing an issue. When I Downloaded the files and ran it I got a blank white screen pls help

Venexs avatar Mar 17 '20 17:03 Venexs

To me the solution was to put the absolute path on the promisses, linke this: _faceapi.nets.tinyFaceDetector.loadFromUri('/caretas/assets/lib/face-api/models'), becouse when the browser fetchs it it calls http://www.domain.com/your_project/assets/...

Hope it helps!

gabrieldocs avatar Apr 15 '20 21:04 gabrieldocs

Has anyone tried this on reactjs? Because, for me, it works when I run the code of WebDevSimplified, but I want to implement it on react. I get errors saying "faceapi is not defined.". I have included the faceapi.min in html. But it throws error in the "Promise.all" line. Could someone please help. Thanks.

RuthvikRaviKumar avatar Jun 04 '20 13:06 RuthvikRaviKumar

hey i m getting a script error : faceapi not defined Screenshot (77) evenly i added all the faceapi files Screenshot (78) Screenshot (79) could you please help me out

you can use the live server .

mfurkan60 avatar Aug 15 '20 23:08 mfurkan60

please dont send your mail to me

On Sun, Aug 16, 2020 at 4:35 AM Mert ERGÜDEN [email protected] wrote:

hey i m getting a script error : faceapi not defined [image: Screenshot (77)] https://user-images.githubusercontent.com/49087609/71233135-a2763880-231a-11ea-83b3-870b1790f83b.png evenly i added all the faceapi files [image: Screenshot (78)] https://user-images.githubusercontent.com/49087609/71233168-ba4dbc80-231a-11ea-9e24-2e921e6680ad.png [image: Screenshot (79)] https://user-images.githubusercontent.com/49087609/71233198-d6e9f480-231a-11ea-834d-3e873d927c6a.png could you please help me out

you can use the live server .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/8#issuecomment-674455897, or unsubscribe https://github.com/notifications/unsubscribe-auth/AON3XCF6OO7YRDLLXUNMJKLSA4ICTANCNFSM4I44NEKQ .

anirudh274 avatar Aug 20 '20 08:08 anirudh274

Hello 1- You can just add scripts in this order:

2- use live-server to open index.html file

obSoftMind avatar Aug 20 '20 16:08 obSoftMind

Hi, I am experiencing an issue. When I Downloaded the files and ran it I got a blank white screen pls help

hey try this code:- if (navigator.mediaDevices.getUserMedia) { navigator.mediaDevices.getUserMedia({ video: true }) .then(function(stream) { video.srcObject = stream; }) .catch(function(err0r) { console.log("Something went wrong!"); }); }

Insted of this :- // function startVideo() { // navigator.getUserMedia({ video: {} }, // stream => video.srcObject = stream, // err => console.error(err) // ) // }

-> But the main thing is the uncaught error faceapi-not defined.

srk0102 avatar Aug 23 '20 11:08 srk0102

please how did you solve it ??

abdullahalmasri avatar Sep 05 '20 14:09 abdullahalmasri

@Bea98 may you help me to solve the errors

abdullahalmasri avatar Sep 05 '20 14:09 abdullahalmasri

Hello everyone, I may have found the problem. I had the same error faceapi is not defined. It seems to be caused by the compiler/bundler/local server you are using. I used Parcel when I got the error. Using live server solved it for me.

Another solution I found is using npm live-server. It hosts de root directory as a server so you can host other folders as well.

TortleTurtle avatar Oct 28 '20 13:10 TortleTurtle

Hi, I get this error from my p5 (p5.js says: There's an error due to "faceapi" not being defined in the current scope)(and so I get a face api not defined). Is face api and P5.js not compatible? Thanks!

Oceanestars avatar Nov 16 '20 07:11 Oceanestars

you save my life =))

trungdzung9900 avatar Dec 14 '20 08:12 trungdzung9900