Open wsoftone opened 5 months ago
Sorry for the delay in responding. A working MAUI on Android example is available here: https://github.com/georg-jung/explain-face-rec/tree/master/src/BlazorFace.Maui
Your issue might be related to how assets are handled on the different platforms. Take a look at the csproj in the linked repo:
<Target Name="ConvertToMauiAsset" DependsOnTargets="ResolveProjectReferences" BeforeTargets="PrepareForBuild">
<ItemGroup>
<ContentToMauiAsset Include="@(Content)" Condition="'%(Extension)' == '.onnx'" />
<MauiAsset Include="@(ContentToMauiAsset)" />
<Content Remove="@(ContentToMauiAsset)" />
</ItemGroup>
</Target>
And also here: https://github.com/georg-jung/explain-face-rec/blob/fe8a4e5d783b2a8eb22c33f8fcb9c8d3a89665eb/src/BlazorFace.Maui/MauiProgram.cs#L31
Let me know if this works for you or if you need further assistance.
thank for your reply. I tried all your procedures. I am still having the same exception.
Could you provide a more complete repro, probably a repository that contains a project where this does not work?
This is most probably related to Android specifics when reading ressource files. Do you have something like https://github.com/georg-jung/explain-face-rec/blob/fe8a4e5d783b2a8eb22c33f8fcb9c8d3a89665eb/src/BlazorFace.Maui/MauiResourceOpener.cs in your project? If not, it can not work on Android.
Hi Georg, I attached the Maui project. I integrated all necessery code from your example. It still not working on Adroid: Microsoft.ML.OnnxRuntime.OnnxRuntimeException: '[ErrorCode:NoSuchFile] .
Thank you for your assistance and help.
I couldn't find a ConvertToMauiAsset
target (or similar) in your FaceAiMaui.csproj
.
Please try adding something like this:
<Target Name="ConvertToMauiAsset" DependsOnTargets="ResolveProjectReferences" BeforeTargets="PrepareForBuild">
<ItemGroup>
<ContentToMauiAsset Include="@(Content)" Condition="'%(Extension)' == '.onnx'" />
<MauiAsset Include="@(ContentToMauiAsset)" />
<Content Remove="@(ContentToMauiAsset)" />
</ItemGroup>
</Target>
Hi Georg, I added the missing code and revised the code again. still does not work.
Hi Georg, I added the missing code and revised the code again. still does not work. on Adroid i am getting the exception on this line: var det = FaceAiSharpBundleFactory. I checked the source code of FaceAiSharpBundleFactory and i found that GetExeDir() is the issue. The flles: scrfd_2.5g_kps.onnx, arcfaceresnet100-11-int8.onnx and open_closed_eye.onnx are not copied to the device after deployment.
Hello, I also faced the same problem on avalonia android. Did you find a solution to this?
Just to make this work on your android device : 1-copy the files : scrfd_2.5g_kps.onnx, arcfaceresnet100-11-int8.onnx and open_closed_eye.onnx to the app location on your android device. 2- replace the GetExeDir() methods in the FaceAiSharpBundleFactory class with the absolute path of the previously copied files.
One solution could be to add a new method to the FaceAiSharpBundleFactory class that copies the mentioned files from the project to the Android device. This will be a decision for Georg.
I'm currently on holiday, sorry, but I'll probably take a look at this in the coming weeks. In the meantime, https://github.com/georg-jung/explain-face-rec/ has a fully working android app based on FaceAiSharp. Android has some specifics about how to access files bundled with the app instead of it's data directory. The repo contains a working example for this though. To take a look at your specific problems it would be very helpful to look at the specific code you're trying to make work. Easiest would be an up to date minimal working example in a git repo.
Hi, I tried your example to compare two face (code below) and it worked fine on .net maui (win & andtoid). After making an update of the faceaisharp, the android app throw an exception: Microsoft.ML.OnnxRuntime.OnnxRuntimeException: '[ErrorCode:NoSuchFile] Load model from /data/data/com.companyname.facerecognitiontest/files/.override/onnx/scrfd_2.5g_kps.onnx failed:Load model /data/data/com.companyname.facerecognitiontest/files/.override/onnx/scrfd_2.5g_kps.onnx failed. File doesn't exist'
On windows it still working. but on Adroid i am getting the exception on this line: var det = FaceAiSharpBundleFactory.CreateFaceDetectorWithLandmarks(); I am not able to resolve this issue. Can you please help with this. Is it possible to provide an example that works on .net maui for Android.
thanks in advance.