@@ -24,9 +24,15 @@ work on i13900k + 64Gb Ram + RTX4090
2424![ ] ( https://raw.githubusercontent.com/ivilson/Yolov7net/master/performance.png )
2525
2626
27+ ![ ] ( https://raw.githubusercontent.com/ivilson/Yolov7net/master/test/Yolov7net.test/Assets/demo.jpg )
2728
2829### 2024.6.9
29- 1 . add yolov10 support.
30+
31+ Usage:
32+
33+ 1 . install-package IVilson.AI.Yolov7net
34+ 2 . [ Program.cs] ( https://github.com/ivilson/Yolov7net/blob/master/Yolov7net.Demo/Program.cs )
35+ 3 . add yolov10 support.
3036Yolov10
3137``` csharp
3238// init Yolov8 with onnx (include nms results)file path
@@ -66,6 +72,10 @@ foreach (var prediction in predictions) // 迭代预测结果并绘制
6672 canvas .DrawText ($" {prediction .Label .Name } ({score })" , x , y , paintText );
6773}
6874```
75+
76+
77+ ![ ] ( https://raw.githubusercontent.com/ivilson/Yolov7net/master/result.jpg )
78+
6979yolov10 和 yolov7 保持兼容,包含了NMS 操作,感觉性能上比不上yolov9
7080
7181
@@ -88,8 +98,6 @@ The net8.0 branch has been renamed to master. This is now the main branch where
8898
8999
90100
91-
92-
93101# Yolov7net Now support yolov9,yolov8,yolov7,yolov5.
94102
95103.net 6 yolov5, yolov7, yolov8 onnx runtime interface, work for:
@@ -99,104 +107,10 @@ The net8.0 branch has been renamed to master. This is now the main branch where
991074 . yolov5 https://github.com/ultralytics/yolov5
100108
101109
102- Usage:
103110
104- install-package IVilson.AI.Yolov7net
105111
106- ![ ] ( https://raw.githubusercontent.com/ivilson/Yolov7net/master/test/Yolov7net.test/Assets/demo.jpg )
107112
108- yolov9 和 yolov8 的 onnx 输出参数相同,都是 (1,84,8400)
109113
110- 如果有问题请前往 issus 进行提问,我会尽量解答
111-
112- Yolov9
113- ``` csharp
114- // init Yolov8 with onnx (include nms results)file path
115- using var yolo = new Yolov8 (" ./assets/yolov9-c.onnx" , true );
116- // setup labels of onnx model
117- yolo .SetupYoloDefaultLabels (); // use custom trained model should use your labels like: yolo.SetupLabels(string[] labels)
118- using var image = Image .FromFile (" Assets/demo.jpg" );
119- var predictions = yolo .Predict (image ); // now you can use numsharp to parse output data like this : var ret = yolo.Predict(image,useNumpy:true);
120- // draw box
121- using var graphics = Graphics .FromImage (image );
122- foreach (var prediction in predictions ) // iterate predictions to draw results
123- {
124- double score = Math .Round (prediction .Score , 2 );
125- graphics .DrawRectangles (new Pen (prediction .Label .Color , 1 ),new [] { prediction .Rectangle });
126- var (x , y ) = (prediction .Rectangle .X - 3 , prediction .Rectangle .Y - 23 );
127- graphics .DrawString ($" {prediction .Label .Name } ({score })" ,
128- new Font (" Consolas" , 16 , GraphicsUnit .Pixel ), new SolidBrush (prediction .Label .Color ),
129- new PointF (x , y ));
130- }
131- ```
132-
133- Yolov8
134- ``` csharp
135- // init Yolov8 with onnx (include nms results)file path
136- using var yolo = new Yolov8 (" ./assets/yolov8n.onnx" , true );
137- // setup labels of onnx model
138- yolo .SetupYoloDefaultLabels (); // use custom trained model should use your labels like: yolo.SetupLabels(string[] labels)
139- using var image = Image .FromFile (" Assets/demo.jpg" );
140- var predictions = yolo .Predict (image ); // now you can use numsharp to parse output data like this : var ret = yolo.Predict(image,useNumpy:true);
141- // draw box
142- using var graphics = Graphics .FromImage (image );
143- foreach (var prediction in predictions ) // iterate predictions to draw results
144- {
145- double score = Math .Round (prediction .Score , 2 );
146- graphics .DrawRectangles (new Pen (prediction .Label .Color , 1 ),new [] { prediction .Rectangle });
147- var (x , y ) = (prediction .Rectangle .X - 3 , prediction .Rectangle .Y - 23 );
148- graphics .DrawString ($" {prediction .Label .Name } ({score })" ,
149- new Font (" Consolas" , 16 , GraphicsUnit .Pixel ), new SolidBrush (prediction .Label .Color ),
150- new PointF (x , y ));
151- }
152- ```
153- yolov7 可以直接导出包含nms操作结果的onnx, 使用方法略有不同,需要使用 Yolov7 这个类
154-
155- ``` csharp
156- // init Yolov7 with onnx (include nms results)file path
157- using var yolo = new Yolov7 (" ./assets/yolov7-tiny_640x640.onnx" , true );
158- // setup labels of onnx model
159- yolo .SetupYoloDefaultLabels (); // use custom trained model should use your labels like: yolo.SetupLabels(string[] labels)
160- using var image = Image .FromFile (" Assets/demo.jpg" );
161- var predictions = yolo .Predict (image );
162-
163- // draw box
164- using var graphics = Graphics .FromImage (image );
165- foreach (var prediction in predictions ) // iterate predictions to draw results
166- {
167- double score = Math .Round (prediction .Score , 2 );
168- graphics .DrawRectangles (new Pen (prediction .Label .Color , 1 ),new [] { prediction .Rectangle });
169- var (x , y ) = (prediction .Rectangle .X - 3 , prediction .Rectangle .Y - 23 );
170- graphics .DrawString ($" {prediction .Label .Name } ({score })" ,
171- new Font (" Consolas" , 16 , GraphicsUnit .Pixel ), new SolidBrush (prediction .Label .Color ),
172- new PointF (x , y ));
173- }
174- ```
175-
176- 对于未包括nms 结果的模型,需要用到 yolov5 这个类
177- ``` csharp
178- // init Yolov5 with onnx file path
179- using var yolo = new Yolov5 (" ./assets/yolov7-tiny_640x640.onnx" , true );
180- // setup labels of onnx model
181- yolo .SetupYoloDefaultLabels (); // use custom trained model should use your labels like: yolo.SetupLabels(string[] labels)
182- using var image = Image .FromFile (" Assets/demo.jpg" );
183- var predictions = yolo .Predict (image );
184-
185- // draw box
186- using var graphics = Graphics .FromImage (image );
187- foreach (var prediction in predictions ) // iterate predictions to draw results
188- {
189- double score = Math .Round (prediction .Score , 2 );
190- graphics .DrawRectangles (new Pen (prediction .Label .Color , 1 ),new [] { prediction .Rectangle });
191- var (x , y ) = (prediction .Rectangle .X - 3 , prediction .Rectangle .Y - 23 );
192- graphics .DrawString ($" {prediction .Label .Name } ({score })" ,
193- new Font (" Consolas" , 16 , GraphicsUnit .Pixel ), new SolidBrush (prediction .Label .Color ),
194- new PointF (x , y ));
195- }
196-
197-
198- ```
199- ![ ] ( https://raw.githubusercontent.com/ivilson/Yolov7net/master/result.jpg )
200114
201115# References & Acknowledgements
202116
0 commit comments