FastestDet:轻量级目标检测 实时Anchor-free目标检测算法,虽然精度稍逊,但FastestDet在速度和参数量上有显著优势,适用于资源有限的设备。
FastDet项目链接:https://github.com/dog-qiuqiu/FastestDet
第一次写文章,不知道该写些什么,直接上代码吧,不足之处还望海涵
onnx模型直接使用作者给的模型 FastestDet-main/example/onnx-runtime/FastestDet.onnx,模型大小不到1MB大小,不得不说,这是真的轻量👍
模型信息
Inputs
-------------------------
name:input.1
tensor:Float[1, 3, 352, 352]
---------------------------------------------------------------
Outputs
-------------------------
name:758
tensor:Float[1, 85, 22, 22]
---------------------------------------------------------------
代码参考 FastestDet-main/example/ncnn/FastestDet.cpp

经多次测试,单次平均推理速度在15ms左右,速度是真的块
其中NMS(非极大值抑制)用的是作者给的函数,也可以使用OpenCV自带的CvDnn.NMSBoxes函数
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenCvSharp;
using OpenCvSharp.Dnn;
using Point = OpenCvSharp.Point;
using Size = OpenCvSharp.Size;
namespace OPENCV
{
public partial class FastDetect : Form
{
public FastDetect()
{
InitializeComponent();
}
string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
string image_path = "";
string[] class_names;
// 阈值
float thresh = 0.65f;
// 模型输入宽高
int input_width = 352;
int input_height = 352;
Net net;
float Sigmoid(float x)
{
return (float)(1.0f / (1.0f + Math.Exp(-x)));
}
float Tanh(float x)
{
return (float)(2.0f / (1.0f + Math.Exp(-2 * x)) - 1);
}
private float IntersectionArea(TargetBox a, TargetBox b)
{
if (a.x1 > b.x2 || a.x2 < b.x1 || a.y1 > b.y2 || a.y2 < b.y1)
{
// no intersection
return 0.0f;
&n

最低0.47元/天 解锁文章
8050

被折叠的 条评论
为什么被折叠?



