当前位置:网站首页>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
重新運行:
边栏推荐
- 金融德语翻译,北京专业的翻译公司
- 翻译公司证件盖章的价格是多少
- What are the commonly used English words and sentences about COVID-19?
- Day 246/300 SSH connection prompt "remote host identification has changed!"
- 查询字段个数
- SQL Server manager studio(SSMS)安装教程
- 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
- Fedora/REHL 安装 semanage
- MySQL high frequency interview 20 questions, necessary (important)
- How effective is the Chinese-English translation of international economic and trade contracts
猜你喜欢
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
Apache DolphinScheduler源码分析(超详细)
[ 英语 ] 语法重塑 之 动词分类 —— 英语兔学习笔记(2)
云上有AI,让地球科学研究更省力
Address bar parameter transmission of list page based on jeecg-boot
[English] Grammar remodeling: the core framework of English Learning -- English rabbit learning notes (1)
翻译影视剧字幕,这些特点务必要了解
Use shortcut LNK online CS
How effective is the Chinese-English translation of international economic and trade contracts
CS certificate fingerprint modification
随机推荐
Reflex WMS medium level series 3: display shipped replaceable groups
SSO流程分析
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
Lecture 8: 1602 LCD (Guo Tianxiang)
(practice C language every day) reverse linked list II
机器人类专业不同层次院校课程差异性简述-ROS1/ROS2-
How to translate biomedical instructions in English
Fedora/REHL 安装 semanage
Py06 字典 映射 字典嵌套 键不存在测试 键排序
Phishing & filename inversion & Office remote template
成功解决TypeError: data type ‘category‘ not understood
Biomedical English contract translation, characteristics of Vocabulary Translation
CS certificate fingerprint modification
自动化测试环境配置
LeetCode每日一题(971. Flip Binary Tree To Match Preorder Traversal)
Day 246/300 ssh连接提示“REMOTE HOST IDENTIFICATION HAS CHANGED! ”
Cobalt Strike特征修改
云服务器 AccessKey 密钥泄露利用
[English] Grammar remodeling: the core framework of English Learning -- English rabbit learning notes (1)
我的创作纪念日