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

边栏推荐
- Cobalt Strike特征修改
- Apache dolphin scheduler source code analysis (super detailed)
- [Yu Yue education] Dunhuang Literature and art reference materials of Zhejiang Normal University
- SQL Server manager studio(SSMS)安装教程
- Tms320c665x + Xilinx artix7 DSP + FPGA high speed core board
- 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
- My daily learning records / learning methods
- (practice C language every day) reverse linked list II
- Reflex WMS medium level series 3: display shipped replaceable groups
- Engineering organisms containing artificial metalloenzymes perform unnatural biosynthesis
猜你喜欢

机器学习植物叶片识别

基于购买行为数据对超市顾客进行市场细分(RFM模型)

AI on the cloud makes earth science research easier

Today's summer solstice

生物医学本地化翻译服务

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

Chinese English comparison: you can do this Best of luck

SQL Server Manager studio (SSMS) installation tutorial

端午节快乐Wish Dragon Boat Festival is happy

Brief introduction to the curriculum differences of colleges and universities at different levels of machine human major -ros1/ros2-
随机推荐
详解SQL中Groupings Sets 语句的功能和底层实现逻辑
[ 英语 ] 语法重塑 之 动词分类 —— 英语兔学习笔记(2)
Brief introduction to the curriculum differences of colleges and universities at different levels of machine human major -ros1/ros2-
Day 246/300 SSH connection prompt "remote host identification has changed!"
AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm
Changes in the number of words in English papers translated into Chinese
如何做好互联网金融的英语翻译
女生学软件测试难不难 入门门槛低,学起来还是比较简单的
字幕翻译中翻英一分钟多少钱?
P5706 [deep foundation 2. Example 8] redistributing fat house water -- February 13, 2022
Data security -- 13 -- data security lifecycle management
Today's summer solstice
雲上有AI,讓地球科學研究更省力
UniPro甘特图“初体验”:关注细节背后的多场景探索
Automated test environment configuration
Attributeerror successfully resolved: can only use cat accessor with a ‘category‘ dtype
How to convert flv file to MP4 file? A simple solution
Biomedical localization translation services
成功解决TypeError: data type ‘category‘ not understood
翻译影视剧字幕,这些特点务必要了解