takuya-takeuchi / DlibDotNet

Dlib .NET wrapper written in C++ and C# for Windows, MacOS, Linux and iOS
MIT License
488 stars 134 forks source link

Using in Azure App Services #214

Open okolobaxa opened 3 years ago

okolobaxa commented 3 years ago

I'm trying run my app in Azure App Services (Linux), but the call to GetFrontalFaceDetector() leads with an exception with text

The type initializer for 'DlibDotNet.NativeMethods' threw an exception. 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

System.TypeInitializationException:
   at DlibDotNet.NativeMethods.get_frontal_face_detector (DlibDotNet, Version=19.18.0.0, Culture=neutral, PublicKeyToken=null)
   at DlibDotNet.Dlib.GetFrontalFaceDetector (DlibDotNet, Version=19.18.0.0, Culture=neutral, PublicKeyToken=null)
   at Psprto.Core.Image.HogFaceDetector.Detect (Psprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullPsprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: /home/vsts/work/1/s/src/Psprto.Core/Image/HogFaceDetector.csPsprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 13)
   at Psprto.Core.Managers.UploadManager+<PreDetectFaces>d__14.MoveNext (Psprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullPsprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: /home/vsts/work/1/s/src/Psprto.Core/Managers/UploadManager.csPsprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 214)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Psprto.Core.Managers.UploadManager+<UploadAsync>d__13.MoveNext (Psprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullPsprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: /home/vsts/work/1/s/src/Psprto.Core/Managers/UploadManager.csPsprto.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 112)
Inner exception System.DllNotFoundException handled at DlibDotNet.NativeMethods.get_frontal_face_detector:
   at DlibDotNet.NativeMethods.LossMetric_anet_type_create (DlibDotNet, Version=19.18.0.0, Culture=neutral, PublicKeyToken=null)
   at DlibDotNet.NativeMethods..cctor (DlibDotNet, Version=19.18.0.0, Culture=neutral, PublicKeyToken=null)

Am I right that it is due to missing dependencies? And the only way to get it to work in Azure App Services under Linix is to use it in Docker container?

On my Windows machine, everything works well. Using this version:

<PackageReference Include="DlibDotNet" Version="19.20.0.20200725" />

takuya-takeuchi commented 3 years ago

@okolobaxa I have never works DlibDotNet on Azure. But you must run ldd command to investigate missing dependencies.

And the only way to get it to work in Azure App Services under Linix is to use it in Docker container? No. I was successful to run on physical linux machine.