C# OnnxRuntime部署DAMO-YOLO人头检测
目录
说明
效果
模型信息
项目
代码
下载
参考
说明
效果
模型信息
Model Properties
-------------------------
---------------------------------------------------------------
Inputs
-------------------------
name:input
tensor:Float[1, 3, 640, 640]
---------------------------------------------------------------
Outputs
-------------------------
name:transposed_output
tensor:Float[1, 5, 8400]
---------------------------------------------------------------
项目
代码
using Microsoft.ML.OnnxRuntime;
using Microsoft.ML.OnnxRuntime.Tensors;
using OpenCvSharp;
using OpenCvSharp.Dnn;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Onnx_Demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
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;
InferenceSession onnx_session;
int box_num;
float conf_threshold;
float nms_threshold;
StringBuilder sb = new StringBuilder();
/// <summary>
/// 选择图片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = fileFilter;
if (ofd.ShowDialog() != DialogResult.OK) return;
pictureBox1.Image = null;
image_path = ofd.FileName;
pictureBox1.Image = new Bitmap(image_path);
textBox1.Text = "";
pictureBox2.Image = null;
}
/// <summary>
/// 推理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
if (image_path == "")
{
return;
}
button2.Enabled = false;
pictureBox2.Image = null;
textBox1.Text = "";
sb.Clear();
Application.DoEvents();
Mat image = new Mat(image_path);
float ratio = Math.Min(input_height * 1.0f / image.Rows, input_width * 1.0f / image.Cols);
int neww = (int)(image.Cols * ratio);
int newh = (int)(image.Rows * ratio);
Mat dstimg = new Mat();
Cv2.CvtColor(image, dstimg, ColorConversionCodes.BGR2RGB);
Cv2.Resize(dstimg, dstimg, new OpenCvSharp.Size(neww, newh));
Cv2.CopyMakeBorder(dstimg, dstimg, 0, input_height - newh, 0, input_width - neww, BorderTypes.Constant, new Scalar(1));
//Cv2.ImShow("input_img", dstimg);
//输入Tensor
Tensor<float> input_tensor = new DenseTensor<float>(new[] { 1, 3, 640, 640 });
for (int y = 0; y < dstimg.Height; y++)
{
for (int x = 0; x < dstimg.Width; x++)
{
input_tensor[0, 0, y, x] = dstimg.At<Vec3b>(y, x)[0];
input_tensor[0, 1, y, x] = dstimg.At<Vec3b>(y, x)[1];
input_tensor[0, 2, y, x] = dstimg.At<Vec3b>(y, x)[2];
}
}
dstimg.Dispose();
List<NamedOnnxValue> input_container = new List<NamedOnnxValue>
{
NamedOnnxValue.CreateFromTensor("input", input_tensor)
};
//推理
dt1 = DateTime.Now;
var ort_outputs = onnx_session.Run(input_container).ToArray();
dt2 = DateTime.Now;
float[] data = Transpose(ort_outputs[0].AsTensor<float>().ToArray(), 4 + class_num, box_num);
float[] confidenceInfo = new float[class_num];
float[] rectData = new float[4];
List<DetectionResult> detResults = new List<DetectionResult>();
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 xmin = (int)(rectData[0] / ratio);
int ymin = (int)(rectData[1] / ratio);
int xmax = (int)(rectData[2] / ratio);
int ymax = (int)(rectData[3] / ratio);
Rect box = new Rect();
box.X = (int)xmin;
box.Y = (int)ymin;
box.Width = (int)(xmax - xmin);
box.Height = (int)(ymax - ymin);
detResults.Add(new DetectionResult(
maxIndex,
class_names[maxIndex],
box,
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();
sb.AppendLine("推理耗时:" + (dt2 - dt1).TotalMilliseconds + "ms");
sb.AppendLine("------------------------------");
//绘制结果
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);
sb.AppendLine(string.Format("{0}:{1},({2},{3},{4},{5})"
, r.Class
, r.Confidence.ToString("P0")
, r.Rect.TopLeft.X
, r.Rect.TopLeft.Y
, r.Rect.BottomRight.X
, r.Rect.BottomRight.Y
));
}
if (pictureBox2.Image != null)
{
pictureBox2.Image.Dispose();
}
pictureBox2.Image = new Bitmap(result_image.ToMemoryStream());
result_image.Dispose();
textBox1.Text = sb.ToString();
button2.Enabled = true;
}
/// <summary>
///窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{
model_path = "model/damoyolo_head.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/lable.txt";
class_names = File.ReadAllLines(classer_path, Encoding.UTF8);
class_num = class_names.Length;
image_path = "test_img/2.jpg";
pictureBox1.Image = new Bitmap(image_path);
}
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
if (pictureBox2.Image == null)
{
return;
}
Bitmap output = new Bitmap(pictureBox2.Image);
SaveFileDialog sdf = new SaveFileDialog();
sdf.Title = "保存";
sdf.Filter = "Images (*.jpg)|*.jpg|Images (*.png)|*.png|Images (*.bmp)|*.bmp|Images (*.emf)|*.emf|Images (*.exif)|*.exif|Images (*.gif)|*.gif|Images (*.ico)|*.ico|Images (*.tiff)|*.tiff|Images (*.wmf)|*.wmf";
if (sdf.ShowDialog() == DialogResult.OK)
{
switch (sdf.FilterIndex)
{
case 1:
{
output.Save(sdf.FileName, ImageFormat.Jpeg);
break;
}
case 2:
{
output.Save(sdf.FileName, ImageFormat.Png);
break;
}
case 3:
{
output.Save(sdf.FileName, ImageFormat.Bmp);
break;
}
case 4:
{
output.Save(sdf.FileName, ImageFormat.Emf);
break;
}
case 5:
{
output.Save(sdf.FileName, ImageFormat.Exif);
break;
}
case 6:
{
output.Save(sdf.FileName, ImageFormat.Gif);
break;
}
case 7:
{
output.Save(sdf.FileName, ImageFormat.Icon);
break;
}
case 8:
{
output.Save(sdf.FileName, ImageFormat.Tiff);
break;
}
case 9:
{
output.Save(sdf.FileName, ImageFormat.Wmf);
break;
}
}
MessageBox.Show("保存成功,位置:" + sdf.FileName);
}
}
private void pictureBox1_DoubleClick(object sender, EventArgs e)
{
ShowNormalImg(pictureBox1.Image);
}
private void pictureBox2_DoubleClick(object sender, EventArgs e)
{
ShowNormalImg(pictureBox2.Image);
}
public void ShowNormalImg(Image img)
{
if (img == null) return;
frmShow frm = new frmShow();
frm.Width = Screen.PrimaryScreen.Bounds.Width;
frm.Height = Screen.PrimaryScreen.Bounds.Height;
if (frm.Width > img.Width)
{
frm.Width = img.Width;
}
if (frm.Height > img.Height)
{
frm.Height = img.Height;
}
bool b = frm.richTextBox1.ReadOnly;
Clipboard.SetDataObject(img, true);
frm.richTextBox1.ReadOnly = false;
frm.richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Bitmap));
frm.richTextBox1.ReadOnly = b;
frm.ShowDialog();
}
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;
}
}
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; }
}
}
using Microsoft.ML.OnnxRuntime;
using Microsoft.ML.OnnxRuntime.Tensors;
using OpenCvSharp;
using OpenCvSharp.Dnn;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace Onnx_Demo
{public partial class Form1 : Form{public Form1(){InitializeComponent();}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;InferenceSession onnx_session;int box_num;float conf_threshold;float nms_threshold;StringBuilder sb = new StringBuilder();/// <summary>/// 选择图片/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button1_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;if (ofd.ShowDialog() != DialogResult.OK) return;pictureBox1.Image = null;image_path = ofd.FileName;pictureBox1.Image = new Bitmap(image_path);textBox1.Text = "";pictureBox2.Image = null;}/// <summary>/// 推理/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button2_Click(object sender, EventArgs e){if (image_path == ""){return;}button2.Enabled = false;pictureBox2.Image = null;textBox1.Text = "";sb.Clear();Application.DoEvents();Mat image = new Mat(image_path);float ratio = Math.Min(input_height * 1.0f / image.Rows, input_width * 1.0f / image.Cols);int neww = (int)(image.Cols * ratio);int newh = (int)(image.Rows * ratio);Mat dstimg = new Mat();Cv2.CvtColor(image, dstimg, ColorConversionCodes.BGR2RGB);Cv2.Resize(dstimg, dstimg, new OpenCvSharp.Size(neww, newh));Cv2.CopyMakeBorder(dstimg, dstimg, 0, input_height - newh, 0, input_width - neww, BorderTypes.Constant, new Scalar(1));//Cv2.ImShow("input_img", dstimg);//输入TensorTensor<float> input_tensor = new DenseTensor<float>(new[] { 1, 3, 640, 640 });for (int y = 0; y < dstimg.Height; y++){for (int x = 0; x < dstimg.Width; x++){input_tensor[0, 0, y, x] = dstimg.At<Vec3b>(y, x)[0];input_tensor[0, 1, y, x] = dstimg.At<Vec3b>(y, x)[1];input_tensor[0, 2, y, x] = dstimg.At<Vec3b>(y, x)[2];}}dstimg.Dispose();List<NamedOnnxValue> input_container = new List<NamedOnnxValue>{NamedOnnxValue.CreateFromTensor("input", input_tensor)};//推理dt1 = DateTime.Now;var ort_outputs = onnx_session.Run(input_container).ToArray();dt2 = DateTime.Now;float[] data = Transpose(ort_outputs[0].AsTensor<float>().ToArray(), 4 + class_num, box_num);float[] confidenceInfo = new float[class_num];float[] rectData = new float[4];List<DetectionResult> detResults = new List<DetectionResult>();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 xmin = (int)(rectData[0] / ratio);int ymin = (int)(rectData[1] / ratio);int xmax = (int)(rectData[2] / ratio);int ymax = (int)(rectData[3] / ratio);Rect box = new Rect();box.X = (int)xmin;box.Y = (int)ymin;box.Width = (int)(xmax - xmin);box.Height = (int)(ymax - ymin);detResults.Add(new DetectionResult(maxIndex,class_names[maxIndex],box,score));}//NMSCvDnn.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();sb.AppendLine("推理耗时:" + (dt2 - dt1).TotalMilliseconds + "ms");sb.AppendLine("------------------------------");//绘制结果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);sb.AppendLine(string.Format("{0}:{1},({2},{3},{4},{5})", r.Class, r.Confidence.ToString("P0"), r.Rect.TopLeft.X, r.Rect.TopLeft.Y, r.Rect.BottomRight.X, r.Rect.BottomRight.Y));}if (pictureBox2.Image != null){pictureBox2.Image.Dispose();}pictureBox2.Image = new Bitmap(result_image.ToMemoryStream());result_image.Dispose();textBox1.Text = sb.ToString();button2.Enabled = true;}/// <summary>///窗体加载/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void Form1_Load(object sender, EventArgs e){model_path = "model/damoyolo_head.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/lable.txt";class_names = File.ReadAllLines(classer_path, Encoding.UTF8);class_num = class_names.Length;image_path = "test_img/2.jpg";pictureBox1.Image = new Bitmap(image_path);}/// <summary>/// 保存/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button3_Click(object sender, EventArgs e){if (pictureBox2.Image == null){return;}Bitmap output = new Bitmap(pictureBox2.Image);SaveFileDialog sdf = new SaveFileDialog();sdf.Title = "保存";sdf.Filter = "Images (*.jpg)|*.jpg|Images (*.png)|*.png|Images (*.bmp)|*.bmp|Images (*.emf)|*.emf|Images (*.exif)|*.exif|Images (*.gif)|*.gif|Images (*.ico)|*.ico|Images (*.tiff)|*.tiff|Images (*.wmf)|*.wmf";if (sdf.ShowDialog() == DialogResult.OK){switch (sdf.FilterIndex){case 1:{output.Save(sdf.FileName, ImageFormat.Jpeg);break;}case 2:{output.Save(sdf.FileName, ImageFormat.Png);break;}case 3:{output.Save(sdf.FileName, ImageFormat.Bmp);break;}case 4:{output.Save(sdf.FileName, ImageFormat.Emf);break;}case 5:{output.Save(sdf.FileName, ImageFormat.Exif);break;}case 6:{output.Save(sdf.FileName, ImageFormat.Gif);break;}case 7:{output.Save(sdf.FileName, ImageFormat.Icon);break;}case 8:{output.Save(sdf.FileName, ImageFormat.Tiff);break;}case 9:{output.Save(sdf.FileName, ImageFormat.Wmf);break;}}MessageBox.Show("保存成功,位置:" + sdf.FileName);}}private void pictureBox1_DoubleClick(object sender, EventArgs e){ShowNormalImg(pictureBox1.Image);}private void pictureBox2_DoubleClick(object sender, EventArgs e){ShowNormalImg(pictureBox2.Image);}public void ShowNormalImg(Image img){if (img == null) return;frmShow frm = new frmShow();frm.Width = Screen.PrimaryScreen.Bounds.Width;frm.Height = Screen.PrimaryScreen.Bounds.Height;if (frm.Width > img.Width){frm.Width = img.Width;}if (frm.Height > img.Height){frm.Height = img.Height;}bool b = frm.richTextBox1.ReadOnly;Clipboard.SetDataObject(img, true);frm.richTextBox1.ReadOnly = false;frm.richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Bitmap));frm.richTextBox1.ReadOnly = b;frm.ShowDialog();}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;}}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; }}}
下载
源码下载
参考
https://modelscope.cn/models/iic/cv_tinynas_head-detection_damoyolo/summary
相关文章:
C# OnnxRuntime部署DAMO-YOLO人头检测
目录 说明 效果 模型信息 项目 代码 下载 参考 说明 效果 模型信息 Model Properties ------------------------- --------------------------------------------------------------- Inputs ------------------------- name:input tensor:Floa…...
DDD该怎么去落地实现(4)多对多关系
多对多关系的设计实现 如题,DDD该如何落地呢?前面我通过三期的内容,讲解了DDD落地的关键在于“关系”,也就是通过前面我们对业务的理解先形成领域模型,然后将领域模型的原貌,形成程序代码中的服务、实体、…...
Vue 3 组件库开发实战:打造基础 UI 组件库并发布 - 构建可复用的 Vue 组件资产
引言 欢迎再次回到 Vue 3 + 现代前端工程化 系列技术博客! 在昨天的第六篇博客中,我们深入探索了 Vue 3 Composition API 的进阶应用,通过构建可拖拽看板应用,熟练掌握了自定义 Hook 的代码复用技巧。 今天,我们将迈向 Vue 3 组件化开发的更高阶段,聚焦于 组件库的开发与…...
UNION 和 UNION ALL 的区别:深入解析 SQL 中的合并操作
在 SQL 的世界里,当我们需要合并多个查询结果集时,UNION和UNION ALL是两个常用的操作符。虽然它们的功能看起来相似,但实际上有着重要的区别,这些区别在不同的应用场景中会对查询结果和性能产生显著影响。本文将详细探讨UNION和UN…...
Redis 哈希(Hash)
Redis 哈希(Hash) 概述 Redis 哈希(Hash)是一种特殊的键值对类型,它允许存储结构化的数据,例如一个对象或记录。每个哈希值可以包含多个字段,每个字段又可以存储一个字符串值。这使得Redis哈希非常适合用于存储对象的…...
Android Activity栈关系解析
在 Android 系统中,这些类共同构成了 Activity 任务栈管理的核心架构。它们的关系可以类比为一栋大楼的管理体系,每个类负责不同层级的任务。以下是它们的详细解释和实际场景示例: 1. ActivityRecord(活动记录) 是什么…...
7.1.2 计算机网络的分类
文章目录 分布范围交换方式 分布范围 计算机网络按照分布范围可分为局域网、广域网、城域网。局域网的范围在10m~1km,例如校园网,网速高,主要用于共享网络资源,拓扑结构简单,约束少。广域网的范围在100km,例…...
Arcgis中添加脚本工具箱
准备资料 (1)工具箱 (2)python脚本 1、打开arcmap 2、找到目录窗口 3、复制粘贴工具箱的路径 4、添加或者确认python脚本路径 脚本上右键属性(注意:脚本内容和路径最后都不要有中文,否则可能报错) 如果…...
【Python 数据结构 1.零基础复习】
目录 一、输入与输出 1.输入 2.格式化输出 二、数字与变量 1.字符串 & 整型 2.字符串 & 整型 & 浮点型 3.变量 练习 2235. 两整数相加 三、运算与操作 1.四则运算 练习 2769. 找出最大的可达成数字 3.取整与取余 练习 2651. 计算列车到站时间 编辑 四、真与假 1…...
颠覆NLP的魔法:深度解读Transformer架构及其核心组件
目录 颠覆NLP的魔法:深度解读Transformer架构及其核心组件 一、Transformer 架构概述 二、核心组件解析 1. Self-Attention(自注意力机制) 2. 位置编码(Positional Encoding) 3. 多头注意力(Multi-Hea…...
【pytest框架源码分析二】pluggy源码分析之add_hookspecs和register
这里我们看一下_manager.py里的类和方法,最主要的是PluginManager类,类的初始化函数如下: class PluginManager:"""Core class which manages registration of plugin objects and 1:N hookcalling.You can register new hoo…...
【leetcode hot 100 53】最大子数组和
解法一:(动态规划)我们用 f(i) 代表以第 i 个数结尾的「连续子数组的最大和」,那么很显然我们要求的答案就是:max{f(i)},f(i)max{f(i−1)nums[i],nums[i]} class Solution {public int maxSubArray(int[] …...
Sqlserver安全篇之_启用TLS即配置SQL Server 数据库引擎以加密连接
官方文档 https://learn.microsoft.com/zh-cn/sql/database-engine/configure-windows/configure-sql-server-encryption?viewsql-server-ver16 https://learn.microsoft.com/zh-cn/sql/database-engine/configure-windows/manage-certificates?viewsql-server-ver15&pre…...
009---基于Verilog HDL的单比特信号边沿检测
文章目录 摘要一、边沿检测二、时序逻辑实现2.1 rtl2.2 tb 三、组合逻辑实现3.1 rtl3.2 tb 摘要 文章为学习记录。采用时序逻辑和组合逻辑实现边沿检测的核心逻辑。组合逻辑实现的上升沿和下降沿的脉冲比时序逻辑实现的上升沿和下降沿的脉冲提前一拍。 一、边沿检测 边沿检测…...
istio的核心概念简介
Istio 是一个开源的服务网格(Service Mesh)平台,旨在帮助管理、连接、保护和观察分布式微服务架构中的服务。它最初由 Google、IBM 和 Lyft 合作开发,广泛应用于 Kubernetes 环境。Istio 的核心目标是通过提供统一的流量管理、安全…...
如何在Apple不再支持的MacOS上安装Homebrew
手头有一台2012年产的Macbook Pro,系统版本停留在了10.15.7(2020年9月24日发布的)。MacOS 11及后续的版本都无法安装到这台老旧的电脑上。想通过pkg安装Homebrew,发现Homebrew releases里最新的pkg安装包不支持MacOS 10.15.7&…...
@update 的常见用法 Vue.js
在 Vue.js 中,update 是一个事件监听器,通常用于监听自定义组件或某些 Vue 原生组件(如 <input> 或自定义组件)的更新事件。它并不是 Vue 的核心 API,而是一种约定俗成的命名方式,用于处理组件内部状…...
C#开发——日期操作类DateTime
在C#中,日期和时间的操作主要通过 System.DateTime 类来实现。 DateTime 提供了丰富的属性和法,用于处理日期和时间的创建、格式化、比较和计算等操作。以下是一些常用的日期函数和特性: 一、创建日期和时间 1、直接指定日期和时间&…...
大语言模型学习--LangChain
LangChain基本概念 ReAct学习资料 https://zhuanlan.zhihu.com/p/660951271 LangChain官网地址 Introduction | 🦜️🔗 LangChain LangChain是一个基于语言模型开发应用程序的框架。它可以实现以下应用程序: 数据感知:将语言模型…...
Oracle数据库安全防护体系构建与核心技术解析
引言:从某跨国集团数据泄露事件看Oracle防护困局 2025年1月,某跨国零售企业Oracle数据库遭APT组织"暗夜猎手"攻击,攻击者通过三重渗透路径实现数据窃取: 存储层突破:利用Oracle TDE密钥管理漏洞获取wallet…...
iOS UICollectionViewCell 点击事件自动化埋点
iOS 中经常要进行埋点,我们这里支持 UICollectionViewCell. 进行自动化埋点,思路: 通过hook UICollectionViewCell 的setSelected:方法, 则新的方法中执行埋点逻辑,并调用原来的方法 直接上代码 implementation UICol…...
软件工程---基于构件的软件工程
基于构件的软件工程(CBSE)是一种软件开发方法,通过重用现有的软件构件来构建系统,从而提高开发效率和软件质量。这种方法强调软件系统的模块化设计和构建复用,使得软件开发过程更加高效和灵活。 企业软件开发…...
Redis--单线程模型
目录 一、引言 二、Redis单线程模型 三、原因 四、为什么redis是单线程模型,但他的速度这么快? 五、总结 一、引言 本篇文章就Redis为什么是单线程模型做简单介绍。 二、Redis单线程模型 redis只使用一个线程,处理所有的命令请求&#x…...
NodeJS服务器 + Vue3框架 从搭建服务器 定义接口 到请求数据页面展示
NodeJS服务器 Vue3框架全栈开发 后端项目初始化项目安装express创建服务器server.js启动服务验证服务是否启动成功 前端项目新建vue3项目安装axios启动前端项目启动时报错问题解决 vue页面使用axios调用node接口完整代码页面效果图跨域问题解决 本篇文章主要介绍使用Node.js和…...
3.1、密码学基础
目录 密码学概念与法律密码安全分析密码体制分类 - 私钥密码/对称密码体制密码体制分类 - 公钥密码/非对称密码体制密码体制分类 - 混合密码体制 密码学概念与法律 密码学主要是由密码编码以及密码分析两个部分组成,密码编码就是加密,密码分析就是把我们…...
iOS接入Flutter项目
首先要把iOS项目和flutter项目统一目录下,而且需要注意的是flutter是module。 第一步:Flutter相关内容的创建 module创建命令: flutter create --templatemodule my_flutter,之后再执行 flutter pub get flutter build ios …...
点云配准技术的演进与前沿探索:从传统算法到深度学习融合(4)
4、点云配准面临的挑战与应对策略 4.1 点云配准面临的主要挑战 在点云配准的实际应用中,尽管已经取得了显著的研究成果,但仍然面临着诸多复杂而严峻的挑战,这些挑战严重制约了点云配准技术在更多领域的广泛应用和深入发展。 在自动驾驶场景…...
SEKI —— 基于大型语言模型的自进化与知识启发式神经架构搜索
01、项目概述 我们引入了一种基于新型大型语言模型( LLM )的神经架构搜索( NAS )方法,名为 SEKI 。SEKI 受到现代 LLM 中思维链( CoT )范式的启发,分为两个关键阶段运行:…...
Nat Mach Intell | AI分子对接算法评测
《Nature Machine Intelligence》发表重磅评测,系统评估AI与物理方法在虚拟筛选(VS)中的表现,突破药物发现效率瓶颈。 核心评测体系:三大数据集 研究团队构建了三个新型测试集: TrueDecoy:含14…...
01. HarmonyOS应用开发实践与技术解析
文章目录 前言项目概述HarmonyOS应用架构项目结构Ability生命周期 ArkTS语言特性装饰器状态管理 UI组件与布局基础组件响应式布局样式与主题 页面路由与参数传递页面跳转参数接收 数据绑定与循环渲染数据接口定义循环渲染 条件渲染组件生命周期最佳实践与性能优化组件复用响应式…...
001-码云操作
码云操作 一、配置公钥1.官网地址1.进入 git bash2.查看生成的公钥3.设置到 Gitee4.测试 二、初始化一个项目1.新建仓库 一、配置公钥 方便后续提交代码不用填写密码 1.官网地址 官网地址:https://gitee.com/Git码云教程:https://gitee.com/help/arti…...
10.LED点阵实验
LED点阵是一种由发光二极管排列而成的显示器件,在生活里的各种电器中很常见,像汽车报站器和广告屏等地方都会用到它。 平时用得比较多的是 88 点阵。多个 88 点阵能组合成不同大小的 LED 点阵显示屏,比如 4 个 88 点阵可以拼成一个 1616 点阵…...
cesium+vue3自定义HTML实体弹窗、加高德路网、防实体漂浮、让用户画圆、鹰眼
一、基础使用:Cesium.js基础使用(vue)-CSDN博客 1、基础路径 为 Cesium 库设置一个全局变量 CESIUM_BASE_URL,用于指定 Cesium 的资源文件(如 WebGL shaders、纹理、字体等)的 示例场景:假设你…...
Spring(二)容器-注册
目录 一 定义组件Bean (1)添加组件 (2)获取组件 二 配置类Configuration (1)配置类的作用 三 MVC分层注解 - Controller: - Service: - Repository: 四 批量扫描ComponentScan (1) 默认扫描当前包及其子包 (2) 指定扫描包路径 …...
Java-实现PDF合同模板填写内容并导出PDF文件
可用于公司用户合同导出pdf文件 效果图 一、导入所需要jar包 <!--生成PDF--><dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.5.11</version></dependency><dependency&…...
C# 数据转换
1. 文本框读取byte,ushort格式数据 byte addr; if (byte.TryParse(textBoxAddr.Text, out addr) true) {}2. 字节数组 (byte[]) 转换为 ASCII 字符串 byte[] bytes { 72, 101, 108, 108, 111 }; // "Hello" 的 ASCII 码 string s0 Encoding.ASCII.Ge…...
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_list_init
ngx_list_init 定义在 src\core\ngx_list.h static ngx_inline ngx_int_t ngx_list_init(ngx_list_t *list, ngx_pool_t *pool, ngx_uint_t n, size_t size) {list->part.elts ngx_palloc(pool, n * size);if (list->part.elts NULL) {return NGX_ERROR;}list->par…...
鸿蒙NEXT开发-元服务和服务卡片的开发
注意:博主有个鸿蒙专栏,里面从上到下有关于鸿蒙next的教学文档,大家感兴趣可以学习下 如果大家觉得博主文章写的好的话,可以点下关注,博主会一直更新鸿蒙next相关知识 目录 1. 元服务基本概念 1.1 基本介绍 1.2 元…...
Docker安装Redpandata-console控制台
介绍 Redpanda控制台,这是一个功能强大的Web UI,用于管理和监控您的Redpanda 集群。探索实际示例和场景,以帮助您了解如何利用 Redpanda 控制台实现不同的用例,包括数据可观察性、Redpanda 管理、访问控制和连接。 可对Redpanda…...
DeepSeek Agent 企业应用
DeepSeek Agent 技术是基于深度求索(DeepSeek)大模型构建的智能代理系统,其核心技术架构与应用优势可从以下几个方面进行深度解析: 一、核心技术架构 混合专家模型(MoE)与架构优化 DeepSeek 的模型家族(如DeepSeekMoE、DeepSeek-V3)采用 混合专家系统(MoE) ,通过动…...
vcredist_x64 资源文件分享
vcredist_x64 是 Microsoft Visual C Redistributable 的 64 位版本,用于在 64 位 Windows 系统上运行使用 Visual C 开发的应用程序。它包含了运行这些应用程序所需的运行时组件。 vcredist_x64 资源工具网盘下载链接:https://pan.quark.cn/s/ef56f838f…...
解决redis lettuce连接池经常出现连接拒绝(Connection refused)问题
一.软件环境 windows10、11系统、springboot2.x、redis 6 7 linux(centos)系统没有出现这问题,如果你是linux系统碰到的,本文也有一定大参考价值。 根本思路就是:tcp/ip连接的保活(keepalive)。 二.问题描述 在spr…...
Mac远程桌面软件哪个好用?
远程桌面软件能帮助我们快速的远程控制另一台电脑,从而提供远程帮助,或者进行远程办公。那么,对macOS系统有什么好用的Mac远程桌面软件呢? 远程看看是一款操作简单、界面简洁的远程桌面软件,支持跨平台操作࿰…...
一篇吃透模型:all-MiniLM-L6-v2
MiniLM 是什么? MiniLM 是微软研究院开发的一种轻量级的语言模型,旨在以较小的参数量和计算成本实现与大型语言模型(如 BERT)相当的性能。它是基于 Transformer 架构的预训练模型,通过深度自注意力蒸馏(De…...
深入学习Linux内存管理-缺页异常
1.什么是缺页异常 在Linux虚拟内存管理中,缺页异常(Page Fault) 是CPU在访问虚拟地址时发现对应物理页未就绪时触发的中断。根据触发原因,缺页异常分为两类: 次要缺页(Minor Fault):物理页已存在(如缓存或共享内存),只需建立映射。 主要缺页(Major Fault):需要…...
互推机制在开源AI智能名片2+1链动模式S2B2C商城小程序源码推广中的应用探索
摘要: 在数字化营销时代,开源AI智能名片21链动模式S2B2C商城小程序源码作为一种创新的技术解决方案,正逐步成为企业数字化转型的重要工具。然而,面对激烈的市场竞争,如何高效推广这一前沿技术产品,成为开发…...
SparkSQL全之RDD、DF、DS ,UDF、架构、资源划分、sql执行计划、调优......
1 SparkSQL概述 1.1 sparksql简介 Shark是专门针对于spark的构建大规模数据仓库系统的一个框架Shark与Hive兼容、同时也依赖于Spark版本Hivesql底层把sql解析成了mapreduce程序,Shark是把sql语句解析成了Spark任务随着性能优化的上限,以及集成SQL的一些…...
神经网络 - 激活函数(Maxout 单元)
一、Maxout 单元 Maxout 单元是一种特殊的激活函数,用于神经网络中,其主要思想是通过多个线性变换的最大值来作为神经元的输出,从而提高模型的表达能力和鲁棒性。 1. 数学定义 假设输入为 x,Maxout 单元会计算 k 个线性变换&am…...
【软考-架构】1.3、磁盘-输入输出技术-总线
GitHub地址:https://github.com/tyronczt/system_architect ✨资料&文章更新✨ 文章目录 存储系统💯考试真题输入输出技术💯考试真题第一题第二题 存储系统 寻道时间是指磁头移动到磁道所需的时间; 等待时间为等待读写的扇区…...
专业便捷PDF软件,即开即用
PDF文件因其小巧的体积、便捷的分享与存储方式,以及卓越的安全性,已成为学习、企业及各类机构中不可或缺的文件格式。无论是在学术研究、课程资料、商业报告还是合同文件中,PDF都能有效保持原有的格式和布局,确保内容在不同设备和…...