当前位置:网站首页>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:46: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
重新運行:
边栏推荐
- 红蓝对抗之流量加密(Openssl加密传输、MSF流量加密、CS修改profile进行流量加密)
- How to translate biomedical instructions in English
- [ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)
- [Yu Yue education] flower cultivation reference materials of Weifang Vocational College
- Lecture 8: 1602 LCD (Guo Tianxiang)
- 商标翻译有什么特点,如何翻译?
- 基於JEECG-BOOT的list頁面的地址欄參數傳遞
- SSO process analysis
- 我的创作纪念日
- The registration password of day 239/300 is 8~14 alphanumeric and punctuation, and at least 2 checks are included
猜你喜欢
Tms320c665x + Xilinx artix7 DSP + FPGA high speed core board
Changes in the number of words in English papers translated into Chinese
Use shortcut LNK online CS
26岁从财务转行软件测试,4年沉淀我已经是25k的测开工程师...
CS通过(CDN+证书)powershell上线详细版
MySQL5.72.msi安装失败
[brush questions] how can we correctly meet the interview?
[English] Verb Classification of grammatical reconstruction -- English rabbit learning notes (2)
Reflex WMS medium level series 3: display shipped replaceable groups
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
随机推荐
Chapter 7 - thread pool of shared model
Leetcode daily question (971. flip binary tree to match preorder traversal)
SSO process analysis
ECS accessKey key disclosure and utilization
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
LeetCode - 152 乘积最大子数组
How effective is the Chinese-English translation of international economic and trade contracts
机器学习植物叶片识别
利用快捷方式-LNK-上线CS
Facebook AI & Oxford proposed a video transformer with "track attention" to perform SOTA in video action recognition tasks
How much is the price for the seal of the certificate
Luogu p2089 roast chicken
CS-证书指纹修改
Py06 字典 映射 字典嵌套 键不存在测试 键排序
[English] Verb Classification of grammatical reconstruction -- English rabbit learning notes (2)
云服务器 AccessKey 密钥泄露利用
Chinese English comparison: you can do this Best of luck
Biomedical English contract translation, characteristics of Vocabulary Translation
Day 248/300 thoughts on how graduates find jobs
钓鱼&文件名反转&office远程模板