Pyinstaller 打包pytorch应用(Yolov5为例)
yolov5
yolov5 - Ultralytics YOLOv8的前身,是一个用于目标检测、图像分割和图像分类任务的先进模型。
项目地址:https://gitcode.com/gh_mirrors/yo/yolov5
·
安装pytorch
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
**注:**打包cudatoolkit会出错(报错如图1所示,如果有解决办法请打在评论区,谢谢!),因此使用pip安装pytorch并手动配置CUDA.

打包应用
# 安装pyinstaller
pip install pyinstaller
# 使用pyinstaller打包应用(run.py为程序入口文件)
pyinstaller --noconfirm --onefile --console --clean run.py
遇到的坑
以Yolov5为例
- Linux下需要将pin_memery = False。
- 切记一定要关闭360(如果打开360可能会报如下错误)!!!

- torch_uilt.py: select_device函数中将 “git_describe() or date_modified()” 改为 “date_modified()”。
- pathlib 尽量使用os.path替代
- 加入multiprocessing.freeze_support()。

- opencv-python==4.5.3.56 (版本过高打包完运行时会报错)。
- 打包cudatoolkit会出错(报错如图1所示,如果有解决办法请打在评论区,谢谢!),因此使用pip安装pytorch并手动配置CUDA.
yolov5 - Ultralytics YOLOv8的前身,是一个用于目标检测、图像分割和图像分类任务的先进模型。
最近提交(Master分支:3 个月前 )
6981c274
Refactor code for speed and clarity
Co-authored-by: UltralyticsAssistant <web@ultralytics.com> 2 个月前
f003c3df
This commit resolves an issue where the save-csv command did not write the CSV header. The code now correctly saves the header in the CSV file.
Signed-off-by: Ali Ghanbari <alighanbari446@gmail.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com> 2 个月前
更多推荐




所有评论(0)