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

边栏推荐
- It is necessary to understand these characteristics in translating subtitles of film and television dramas
- P5706 [deep foundation 2. Example 8] redistributing fat house water -- February 13, 2022
- Biomedical English contract translation, characteristics of Vocabulary Translation
- Changes in the number of words in English papers translated into Chinese
- Reflex WMS中阶系列3:显示已发货可换组
- Leetcode daily question (1870. minimum speed to arrive on time)
- MySQL5.72.msi安装失败
- Facebook AI & Oxford proposed a video transformer with "track attention" to perform SOTA in video action recognition tasks
- 删除外部表源数据
- Fedora/rehl installation semanage
猜你喜欢

How to convert flv file to MP4 file? A simple solution

Office-DOC加载宏-上线CS

mysql的基础命令

University of Manchester | dda3c: collaborative distributed deep reinforcement learning in swarm agent systems

Suspended else

Introduction and underlying analysis of regular expressions

Modify the list page on the basis of jeecg boot code generation (combined with customized components)

翻译公司证件盖章的价格是多少

Engineering organisms containing artificial metalloenzymes perform unnatural biosynthesis

How to do a good job in financial literature translation?
随机推荐
CS passed (cdn+ certificate) PowerShell online detailed version
Suspended else
LeetCode每日一题(1997. First Day Where You Have Been in All the Rooms)
Today's summer solstice
The internationalization of domestic games is inseparable from professional translation companies
[web security] nodejs prototype chain pollution analysis
SSO流程分析
Summary of leetcode's dynamic programming 4
The registration password of day 239/300 is 8~14 alphanumeric and punctuation, and at least 2 checks are included
利用快捷方式-LNK-上线CS
云上有AI,让地球科学研究更省力
Making interactive page of "left tree and right table" based on jeecg-boot
Lecture 8: 1602 LCD (Guo Tianxiang)
Py06 字典 映射 字典嵌套 键不存在测试 键排序
Data security -- 13 -- data security lifecycle management
云服务器 AccessKey 密钥泄露利用
Successfully solved typeerror: data type 'category' not understood
Monotonic stack
Facebook AI & Oxford proposed a video transformer with "track attention" to perform SOTA in video action recognition tasks
L'Ia dans les nuages rend la recherche géoscientifique plus facile