发布时间:2022-08-18 18:20
hi yolov5, i met this problem when i try to use the model in my project. the question has solved but i think it's enough classical to open a new issue to describe it
in yolov5 repo, the infer file is detect.py
and the model is ./weights/yolov5s.pt
. The complete detection code is as follows
python detect.py --source ./inference/images/ --weights yolov5s.pt --conf 0.4
i retrained the model and put it in my repo: ./weights/best.pt
. and i put yolov5's models and utils in my repo
└── yolov5
├── detect.py
├── models
├── __pycache__
└── utils
i use ./demo/test.py
to predict and there is something wrong with the program
refer to
torch.load() requires model module in the same folder #3678
ModuleNotFoundError: No module named 'models' #18325
Pytorch.load() error:No module named ‘model’
the key of this problem is Pickle need the same file structure between the calling file and the source file if use the following code to save model
torch.save(model, PATH)
i checked the source file train.py
# Save last, best and delete
torch.save(ckpt, last)
if (best_fitness == fi) and not final_epoch:
torch.save(ckpt, best)
del ckpt
Yes, that's it
use sys.path to include the source file. do it like this:
import sys
sys.path.insert(0, './yolov5')
信息完全技术之Enigma密码机【MATLAB程序及软件APP实现】
LSTM时间序列预测:圆圈搜索算法(Circle Search Algorithm,CSA)优化LSTM权值和阈值(提供MATLAB代码)
【第30天】给定一个整数 n ,求它的因数之和 | 约数之和定理
企业级飞速低代码平台 | 开发人员不喜欢低代码和无代码的八个理由
内网渗透模拟演练:使用sqlmap对内网mssql提权与反弹shell
python特殊变量name_一文掌握 __name__ 变量和在Python中的用法
深度学习与计算机视觉教程:斯坦福CS231n · 全套笔记解读
SpringBoot图文并茂详解如何引入mybatis与连接Mysql数据库