Beispiel #1
0
        static float[] GetEmbedding(Bitmap image)
        {
            var faces = _faceDetectorLight.Forward(image);

            using var cropped = Imaging.Crop(image, faces.First());
            var points = _faceLandmarksExtractor.Forward(cropped);

            using var aligned = FaceLandmarksExtractor.Align(cropped, points);
            return(_faceEmbedder.Forward(aligned));
        }
Beispiel #2
0
        static string[] GetEmotionAndBeauty(Bitmap image, Rectangle face)
        {
            using var cropped = Imaging.Crop(image, face);
            var points = _faceLandmarksExtractor.Forward(cropped);

            using var aligned = FaceLandmarksExtractor.Align(cropped, points);
            var emotion      = _faceEmotionClassifier.Forward(aligned);
            var emotionLabel = FaceEmotionClassifier.Labels[emotion.Argmax()];
            var beauty       = _faceBautyClassifier.Forward(aligned);
            var beautyLabel  = $"{Math.Round(2 * beauty.Max(), 1)}/10.0";

            Console.WriteLine($"--> classified as [{emotionLabel}] emotion and [{beautyLabel}] beauty");

            return(new string[] { emotionLabel, beautyLabel });
        }
Beispiel #3
0
        static string[] GetRaceAndAge(Bitmap image, Rectangle face)
        {
            using var cropped = Imaging.Crop(image, face);
            var points = _faceLandmarksExtractor.Forward(cropped);

            using var aligned = FaceLandmarksExtractor.Align(cropped, points);
            var race      = _faceRaceClassifier.Forward(aligned);
            var raceLabel = FaceRaceClassifier.Labels[race.Argmax()];
            var age       = _faceAgeClassifier.Forward(aligned);
            var ageLabel  = FaceAgeClassifier.Labels[age.Argmax()];

            Console.WriteLine($"--> classified as [{raceLabel}] race and [{ageLabel}] age");

            return(new string[] { raceLabel, ageLabel });
        }