发布时间: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')
报错ImportError: numpy.core.multiarray failed to import
教你使用Typora + 阿里云OSS + PicGo 搭建私人图床(最新)
常用的卷积神经网络——LeNet-5(1990‘s)代码实现
39.JavaScript中Promise的基本概念、使用方法,回调地狱规避、链式编程
【SSM】Spring系列——Spring概述、第一个Spring程序、容器接口和实现类
Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]
C++2.0——多线程的使用 promise 和 packaged_task