georg-jung / faceaisharp Goto Github PK
View Code? Open in Web Editor NEWState-of-the-art face detection and face recognition for .NET.
Home Page: https://nuget.org/packages/FaceAiSharp/
License: MIT License
State-of-the-art face detection and face recognition for .NET.
Home Page: https://nuget.org/packages/FaceAiSharp/
License: MIT License
Hi @georg-jung , first of all thanks for the great work that you put into this library.
Currently I was testing some pictures and lib is working great, but then I ran into 1 picture where I cannot detect the face. I would clarify this picture as good picture, the face can be seen clearly only a mic blocking the mouth.
But funny thing is on your demo site part Face Recognition, the face was detected normally.
Can you suggest me where can I start to check, I already checkout your demo code make sure everything the same config and using the same lib version. But I'm using .NET6 MVC instead of Blazor .NET7.
Thanks before.
Hi,
I tried your example to compare two face (code below) and it worked fine.
Now without making any change on the code, i am getting an exception at this line:
var det = FaceAiSharpBundleFactory.CreateFaceDetectorWithLandmarks();
the exception is :
The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception.
How to fix this issue?
i tried to unistall and reinstall the libraries : FaceAiSharp & FaceAiSharp.Bundle but still getting the same exception.
Here is the code i have used from your documentation.
`using var hc = new HttpClient();
var groupPhoto = await hc.GetByteArrayAsync(
"https://raw.githubusercontent.com/georg-jung/FaceAiSharp/master/examples/obama_family.jpg");
var img = Image.Load(groupPhoto);
var det = FaceAiSharpBundleFactory.CreateFaceDetectorWithLandmarks();_**//exception at this line**_
var rec = FaceAiSharpBundleFactory.CreateFaceEmbeddingsGenerator();
var faces = det.DetectFaces(img);
var first = faces.First();
var second = faces.Skip(1).First();
// AlignFaceUsingLandmarks is an in-place operation so we need to create a clone of img first
var secondImg = img.Clone();
rec.AlignFaceUsingLandmarks(img, first.Landmarks!);
rec.AlignFaceUsingLandmarks(secondImg, second.Landmarks!);
var embedding1 = rec.GenerateEmbedding(img);
var embedding2 = rec.GenerateEmbedding(secondImg);
var dot = FaceAiSharp.Extensions.GeometryExtensions.Dot(embedding1, embedding2);
Console.WriteLine($"Dot product: {dot}");
if (dot >= 0.42)
{
Console.WriteLine("Assessment: Both pictures show the same person.");
}
else if (dot > 0.28 && dot < 0.42)
{
Console.WriteLine("Assessment: Hard to tell if the pictures show the same person.");
}
else if (dot <= 0.28)
{
Console.WriteLine("Assessment: These are two different people.");
}`
Hi Georg,
Your project it's really good. Congratz.
Do you have any example of cropping image for profile I saw your page but didn't see the code of this example.
Thank you,
Johan
Hello,
Thank you for the great library.
How to use GPU for face detection and recognition? I want to use it with Frigate for camera's stream!
There are few standards, wonder which one this project provides on the resolution of the facial landmark?
When the FaceAiSharp library is used alongside the latest version of ImageSharp (3.1.1), the DetectFaces
method throws a runtime exception, indicating a compatibility issue. This problem does not occur with the older version of ImageSharp (2.1.5), suggesting that changes in ImageSharp's library, specifically the removal or modification of ImageInfoExtensions
, might be the cause.
Could not load type 'SixLabors.ImageSharp.ImageInfoExtensions' from assembly 'SixLabors.ImageSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13'.
var selfiePath = @"<ReplaceWithValidPath>\Selfie.jpg";
var groupPhotoPath = @"<ReplaceWithValidPath>\GroupPhoto.jpg";
// Load images from file paths
using var selfieStream = File.OpenRead(selfiePath);
var selfie = Image.Load<Rgb24>(selfieStream);
using var groupPhotoStream = File.OpenRead(groupPhotoPath);
var groupPhoto = Image.Load<Rgb24>(groupPhotoStream);
var detector = FaceAiSharpBundleFactory.CreateFaceDetectorWithLandmarks();
var recognizer = FaceAiSharpBundleFactory.CreateFaceEmbeddingsGenerator();
var selfieFaces = detector.DetectFaces(selfie);
if (!selfieFaces.Any())
{
Console.WriteLine("No faces detected in the selfie.");
return;
}
The DetectFaces
method should successfully identify faces within the provided images without triggering any exceptions.
An exception is thrown by the method, pointing to the inability to load the type ImageInfoExtensions
, which suggests that this class has either been removed or relocated in the latest ImageSharp version.
A review of the changes made between ImageSharp versions 2.1.5 and 3.1.1 could clarify whether ImageInfoExtensions
has been deprecated or replaced. Adapting FaceAiSharp to align with these updates could potentially resolve the issue.
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.
I tried your example to compare faces. I am getting an exception at this line: var faces = det.DetectFaces(img);
the exception is :
System.TypeLoadException:` 'Could not load type 'SixLabors.ImageSharp.ImageInfoExtensions' from assembly 'SixLabors.ImageSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13'.'
How to fix this issue?
Here is the code i have used from your documentation.
using var hc = new HttpClient();
var groupPhoto = await hc.GetByteArrayAsync(
"https://raw.githubusercontent.com/georg-jung/FaceAiSharp/master/examples/obama_family.jpg");
var img = Image.Load<Rgb24>(groupPhoto);
var det = FaceAiSharpBundleFactory.CreateFaceDetectorWithLandmarks();
var rec = FaceAiSharpBundleFactory.CreateFaceEmbeddingsGenerator();
var faces = det.DetectFaces(img);
var first = faces.First();
var second = faces.Skip(1).First();
// AlignFaceUsingLandmarks is an in-place operation so we need to create a clone of img first
var secondImg = img.Clone();
rec.AlignFaceUsingLandmarks(img, first.Landmarks!);
rec.AlignFaceUsingLandmarks(secondImg, second.Landmarks!);
var embedding1 = rec.GenerateEmbedding(img);
var embedding2 = rec.GenerateEmbedding(secondImg);
var dot = FaceAiSharp.Extensions.GeometryExtensions.Dot(embedding1, embedding2);
Console.WriteLine($"Dot product: {dot}");
if (dot >= 0.42)
{
Console.WriteLine("Assessment: Both pictures show the same person.");
}
else if (dot > 0.28 && dot < 0.42)
{
Console.WriteLine("Assessment: Hard to tell if the pictures show the same person.");
}
else if (dot <= 0.28)
{
Console.WriteLine("Assessment: These are two different people.");
}
Hi Georg--jung, i tried to implement an example to detect and recognise faces in .Net Maui. I am able to make it work on win device but not on android device. I am getting this exception on android:
Microsoft.ML.OnnxRuntime.OnnxRuntimeException: '[ErrorCode:NoSuchFile] Load model from /data/data/com.companyname.faceaitestmaui/files/.override/onnx/scrfd_2.5g_kps.onnx failed:Load model /data/data/com.companyname.faceaitestmaui/files/.override/onnx/scrfd_2.5g_kps.onnx failed. File doesn't exist'
Does your plugin works on android or it is designed to work on windows only?
best regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.