11// Copyright (c) Georg Jung. All rights reserved.
22// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33
4- using System . Numerics ;
4+ using System . Reflection ;
55using BenchmarkDotNet . Attributes ;
66using FaceAiSharp ;
77using FaceAiSharp . Extensions ;
8- using FaceONNX ;
98using Microsoft . ML . OnnxRuntime . Tensors ;
109using SixLabors . ImageSharp ;
1110using SixLabors . ImageSharp . PixelFormats ;
@@ -19,7 +18,7 @@ public class Scrfd
1918 private readonly Image _img = Image . Load ( @"C:\Users\georg\facePics\avGroup.jpg" ) ;
2019 private readonly Image < Rgb24 > _preprocImg ;
2120 private readonly ScrfdDetector _scrfd1 ;
22- private readonly ScrfdDetector _scrfd2 ;
21+ /* private readonly ScrfdDetector _scrfd2; */
2322 private readonly DenseTensor < float > _imgTensor ;
2423
2524 public Scrfd ( )
@@ -36,14 +35,15 @@ public Scrfd()
3635
3736 _preprocImg = x . Image ;
3837 _imgTensor = ScrfdDetector . CreateImageTensor ( _preprocImg ) ;
38+ var modelPath = Path . Combine ( GetExeDir ( ) , "onnx" , "scrfd_2.5g_kps.onnx" ) ;
3939 _scrfd1 = new (
4040 new ScrfdDetectorOptions ( )
4141 {
42- ModelPath = @"C:\Users\georg\OneDrive\Dokumente\ScrfdOnnx\scrfd_2.5g_bnkps_shape640x640.onnx" ,
42+ ModelPath = modelPath ,
4343 AutoResizeInputToModelDimensions = false ,
4444 } ) ;
4545
46- _scrfd2 = new (
46+ /* _scrfd2 = new(
4747 new()
4848 {
4949 ModelPath = @"C:\Users\georg\OneDrive\Dokumente\ScrfdOnnx\scrfd_2.5g_bnkps_dyn.onnx",
@@ -52,12 +52,14 @@ public Scrfd()
5252 new()
5353 {
5454 ExecutionMode = Microsoft.ML.OnnxRuntime.ExecutionMode.ORT_PARALLEL,
55- } ) ;
55+ });*/
5656 }
5757
5858 [ Benchmark ]
5959 public IReadOnlyCollection < FaceDetectorResult > First ( ) => _scrfd1 . Detect ( _imgTensor , new Size ( 640 , 640 ) , 1.0f ) ;
6060
61- [ Benchmark ]
62- public IReadOnlyCollection < FaceDetectorResult > Second ( ) => _scrfd2 . Detect ( _imgTensor , new Size ( 640 , 640 ) , 1.0f ) ;
61+ /*[Benchmark]
62+ public IReadOnlyCollection<FaceDetectorResult> Second() => _scrfd2.Detect(_imgTensor, new Size(640, 640), 1.0f);*/
63+
64+ private static string GetExeDir ( ) => Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ! ;
6365}
0 commit comments