当前位置:网站首页>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重新運行:

边栏推荐
- Making interactive page of "left tree and right table" based on jeecg-boot
- mysql的基础命令
- CS-证书指纹修改
- Distributed system basic (V) protocol (I)
- Phishing & filename inversion & Office remote template
- Difference between backtracking and recursion
- 万丈高楼平地起,每个API皆根基
- Market segmentation of supermarket customers based on purchase behavior data (RFM model)
- On the first day of clock in, click to open a surprise, and the switch statement is explained in detail
- Delete external table source data
猜你喜欢

E-book CHM online CS

详解SQL中Groupings Sets 语句的功能和底层实现逻辑

How effective is the Chinese-English translation of international economic and trade contracts

(practice C language every day) reverse linked list II

In English translation of papers, how to do a good translation?
![[web security] nodejs prototype chain pollution analysis](/img/b6/8eddc9cbe343f2439da92bf342b0dc.jpg)
[web security] nodejs prototype chain pollution analysis
![[unity] how to export FBX in untiy](/img/03/b7937a1ac1a677f52616186fb85ab3.jpg)
[unity] how to export FBX in untiy

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

金融德语翻译,北京专业的翻译公司

How much is the price for the seal of the certificate
随机推荐
Do you really know the use of idea?
CS certificate fingerprint modification
SQL Server Manager studio (SSMS) installation tutorial
Erreur de type résolue avec succès: type de données « catégorie» non sous - jacente
CS通过(CDN+证书)powershell上线详细版
我的创作纪念日
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
国产游戏国际化离不开专业的翻译公司
CS passed (cdn+ certificate) PowerShell online detailed version
[Yu Yue education] flower cultivation reference materials of Weifang Vocational College
SQL Server manager studio(SSMS)安装教程
云服务器 AccessKey 密钥泄露利用
生物医学英文合同翻译,关于词汇翻译的特点
What are the characteristics of trademark translation and how to translate it?
The registration password of day 239/300 is 8~14 alphanumeric and punctuation, and at least 2 checks are included
My creation anniversary
【软件测试进阶第1步】自动化测试基础知识
Luogu p2141 abacus mental arithmetic test
Leetcode daily question (971. flip binary tree to match preorder traversal)
Day 245/300 JS foreach data cannot be updated to the object after multi-layer nesting