Search code examples
javascriptc#jqueryiisface-detection

404 page not found for face-api.js


I am trying to implement the face-api.js in a simple project hosted on a local IIS but I am getting the following issue

enter image description here

here is my javascript code

Promise.all([
faceapi.nets.faceRecognitionNet.loadFromUri('/models'),
faceapi.nets.faceLandmark68Net.loadFromUri('/models'),
faceapi.nets.ssdMobilenetv1.loadFromUri('/models')
]).then(start)

I added my website on IIS as follow and add a custom domain in the host file and I am browsing the website as follow: http://facelocal/index.html

enter image description here

Also my hierarchy looks like the following

enter image description here

The response is the following:

enter image description here

Can anyone help me figure out this issue?


Solution

  • The error message is quite clear.

    HTTP error 404.3 is a specific error in IIS: MIME type restriction.

    IIS needs to know what content type to respond to static files without extension (like your model files).

    Since it's undefined by default, you need to set a MIME type for extension-less static files.

    Put the following web.config file in your web application's root folder or update the existing one by adding nodes remove and mimeMap respectively under configuration/system.webServer/staticContent.

    I don't know what should be your model file MIME type, so assumed it was text/plain.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <staticContent>
                <!-- "." means no extension -->
                <!--  to prevent future duplication errors, remove "." mime map in case a higher level configuration is defined somewhere in the web server tree -->
                <remove fileExtension="." />
                <!-- now add the mime map again -->
                <mimeMap fileExtension="." mimeType="text/plain" />
            </staticContent>
        </system.webServer>
    </configuration>
    

    If you manage to configure this, those 404.3 errors will not occur again.


    Related: Adding Static Content MIME Mappings <mimeMap>