当前位置:网站首页>AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm
AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm
2022-07-06 06:35:00 【振华OPPO】
我在ubuntu下已经成功运行了yolov5的多个版本,也出了环境部署教程。然后因为转换模型的需求,我重新非官网仓库下载了yolov5代码,但是该仓库作者并没有标明是在哪一个版本基础上进行魔改的。然后我就正常地使用6.1版本的模型,当然环境依赖不需要安装,yolov5的环境都是一样,一次安装,永久运行。
| 报错信息 |
|---|
运行detect.py文件,然后就出现下面报错:
Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.25, device='',
exist_ok=False, img_size=416, iou_thres=0.45, name='exp', project='runs/detect',
rknn_mode=False, save_conf=False, save_txt=False, source='rtsp://admin:@192.168.144.64/h264/ch1
/main/av_stream', update=False, view_img=False, weights='./models/yolov5s.pt')
YOLOv5 torch 1.9.0 CPU
Traceback (most recent call last):
File "detect.py", line 258, in <module>
detect()
File "detect.py", line 34, in detect
model = attempt_load(weights, map_location=device) # load FP32 model
File "/home/firefly/yolov5-rknn/models/experimental.py", line 118, in attempt_load
ckpt = torch.load(w, map_location=map_location) # load
File "/home/firefly/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/serialization.py", line 607, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/firefly/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/serialization.py", line 882, in _load
result = unpickler.load()
File "/home/firefly/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/serialization.py", line 875, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from '/home/firefly/rknn/models/common.py'>
| 报错分析 |
|---|
定位错误,发现是在models.common文件中,没有这个SPPF方法。网上的解决方法,都是从6.1版本中将SPPF方法复制过来,然后运行继续报错:
File "/home/firefly/yolov5-rknn/models/yolo.py", line 58, in forward
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
RuntimeError: The size of tensor a (52) must match the size of tensor b (56) at non-singleton dimension 3
后面的报错就没完没了的解决了,而且根本不适用,那些评论区底下有好多急着求解决方法的同学。
那么我就开始自己摸索了,首先考虑是不是模型问题,model中是加载了weights的,是不是weights的版本和yolov5版本不匹配呢。然后我就请舍友帮我从github上下载了yolov5 3.0的权重文件,替换,果然成功解决问题。
| 报错解决 |
|---|
从yolov5仓库下载你的代码版本对应的yolov5s.pt文件,否则会因为权重文件版本和源代码版本不匹配导致错误。比如我下载后,放到了models下,detect.py最后的weights路径也修改一下:
parser.add_argument('--weights', nargs='+', type=str, default='./models/yolov5s.pt', help='model.pt path(s)')
python detect.py重新运行:

边栏推荐
- [Yu Yue education] Dunhuang Literature and art reference materials of Zhejiang Normal University
- Apache DolphinScheduler源码分析(超详细)
- [ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)
- 如何做好金融文献翻译?
- A 27-year-old without a diploma, wants to work hard on self-study programming, and has the opportunity to become a programmer?
- Remember the implementation of a relatively complex addition, deletion and modification function based on jeecg-boot
- 金融德语翻译,北京专业的翻译公司
- Cobalt strike feature modification
- MySQL high frequency interview 20 questions, necessary (important)
- Luogu p2141 abacus mental arithmetic test
猜你喜欢

Traffic encryption of red blue confrontation (OpenSSL encrypted transmission, MSF traffic encryption, CS modifying profile for traffic encryption)

org. activiti. bpmn. exceptions. XMLException: cvc-complex-type. 2.4. a: Invalid content beginning with element 'outgoing' was found
![[ 英语 ] 语法重塑 之 动词分类 —— 英语兔学习笔记(2)](/img/3c/c25e7cbef9be1860842e8981f72352.png)
[ 英语 ] 语法重塑 之 动词分类 —— 英语兔学习笔记(2)

英语论文翻译成中文字数变化

LeetCode - 152 乘积最大子数组

How much is it to translate Chinese into English for one minute?

Leetcode - 152 product maximum subarray

Lecture 8: 1602 LCD (Guo Tianxiang)

How much is the price for the seal of the certificate

Cobalt Strike特征修改
随机推荐
Erreur de type résolue avec succès: type de données « catégorie» non sous - jacente
Automated test environment configuration
Machine learning plant leaf recognition
Transfert des paramètres de la barre d'adresse de la page de liste basée sur jeecg - boot
Oscp raven2 target penetration process
Cannot create poolableconnectionfactory (could not create connection to database server. error
机器人类专业不同层次院校课程差异性简述-ROS1/ROS2-
万丈高楼平地起,每个API皆根基
翻译生物医学说明书,英译中怎样效果佳
SSO流程分析
Monotonic stack
Changes in the number of words in English papers translated into Chinese
Address bar parameter transmission of list page based on jeecg-boot
如何做好互联网金融的英语翻译
【刷题】怎么样才能正确的迎接面试?
Cobalt strike feature modification
How to do a good job in financial literature translation?
Py06 字典 映射 字典嵌套 键不存在测试 键排序
[Tera term] black cat takes you to learn TTL script -- serial port automation skill in embedded development
英语论文翻译成中文字数变化