本文主要是介绍[C#]C# winform实现imagecaption图像生成描述图文描述生成,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
介绍:
地址:C#https://github.com/ruotianluo/ImageCaptioning.pytorch
效果:
测试环境:
vs2019
onnxruntime1.16.3
opencvsharp4.8
代码:
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 FIRC;
using OpenCvSharp;namespace imagecaptiondemo
{public partial class Form1 : Form{ImageCaptionManager icm = new ImageCaptionManager();Mat curMat = new Mat();public Form1(){InitializeComponent();}private void btn_select_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = "图片文件(*.*)|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";ofd.Multiselect = false;if (ofd.ShowDialog() != DialogResult.OK) return;curMat = Cv2.ImRead(ofd.FileName);pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(curMat);}private void Form1_Load(object sender, EventArgs e){icm.LoadWeights();}private void button2_Click(object sender, EventArgs e){if(pictureBox1.Image==null){return;}Stopwatch sw = new Stopwatch();sw.Start();var result = icm.Inference(curMat);sw.Stop();tb_res.Text = "推理耗时:" + sw.Elapsed.TotalSeconds+"秒\r\n推理结果:"+result;}}
}
视频演示:
C#实现图文描述生成imagecaption图像生成文字描述_哔哩哔哩_bilibiliC#实现图文描述生成imagecaption图像生成文字描述测试环境为:vs2019net framework4.7.2onnxruntime1.16.3opencvsharp4.8, 视频播放量 1、弹幕量 0、点赞数 0、投硬币枚数 0、收藏人数 0、转发人数 0, 视频作者 未来自主研究中心, 作者简介 未来自主研究中心,相关视频:https://www.bilibili.com/video/BV1Ba4y1z7Df/?vd_source=989ae2b903ea1b5acebbe2c4c4a635ee
源码下载地址:
https://download.csdn.net/download/FL1623863129/88681153
这篇关于[C#]C# winform实现imagecaption图像生成描述图文描述生成的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!