当前位置:网站首页>Graphical tools package yolov5 and generate executable files exe
Graphical tools package yolov5 and generate executable files exe
2022-07-07 03:22:00 【Master Ma】
Environmental Science
windows 10 64bit
auto-py-to-exe 2.10.1
Preface
Python Project packaging is a question that many novices often ask , Previous articles have also introduced how to use pyinstaller To package and generate executable files , It's just that the packaging process is based on the command line . The tool introduced in this article ,auto-py-to-exe, It is pyinstaller Of GUI edition , Be more friendly to new people , You can easily do it with a click of the mouse , that , Let's get started .
install
Use pip Direct installation
pip install auto-py-to-exe
Or pull the source code , Unzip and enter the root directory , perform
python setup.py install
Packaging example
This article uses the previous yolov5-pyqt5 Package the project , Here's a little bit of attention , If you are using python A virtual environment , It must be installed in this virtual environment auto-py-to-exe
After the project code is pulled down , modify main.py, take
self.device = select_device(self.opt.device)
Change it to
# gpu
self.device = torch.device('cuda:0')
# If only cpu Words , Change to
# self.device = torch.device('cpu')
Why should we change this ? This is mainly select_device The method uses subprocess, and pyinstaller Packing subprocess Method will report an error , If you go to modify subprocess Part of the code is a little troublesome , For the sake of simplicity , You won't call this method , For details, please refer to https://xugaoxiang.com/2019/12/04/pyqt5-4-pyinstaller/
then , open auto-py-to-exe, Script file selection yolov5-pyqt5 Under folder main.py, Select single file , That is, only one executable file is generated in the end 
In the Advanced tab , Click on --hidden-import The plus sign on the right , Then fill in modles.yolo, otherwise , Generated exe The following error will be reported when running
Traceback (most recent call last):
File "detect_image.py", line 405, in <module>
File "detect_image.py", line 365, in main
File "detect_image.py", line 293, in detection_alertarea
File "detect_image.py", line 79, in __init__
File "models\experimental.py", line 137, in attempt_load
File "torch\serialization.py", line 594, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "torch\serialization.py", line 853, in _load
result = unpickler.load()
ModuleNotFoundError: No module named 'models.yolo'
[12976] Failed to execute script detect_image

Others are similar No module named xxx Error of , It's the same solution 
In the process of checking the configuration , The current command will display the corresponding pyinstaller Instructions , If you do not install auto-py-to-exe, Only installed pyinstaller, Then copy this command , It can also be packaged successfully
If no error is reported , project-generated exe The file will be placed in... By default C:\Users\ user name \output Next
Prepare the official model file yolov5s.pt, Put it in weights Under the folder , Then double click. exe file

Last , Select a test picture to test , Function is normal

Reference material
https://github.com/brentvollebregt/auto-py-to-exe
https://xugaoxiang.com/2019/12/04/pyqt5-4-pyinstaller/
https://github.com/xugaoxiang/yolov5-pyqt5
边栏推荐
- Appx代码签名指南
- Codeforces round 264 (Div. 2) C gargari and Bishop [violence]
- CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation
- Flink Task退出流程与Failover机制
- Matlab Error (Matrix dimensions must agree)
- Leetcode-02 (linked list question)
- Le tube MOS réalise le circuit de commutation automatique de l'alimentation principale et de l'alimentation auxiliaire, et la chute de tension "zéro", courant statique 20ua
- 房费制——登录优化
- Cryptography series: detailed explanation of online certificate status protocol OCSP
- 上个厕所的功夫,就把定时任务的三种调度策略说得明明白白
猜你喜欢

The solution of unable to create servlet file after idea restart

Do you know the five most prominent advantages of E-bidding?

Significance and measures of source code confidentiality

知识图谱构建全流程

leetcode

VHDL实现单周期CPU设计

Appx code signing Guide

数学归纳与递归

Under the tide of "going from virtual to real", Baidu AI Cloud is born from real

How to verify accesstoken in oauth2 protocol
随机推荐
函数重入、函数重载、函数重写自己理解
How-PIL-to-Tensor
Jerry's ble exiting Bluetooth mode card machine [chapter]
centerX: 用中国特色社会主义的方式打开centernet
Jerry's question about DAC output power [chapter]
Matlab Error (Matrix dimensions must agree)
注意力机制原理
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
如何分析粉丝兴趣?
IDEA重启后无法创建Servlet文件的解决方案
[Dameng database] after backup and recovery, two SQL statements should be executed
Decoration design enterprise website management system source code (including mobile source code)
Leetcode-02 (linked list question)
尚硅谷JVM-第一章 类加载子系统
Jericho turns on the display icon of the classic Bluetooth hid mobile phone to set the keyboard [chapter]
树莓派设置wifi自动连接
存储过程与函数(MySQL)
unrecognized selector sent to instance 0x10b34e810
腾讯云原生数据库TDSQL-C入选信通院《云原生产品目录》
图形化工具打包YOLOv5,生成可执行文件EXE