视频 播放网站怎么做欧洲做安网站

张小明 2026/1/8 3:37:00
视频 播放网站怎么做,欧洲做安网站,ip代理免费,怎么进入自己网站主机地址一. 模型导出 二. 环境搭建 三. 代码程序 参考链接#xff1a;https://blog.csdn.net/qq_41375318/article/details/142747415 1. 模型导出 参考链接#xff1a;https://docs.ultralytics.com/zh/modes/export/#cli 将训练完成的YOLO模型导出成ONNX格式#xff0c;代码如…一. 模型导出二. 环境搭建三. 代码程序参考链接https://blog.csdn.net/qq_41375318/article/details/1427474151. 模型导出参考链接https://docs.ultralytics.com/zh/modes/export/#cli将训练完成的YOLO模型导出成ONNX格式代码如下from ultralytics import YOLO # Load a model model YOLO(yolo11n.pt) # load an official model model YOLO(path/to/best.pt) # load a custom-trained model # Export the model model.export(formatonnx)成功导出的onnx模型储存在yolo模型的同级目录下2. 环境搭建主要包括C#中的Nuget包下载其中需要的DLL包括4个Microsoft.ML.OnnxRuntimeMicrosoft.ML.OnnxRuntime.ManagedOpenCvSharp4OpenCvSharp4.runtime.win3. 代码程序3.1 检测结果类public class DetectionResult { public DetectionResult(int ClassId, string Class, Rect Rect, float Confidence) { this.ClassId ClassId; this.Confidence Confidence; this.Rect Rect; this.Class Class; } public string Class { get; set; } public int ClassId { get; set; } public float Confidence { get; set; } public Rect Rect { get; set; } }3.2 变量和Tanspose函数string fileFilter *.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png; string image_path ; string model_path; string classer_path; public string[] class_names; public int class_num; DateTime dt1 DateTime.Now; DateTime dt2 DateTime.Now; int input_height; int input_width; float ratio_height; float ratio_width; InferenceSession onnx_session; int box_num; float conf_threshold; float nms_threshold; public unsafe float[] Transpose(float[] tensorData, int rows, int cols) { float[] transposedTensorData new float[tensorData.Length]; fixed (float* pTensorData tensorData) { fixed (float* pTransposedData transposedTensorData) { for (int i 0; i rows; i) { for (int j 0; j cols; j) { int index i * cols j; int transposedIndex j * rows i; pTransposedData[transposedIndex] pTensorData[index]; } } } } return transposedTensorData; }3.2 加载模型与label.txtprivate void Form1_Load(object sender, EventArgs e) { model_path ...\...\model\yolo11n.onnx; //创建输出会话用于输出模型读取信息 SessionOptions options new SessionOptions(); options.LogSeverityLevel OrtLoggingLevel.ORT_LOGGING_LEVEL_INFO; options.AppendExecutionProvider_CPU(0);// 设置为CPU上运行 // 创建推理模型类读取模型文件 onnx_session new InferenceSession(model_path, options);//model_path 为onnx模型文件的路径 input_height 640; input_width 640; box_num 8400; conf_threshold 0.25f; nms_threshold 0.5f; classer_path ...\...\model\label.txt; class_names File.ReadAllLines(classer_path, Encoding.UTF8); class_num class_names.Length; // 图片路径 image_path ...\...\image1.jpg; pictureBox1.Image new Bitmap(image_path); }3.3 开始检测推理private void button2_Click(object sender, EventArgs e) { if (image_path ) { return; } button2.Enabled false; pictureBox2.Image null; textBox1.Text ; Application.DoEvents(); Mat image new Mat(image_path); //图片缩放 int height image.Rows; int width image.Cols; Mat temp_image image.Clone(); if (height input_height || width input_width) { float scale Math.Min((float)input_height / height, (float)input_width / width); OpenCvSharp.Size new_size new OpenCvSharp.Size((int)(width * scale), (int)(height * scale)); Cv2.Resize(image, temp_image, new_size); } ratio_height (float)height / temp_image.Rows; ratio_width (float)width / temp_image.Cols; Mat input_img new Mat(); Cv2.CopyMakeBorder(temp_image, input_img, 0, input_height - temp_image.Rows, 0, input_width - temp_image.Cols, BorderTypes.Constant, 0); //Cv2.ImShow(input_img, input_img); //输入Tensor Tensorfloat input_tensor new DenseTensorfloat(new[] { 1, 3, 640, 640 }); for (int y 0; y input_img.Height; y) { for (int x 0; x input_img.Width; x) { input_tensor[0, 0, y, x] input_img.AtVec3b(y, x)[0] / 255f; input_tensor[0, 1, y, x] input_img.AtVec3b(y, x)[1] / 255f; input_tensor[0, 2, y, x] input_img.AtVec3b(y, x)[2] / 255f; } } ListNamedOnnxValue input_container new ListNamedOnnxValue { NamedOnnxValue.CreateFromTensor(images, input_tensor) }; //推理 dt1 DateTime.Now; var ort_outputs onnx_session.Run(input_container).ToArray(); dt2 DateTime.Now; float[] data Transpose(ort_outputs[0].AsTensorfloat().ToArray(), 4 class_num, box_num); float[] confidenceInfo new float[class_num]; float[] rectData new float[4]; ListDetectionResult detResults new ListDetectionResult(); for (int i 0; i box_num; i) { Array.Copy(data, i * (class_num 4), rectData, 0, 4); Array.Copy(data, i * (class_num 4) 4, confidenceInfo, 0, class_num); float score confidenceInfo.Max(); // 获取最大值 int maxIndex Array.IndexOf(confidenceInfo, score); // 获取最大值的位置 int _centerX (int)(rectData[0] * ratio_width); int _centerY (int)(rectData[1] * ratio_height); int _width (int)(rectData[2] * ratio_width); int _height (int)(rectData[3] * ratio_height); detResults.Add(new DetectionResult( maxIndex, class_names[maxIndex], new Rect(_centerX - _width / 2, _centerY - _height / 2, _width, _height), score)); } //NMS CvDnn.NMSBoxes(detResults.Select(x x.Rect), detResults.Select(x x.Confidence), conf_threshold, nms_threshold, out int[] indices); detResults detResults.Where((x, index) indices.Contains(index)).ToList(); //绘制结果 Mat result_image image.Clone(); foreach (DetectionResult r in detResults) { Cv2.PutText(result_image, ${r.Class}:{r.Confidence:P0}, new OpenCvSharp.Point(r.Rect.TopLeft.X, r.Rect.TopLeft.Y - 10), HersheyFonts.HersheySimplex, 1, Scalar.Red, 2); Cv2.Rectangle(result_image, r.Rect, Scalar.Red, thickness: 2); } pictureBox2.Image new Bitmap(result_image.ToMemoryStream()); textBox1.Text 推理耗时: (dt2 - dt1).TotalMilliseconds ms; button2.Enabled true; }注意设置picture1和picture2的SizeMode属性为Zoom
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

怎样看网站是什么语言做的公司宣传折页模板

进程间与网络通信详解 进程间双向管道通信测试 为了测试 pipe_2way 函数,我们编写一个程序,将字符发送给 lowercase 命令,然后接收转换后的字符串。这里使用 readl 函数来完成接收操作,其代码如下: int readl(int fd, char s[], int size) {char *tmp = s;while…

张小明 2026/1/2 3:12:38 网站建设

设计一个商务网站wordpress菜单加图标

全球AI研究与产业界正迎来新一轮技术革新浪潮。在2025年 NeurIPS 大会上,NVIDIA 宣布推出覆盖物理与数字AI领域的全方位开放技术矩阵,包括全球首款面向自动驾驶的产业级推理视觉语言动作模型、语音交互与安全防护新工具,以及支持多场景物理AI…

张小明 2025/12/31 15:54:03 网站建设

网站开发与电子商务c 开发手机网站开发

FaceFusion商业化路径探索:SaaS服务API接口模式在社交媒体滤镜风靡、数字人内容爆发的今天,用户对个性化视觉体验的需求正以前所未有的速度增长。无论是“一键换脸”参与节日营销活动,还是电商平台虚拟试妆提升转化率,背后都离不开…

张小明 2026/1/2 16:17:16 网站建设

东莞网站制作外包小程序是什么东西

阅读对象:C 语言初学者、在校学生、初级嵌入式/系统开发工程师 目标:不仅让你“记住”运算符,更让你“理解”代码背后的逻辑。如果把变量比作 C 语言中的“积木”,那么运算符就是粘合这些积木的“胶水”和“工具”。没有它们&…

张小明 2025/12/24 10:47:08 网站建设

建网站松滋哪家强?深圳房价

POV-Ray射线追踪完全指南:从入门到精通3D渲染 【免费下载链接】povray The Persistence of Vision Raytracer: http://www.povray.org/ 项目地址: https://gitcode.com/gh_mirrors/po/povray POV-Ray是一款功能强大的开源射线追踪程序,能够从文本…

张小明 2026/1/1 15:16:58 网站建设

有没有好网站推荐企服平台

还在为烦人的广告弹窗和恶意网站困扰吗?华硕路由器用户现在可以通过简单的3步操作,轻松搭建企业级的广告拦截系统。这个专为Asuswrt-Merlin固件设计的AdGuardHome安装程序,让您无需专业技术知识就能享受纯净的上网体验,保护家庭网…

张小明 2026/1/1 16:31:56 网站建设