takuya-takeuchi / FaceRecognitionDotNet

The world's simplest facial recognition api for .NET on Windows, MacOS and Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Face_Recognition Constructor

danijerez opened this issue · comments

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);
        }

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

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

@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

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

I have tried to put all

  • FaceRecognitionDotNet
  • FaceRecognitionDotNet.MKL
  • FaceRecognitionDotNet.CUDA92
  • FaceRecognitionDotNet.CUDA100
  • FaceRecognitionDotNet.CUDA101

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?

@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

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/*