takuya-takeuchi / FaceRecognitionDotNet

The world's simplest facial recognition api for .NET on Windows, MacOS and Linux
MIT License
1.27k stars 309 forks source link

Face_Recognition Constructor #134

Closed danijerez closed 4 years ago

danijerez commented 4 years ago

Face_Recognition can be constructed differently than FaceRecognition.Create ("data"); ? I wanted to use it in a docker container and avoid having to create directories, how could I build it?

fr = FaceRecognition.Create("data");

        public static IEnumerable<FaceEncoding> BitmapToEncoding(Bitmap bitmap, FaceRecognition fr)
        {
            Image image = FaceRecognition.LoadImage(bitmap);
            IEnumerable<Location> locations = fr.FaceLocations(image);
            return fr.FaceEncodings(image, locations);
        }
takuya-takeuchi commented 4 years ago

@danijerez FaceRecognition.Create does not create directory. This argument is source directory contains model files.

danijerez commented 4 years ago

I managed to load the path in the following way

fr = FaceRecognition.Create($"{env.ContentRootPath}/Resources/Data");

but when deploying the docker container and using the function, the following happens to me

System.TypeInitializationException: The type initializer for 'DlibDotNet.NativeMethods' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'DlibDotNetNativeDnn' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libDlibDotNetNativeDnn: cannot open shared object file: No such file or directory
takuya-takeuchi commented 4 years ago

@danijerez It means that DlibDotNetNativeDnn can not resolve dependencies. Could try ldd libDlibDotNetNativeDnn? You may see not found.

I'm not sure you use exact version of FRDN. Do you install requirements library? https://github.com/takuya-takeuchi/FaceRecognitionDotNet/wiki/Quickstart

danijerez commented 4 years ago

install the nuget dependency and locally if it works, the problem is in the container, I show you the repository where I am doing the tests

https://gitlab.com/danijerez/face-recognition-api

danijerez commented 4 years ago

I have tried to put all

but it keeps giving me the same error, you have tried a docker container and you get it to work?

do I need to put something else to the code?

takuya-takeuchi commented 4 years ago

@danijerez

OK. I checked your Dockerfile. I can not see installing libopenblas and others. Container base images are minimum. So we have to install dependencies.

I provide dockerfile to run dlibdotnet. It may help you.

base

https://github.com/takuya-takeuchi/DlibDotNet/blob/master/docker/base/ubuntu/16/cuda/10.2/Dockerfile

runtime (derive from base)

https://github.com/takuya-takeuchi/DlibDotNet/blob/master/docker/runtime/ubuntu/16/Dockerfile

danijerez commented 4 years ago

I got it to work by adding this to the dockerfile, thank you very much!

RUN apt-get update && apt-get install -y \ libgdiplus \ libopenblas-dev \ liblapack-dev \ libx11-6 \ && apt-get clean && rm -rf /var/lib/apt/lists/*