Closed amitraja4606 closed 5 years ago
You need to be running the project as a server using something like vscode live server extension. This will make it so that the models and such are accessible in the way the library expects them to be.
On Tue, Jun 25, 2019, 4:19 AM amitraja4606 notifications@github.com wrote:
Hi, I downloaded your code and face-api.js library too. But when running index.html in browser I am getting blank page and below error.
face-api.min.js:1 Fetch API cannot load file:///C:/models/tiny_face_detector_model-weights_manifest.json. URL scheme must be "http" or "https" for CORS request. (anonymous) @ face-api.min.js:1 face-api.min.js:1 Fetch API cannot load file:///C:/models/face_landmark_68_model-weights_manifest.json. URL scheme must be "http" or "https" for CORS request. (anonymous) @ face-api.min.js:1 face-api.min.js:1 Fetch API cannot load file:///C:/models/face_recognition_model-weights_manifest.json. URL scheme must be "http" or "https" for CORS request. (anonymous) @ face-api.min.js:1 face-api.min.js:1 Fetch API cannot load file:///C:/models/face_expression_model-weights_manifest.json. URL scheme must be "http" or "https" for CORS request. (anonymous) @ face-api.min.js:1 face-api.min.js:1 Uncaught (in promise) TypeError: Failed to fetch at face-api.min.js:1 at face-api.min.js:1 at Object.next (face-api.min.js:1) at face-api.min.js:1 at new Promise () at p (face-api.min.js:1) at lp (face-api.min.js:1) at face-api.min.js:1 at face-api.min.js:1 at Object.next (face-api.min.js:1)
where am I missing something? Thanks in advance.
— 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/2?email_source=notifications&email_token=AJPAR257N6OXTCSCNCB5363P4HPK3A5CNFSM4H3GGL2KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G3PX2GA, or mute the thread https://github.com/notifications/unsubscribe-auth/AJPAR256TO2NTWQMVZJR2LLP4HPK3ANCNFSM4H3GGL2A .
@WebDevSimplified Whenever I run it on port 8000 it runs, but it NEVER kills. Even when I run force killing commands to kill all activity on port 8000. Next time I open up the browser, without even initializing a new local server, it will open up again.
Also, if I initialize it on a different port (eg. 1234) it throws errors to load the models and never runs. SUPER confused about this. Please help!
This sounds like it is a problem with the server setup you are using. Are you using live server through VSCode or some other server to load the pages?
@WebDevSimplified I'm using python -m http.server
The default port for this is 8000, but you can also set a specific port. Whenever I set a specific one it stops working...
edit: It's also sad, because it means I cannot add/adjust the code and play around with it. Eg. when I set it up to estimate gender and age, it also doesn't update. (yes I did save the file before running again)
I am not familiar with that library, but most likely you need to configure the server so that the models are accessible via url as well.
what do you mean accessible via urls? I'm giving it the direct path to the models. Even when I delete the entire folder with everything in it, kill my localhost:8000 (from terminal) and then check localhost:8000 it keeps connecting.
The face-api library works by accessing the models via a URL, so your models must be available at that URL. For example localhost:8000/models/model_name.json
. If your server does not also serve the models via URL it will not work. The path to the load models function is just a relative path to the current URL you are on.
@WebDevSimplified solved, for some reason they were cached in my chrome browser. When I do incognito it works correctly, or when I do "disable cache" in dev tools it also works as it should...
That makes sense. You can also press ctrl + r
to do a hard refresh which clears your cache.
I am running a file using xampp server coded in php. I am facing this issues. Is there any way that the face.api work in xampp server
Any workaround if we wish to run it without the server?
Any workaround if we wish to run it without the server?
no use xampp server. https://www.apachefriends.org/download.html
just install the live server in visual code https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer
Hi, I downloaded your code and face-api.js library too. But when running index.html in browser I am getting blank page and below error.
face-api.min.js:1 Fetch API cannot load file:///C:/models/tiny_face_detector_model-weights_manifest.json. URL scheme must be "http" or "https" for CORS request. (anonymous) @ face-api.min.js:1 face-api.min.js:1 Fetch API cannot load file:///C:/models/face_landmark_68_model-weights_manifest.json. URL scheme must be "http" or "https" for CORS request. (anonymous) @ face-api.min.js:1 face-api.min.js:1 Fetch API cannot load file:///C:/models/face_recognition_model-weights_manifest.json. URL scheme must be "http" or "https" for CORS request. (anonymous) @ face-api.min.js:1 face-api.min.js:1 Fetch API cannot load file:///C:/models/face_expression_model-weights_manifest.json. URL scheme must be "http" or "https" for CORS request. (anonymous) @ face-api.min.js:1 face-api.min.js:1 Uncaught (in promise) TypeError: Failed to fetch at face-api.min.js:1 at face-api.min.js:1 at Object.next (face-api.min.js:1) at face-api.min.js:1 at new Promise ()
at p (face-api.min.js:1)
at lp (face-api.min.js:1)
at face-api.min.js:1
at face-api.min.js:1
at Object.next (face-api.min.js:1)
where am I missing something? Thanks in advance.