首页 > 其他分享 >yolov5s ncnn practice

yolov5s ncnn practice

时间:2024-08-17 19:37:26浏览次数:13  
标签:pnnx mobilenet onnx practice ncnn https yolov5s

 

Tutorial - deploy YOLOv5 with ncnn

https://github.com/Tencent/ncnn/discussions/4541

 

ncnn model制作(yolov5s.pt -> ncnn.param and ncnn.bin)

 

使用ncnn库编译后生成的工具

https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx

https://ncnn.readthedocs.io/en/latest/how-to-use-and-FAQ/use-ncnn-with-pytorch-or-onnx.html

 

pt -> onnx -> ncnn

 

pytorch to onnx

python export.py --weights yolov5s.pt --include torchscript onnx

 

onnx simplify

pip install onnxsim
python -m onnxsim resnet18.onnx resnet18-sim.onnx

or

pip install onnxslim
python -m onnxslim resnet18.onnx resnet18-slim.onnx

 

onnx to ncnn

onnx2ncnn resnet18-sim.onnx resnet18.param resnet18.bin

 

优化

https://github.com/Tencent/ncnn/wiki/use-ncnnoptimize-to-optimize-model

https://ncnn.readthedocs.io/en/latest/how-to-use-and-FAQ/use-ncnnoptimize-to-optimize-model.html

ncnnoptimize mobilenet.param mobilenet.bin mobilenet-opt.param mobilenet-opt.bin 65536 

 

量化

https://ncnn.readthedocs.io/en/latest/how-to-use-and-FAQ/quantized-int8-inference.html

create calibration table file

下载图片

https://github.com/nihui/imagenet-sample-images

 

find images/ -type f > imagelist.txt
./ncnn2table mobilenet-opt.param mobilenet-opt.bin imagelist.txt mobilenet.table mean=[104,117,123] norm=[0.017,0.017,0.017] shape=[224,224,3] pixel=BGR thread=8 method=kl

 

./ncnn2int8 mobilenet-opt.param mobilenet-opt.bin mobilenet-int8.param mobilenet-int8.bin mobilenet.table

 

使用pnnx工具

pt -> torchscript / onnx -> ncnn

 

https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx

https://github.com/pnnx/pnnx

https://github.com/Tencent/ncnn/discussions/4541

setup yolov5 pytorch

# checkout yolov5 v7.0 project
git clone https://github.com/ultralytics/yolov5
cd yolov5
git checkout v7.0

# install requirements
pip install -r requirements.txt --user

# download yolov5s weight
wget https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s.pt

# test detection with pytorch weight, result saved to runs/detect/expN folder
python detect.py --source /home/nihui/nbs.jpg --weights yolov5s.pt --view-img

export torchscript and convert it to ncnn via pnnx

# export to torchscript, result saved to yolov5s.torchscript
python export.py --weights yolov5s.pt --include torchscript

# download latest pnnx from https://github.com/pnnx/pnnx/releases
wget https://github.com/pnnx/pnnx/releases/download/20230217/pnnx-20230217-ubuntu.zip
unzip pnnx-20230217-ubuntu.zip

# convert torchscript to pnnx and ncnn, result saved to yolov5s.ncnn.param yolov5s.ncnn.bin
./pnnx-20230217-ubuntu/pnnx yolov5s.torchscript inputshape=[1,3,640,640]

 

标签:pnnx,mobilenet,onnx,practice,ncnn,https,yolov5s
From: https://www.cnblogs.com/lightsong/p/18364875

相关文章

  • English speaking practice tools random video chat applications All In One
    EnglishspeakingpracticetoolsrandomvideochatapplicationsAllInOne英语口语练习工具随机视频聊天应用程序SpeakingPractice/SpokenEnglish/OralEnglishOmeTVDiscoverthethrillofrandomvideochatwithOmeTVhttps://ome.tv/???https://www.camgo.......
  • 【图像去噪】论文复现:新手入门必看!DnCNN的Pytorch源码训练测试全流程解析!为源码做详细
    第一次来请先看【专栏介绍文章】:源码只提供了noiselevel为25的DnCNN-S模型文件。本文末尾有完整代码和训练好的σ=15,25,50的DnCNN-S、σ∈[0,55]的DnCNN-B和CDnCNN-B、DnCNN-3共6个模型文件!读者可以自行下载!本文亮点:以官方Pytorch源代码为基础,在DnCNN-S的基础上,增添Dn......
  • System to practice
    1、Linux中哪个系统调用可以用于设置一个定时器,当时间到时,发送一个信号给进程?(B)a)setitimer()b)alarm()c)timer_create()d)time()tips:timer_create()是一个用于创建定时器的系统调用函数,定义在POSIX标准中,属于Linux系统的时间管理功能。它用于创建一个定时器对象,并......
  • 中文翻译《ASPICE in practice》之“SUP.8 配置管理”
    2.16SUP.8配置管理2.16.1目的配置管理流程的目的是建立和维护流程或项目的所有工作产品的完整性,并将其提供给相关各方。 在配置管理(CM)的背景下,配置管理系统至关重要。我们指的是一个或多个CM工具的组合,以支持物理存储和处理以及相关规则,例如指令、流程和约定;后者例......
  • 中文翻译《ASPICE in practice》之“ACQ.4 供应商监控”
    仅供参考,欢迎指正!2.1ACQ.4供应商监控2.1.1目的供应商监控过程的目的是根据商定的要求监控供应商的绩效。除了讨论供应商监控之外,这个过程还涉及与供应商的合作和沟通。合作的基础是选择供应商并且客户与供应商之间存在合同协议。MAN过程和SUP过程中的方法可应用于......
  • 在安卓上运行yolov8目标检测模型(ncnn)
    在安卓上运行yolov8目标检测模型(ncnn)关于首次发表日期:2024-07-25本人不会Java和Android,如有错误,敬请指出主要是整理一下以下资料https://medium.com/@gary.tsai.advantest/top-tutorials-for-deploying-custom-yolov8-on-android-️-dd6746afc1e6https://github.com/FeiGeCh......
  • Best practices for prompt engineering with the OpenAI API
    BestpracticesforpromptengineeringwiththeOpenAIAPIhttps://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-the-openai-api HowpromptengineeringworksDuetothewayOpenAImodelsaretrained,therearespecificpr......
  • zzuli-production practice 2
    1.安装配置Redis并练习基础命令操作官网:https://redis.io中文网:Redis中文网解压直接可以使用:redis.windows.conf:配置文件redis-cli.exe:redis的客户端redis-server.exe:redis服务器端安装Redis服务1、由于上面虽然启动了redis,但是只要一关闭cmd窗口,redis服务就会......
  • Securing Large Language Models: Threats, Vulnerabilities and Responsible Practic
    本文是LLM系列文章,针对《SecuringLargeLanguageModels:Threats,VulnerabilitiesandResponsiblePractices》的翻译。保护大型语言模型:威胁、漏洞和负责任的做法摘要1引言2背景3LLM的安全和隐私问题4对抗性攻击和LLM漏洞5LLM的风险和失误6风险缓解策......
  • Practice
    1.以读写方式打开一个普通文件,且当其不存在时要创建它,应指定的mode参数是(D)A.r+B.rw+C.rwD.w+E.r2.以下那一个是fseek(FILE*stream,longoffset,intwhence)中whence的合法值?DA.SEEK_OOPB.SEEK_BIGC.SEEK_TELD.SEEK_SETE.SEEK_GET3.已知字符‘A’的ASCII代码值是65......