[C#]winform部署yolov8图像分类的openvino格式的模型

【官方框架地址】

https://github.com/ultralytics/ultralytics
【openvino介绍】

OpenVINO是一个针对Intel硬件优化的开源工具包,用于优化和部署深度学习模型。以下是OpenVINO部署模型的主要优点:

  1. 高性能:OpenVINO提供了一系列性能优化工具,如模型量化和剪枝等,可以在Intel硬件平台上实现高性能和低延迟的推理。
  2. 多平台支持:OpenVINO支持多种Intel硬件平台,包括CPU、GPU和FPGA等,可以在不同的硬件平台上进行优化和部署。
  3. 多框架支持:OpenVINO支持多种流行的深度学习框架,如TensorFlow、PyTorch和Caffe等,可以方便地将已有的模型集成到OpenVINO中。
  4. 简化部署:OpenVINO提供了一系列的工具和API,可以简化模型的部署和集成,使得开发者可以更快速地将模型部署到生产环境中。
  5. 预训练模型:OpenVINO提供了一系列的预训练模型,可以直接使用这些模型进行推理,也可以在这些模型的基础上进行微调和优化。
  6. 灵活性:OpenVINO提供了灵活的部署选项,可以将模型部署到本地设备、云端或边缘设备上,以满足不同的应用场景需求。
  7. 丰富的文档和社区支持:OpenVINO作为一个开源项目,拥有丰富的文档和活跃的社区支持,方便开发者学习和解决问题。
  8. 易用性:OpenVINO的接口简洁明了,易于使用,可以快速上手进行模型部署。

综上所述,OpenVINO在部署模型方面具有高性能、多平台支持、多框架支持、简化部署、预训练模型、灵活性、丰富的文档和社区支持以及易用性等优点。这些优点使得OpenVINO成为了一个强大而可靠的深度学习模型部署工具。
【效果展示】


【实现部分代码】

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenCvSharp;

namespace FIRC
{
    public partial class Form1 : Form
    {
        Mat src = new Mat();
        Yolov8ClsManager detector = new Yolov8ClsManager();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "图文件(*.*)|*.jpg;*.png;*.jpeg;*.bmp";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Multiselect = false;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
              
                src = Cv2.ImRead(openFileDialog.FileName);

                pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src);


            }


        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(pictureBox1.Image==null)
            {
                return;
            }

            var result = detector.Inference(src);
            var resultMat = detector.DrawImage(result,src);
            pictureBox2.Image= OpenCvSharp.Extensions.BitmapConverter.ToBitmap(resultMat); //Mat转Bitmap
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            detector.LoadWeights(Application.StartupPath+ "\\weights\\yolov8n-cls.xml");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            VideoCapture capture = new VideoCapture(0);
            if (!capture.IsOpened())
            {
                Console.WriteLine("video not open!");
                return;
            }
            Mat frame = new Mat();
            var sw = new Stopwatch();
            int fps = 0;
            while (true)
            {

                capture.Read(frame);
                if (frame.Empty())
                {
                    Console.WriteLine("data is empty!");
                    break;
                }
                sw.Start();
                var result = detector.Inference(src);
                var resultMat = detector.DrawImage(result, src);
                sw.Stop();
                fps = Convert.ToInt32(1 / sw.Elapsed.TotalSeconds);
                sw.Reset();
                Cv2.PutText(resultMat, "FPS=" + fps, new OpenCvSharp.Point(30, 30), HersheyFonts.HersheyComplex, 1.0, new Scalar(255, 0, 0), 3);
                //显示结果
                Cv2.ImShow("Result", resultMat);
                int key = Cv2.WaitKey(10);
                if (key == 27)
                    break;
            }

            capture.Release();
        }
    }
}


【视频演示】

https://www.bilibili.com/video/BV1RK4y1q7qX/?vd_source=989ae2b903ea1b5acebbe2c4c4a635ee
【测试环境】
vs2019,netframework4.7.2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FL1623863129

你的打赏是我写文章最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值