NickSwardh / YoloDotNet

YoloDotNet - A C# .NET 8.0 project for Classification, Object Detection, OBB Detection, Segmentation and Pose Estimation in both images and videos.
GNU General Public License v3.0
158 stars 28 forks source link

Performance updates #16

Closed louislewis2 closed 2 months ago

louislewis2 commented 2 months ago

While working with your library, after I got my software running, I started looking for ways to improve the performance. I then noticed you had a branch call performance.

Before submitting performance changes, I thought it would be wise to first add some benchmark capability to ensure changes are in fact increasing performance, to monitor both the speed as well as allocations and GC pressure.

In adding this new benchmark project, I had to refactor some code to make things like assets slightly more shareable. I did move the non src related (code that is packaged and deployed to nuget) out of the main directory and into a test directory.

While the goal was to initially just add the benchmark project with some example, I did spot one fix, would would make a dramatic and immediate change. Please see the new section in the readme file for full details.

I hope this change and addition is received well.

NickSwardh commented 2 months ago

Hi @louislewis2, thank you for contributing to YoloDotNet! Yes, benchmarking is a nice addition for testing performance, onnx-models and various code changes. The usage of an ArrayPool gave an additional boost and a much better GC performance when running multiple detections, which is great! Nice one! :)

Regarding your PR, besides my request for the minor changes I'd also like to have the ConsoleDemo in the the src folder with the YoloDotNet project for clarity, as its purpose is to demonstrate the capabilities of the core project.

Ex:

Solution
│
├── src
│   ├── ConsoleDemo
│   └── YoloDotNet
│
├── test
│   ├── Benchmarks
│   ├── YoloDotNet.Test.Common
│   └── Tests

Rock on, Nick

louislewis2 commented 2 months ago

@NickSwardh

Thanks for reviewing the PR. I have made the changes you suggested, please let me know if there is anything else I might have overlooked.

Regards

Louis