-
-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathSimpleOrientedBoundingBoxTests.cs
More file actions
91 lines (71 loc) · 2.4 KB
/
SimpleOrientedBoundingBoxTests.cs
File metadata and controls
91 lines (71 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
namespace YoloDotNet.Benchmarks.OrientedBoundingBoxTests
{
[MemoryDiagnoser]
public class SimpleOrientedBoundingBoxTests
{
#region Fields
private readonly string _model8 = SharedConfig.GetTestModelV8(ModelType.ObbDetection);
private readonly string _model11 = SharedConfig.GetTestModelV11(ModelType.ObbDetection);
private readonly string _testImage = SharedConfig.GetTestImage(ImageType.Island);
private Yolo _gpuYolov8;
private Yolo _cpuYolov8;
private Yolo _gpuYolov11;
private Yolo _cpuYolov11;
private SKImage _image;
#endregion Fields
#region Methods
[GlobalSetup]
public void GlobalSetup()
{
var options = new YoloOptions
{
ModelType = ModelType.ObbDetection
};
_image = SKImage.FromEncodedData(_testImage);
// Yolov8
options.OnnxModel = _model8;
options.HwAccelerator = HwAcceleratorType.None;
_cpuYolov8 = new Yolo(options);
options.HwAccelerator = HwAcceleratorType.Cuda;
_gpuYolov8 = new Yolo(options);
// Yolov11
options.OnnxModel = _model11;
options.HwAccelerator = HwAcceleratorType.None;
_cpuYolov11 = new Yolo(options);
options.HwAccelerator = HwAcceleratorType.Cuda;
_gpuYolov11 = new Yolo(options);
}
[GlobalCleanup]
public void GlobalCleanup()
{
_cpuYolov8?.Dispose();
_cpuYolov11?.Dispose();
_gpuYolov8?.Dispose();
_gpuYolov11?.Dispose();
_image?.Dispose();
}
// Yolov8
[Benchmark]
public List<OBBDetection> RunSimpleObbDetectionYolov8Cpu()
{
return _cpuYolov8.RunObbDetection(_image);
}
[Benchmark]
public List<OBBDetection> RunSimpleObbDetectionYolov8Gpu()
{
return _gpuYolov8.RunObbDetection(_image);
}
// Yolov11
[Benchmark]
public List<OBBDetection> RunSimpleObbDetectionYolov11Cpu()
{
return _cpuYolov11.RunObbDetection(_image);
}
[Benchmark]
public List<OBBDetection> RunSimpleObbDetectionYolov11Gpu()
{
return _gpuYolov11.RunObbDetection(_image);
}
#endregion Methods
}
}