Sharpiless / Yolov5-Flask-VUE

基于Flask+VUE前后端,在阿里云公网WEB端部署YOLOv5目标检测模型
MIT License
183 stars 24 forks source link

自定义数据集得到的权重运行报错AttributeError #7

Open yukishirataco opened 3 years ago

yukishirataco commented 3 years ago
发生异常: AttributeError
Can't get attribute 'C3' on <module 'models.common' from 'h:\\Yolov5-Flask-VUE\\back-end\\models\\common.py'>
  File "H:\Yolov5-Flask-VUE\back-end\models\experimental.py", line 137, in attempt_load
    model.append(torch.load(w, map_location=map_location)['model'].float().fuse().eval())  # load FP32 model
  File "H:\Yolov5-Flask-VUE\back-end\processor\AIDetector_pytorch.py", line 23, in init_model
    model = attempt_load(self.weights, map_location=self.device)
  File "H:\Yolov5-Flask-VUE\back-end\processor\AIDetector_pytorch.py", line 16, in __init__
    self.init_model()
  File "H:\Yolov5-Flask-VUE\back-end\app.py", line 89, in <module>
    current_app.model = Detector()

使用YOLOv5 5.0训练得到的权重弹出在Visual Studio Code中报错

Curiousity9 commented 3 years ago

请问解决了吗

yukishirataco commented 3 years ago

请问解决了吗

没有,我用的最新版的YOLOv5 5.0不行,前两天回去试了一下用YOLOv5 2.0和3.0,结果也是不行

Curiousity9 commented 3 years ago

裂开,我还以为就是我自己的问题,糟糕了o(╥﹏╥)o

yukishirataco commented 3 years ago

现在就是不知道项目的author用的是哪一个commit的YOLOv5,找到了的话还要重新训练

Curiousity9 commented 3 years ago

兄弟我找到了一个能跑起来的权重

yukishirataco commented 3 years ago

兄弟我找到了一个能跑起来的权重

能知道训练权重用的是什么版本的YOLOv5吗?

yukishirataco commented 3 years ago

有 1124393459 加我qq吧

我加不了啊,QQ出问题了

Curiousity9 commented 3 years ago

阿这 这样博客是聊天页太怪了 https://haoji007.blog.csdn.net/article/details/112504931?ops_request_misc=&request_id=&biz_id=102&utm_term=yolov5m%205s%E7%9A%84%E8%AE%AD%E7%BB%83%E9%9B%86%E5%8F%AF%E4%BB%A5%E6%8D%A2%E7%9D%80%E7%94%A8%E5%90%97&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-9-112504931.pc_search_result_hbase_insert 反正这个下的 m.pt训练集我这能用了

Curiousity9 commented 3 years ago

他给的pt文件是这个 你试试
链接:https://pan.baidu.com/s/1EMEScMeguMgJ5YExYFth5Q 提取码:439b 复制这段内容后打开百度网盘手机App,操作更方便哦

yukishirataco commented 3 years ago

他给的pt文件是这个 你试试 链接:https://pan.baidu.com/s/1EMEScMeguMgJ5YExYFth5Q 提取码:439b 复制这段内容后打开百度网盘手机App,操作更方便哦

Traceback (most recent call last):
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\admin\.conda\envs\yolov5\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "H:\vue\back-end\app.py", line 54, in upload_file
image_path, current_app.model, file.filename.rsplit('.', 1)[1])
File "H:\vue\back-end\core\main.py", line 6, in c_main
image_info = predict.predict(image_data, model, ext)
File "H:\vue\back-end\core\predict.py", line 10, in predict
img_y, image_info = model.detect(x)
File "H:\vue\back-end\processor\AIDetector_pytorch.py", line 65, in detect
pred = self.m(img, augment=False)[0]
File "C:\Users\npfjcg\.conda\envs\yolov5\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "H:\vue\back-end\models\yolo.py", line 123, in forward
return self.forward_once(x, profile)  # single-scale inference, train
File "H:\vue\back-end\models\yolo.py", line 139, in forward_once
x = m(x)  # run
File "C:\Users\npfjcg\.conda\envs\yolov5\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "H:\vue\back-end\models\common.py", line 169, in forward
return self.conv(torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1))
RuntimeError: Sizes of tensors must match except in dimension 3. Got 1 and 2 (The offending index is 0)

不行,使用这个模型会报这个错误

Curiousity9 commented 3 years ago

你发个qq我加你 加了再删除了

Curiousity9 commented 3 years ago

我跑的是他训练好的检测安全帽的 ……m.pt 能启动

yukishirataco commented 3 years ago

你发个qq我加你 加了再删除了

yukino@yukishirataco.moe

yukishirataco commented 3 years ago

我跑的是他训练好的检测安全帽的 ……m.pt 能启动

看来是一定要v5m的了,我这边用的是v5l

Curiousity9 commented 3 years ago

![Uploading image.png…]()

XhHello commented 2 years ago
发生异常: AttributeError
Can't get attribute 'C3' on <module 'models.common' from 'h:\\Yolov5-Flask-VUE\\back-end\\models\\common.py'>
  File "H:\Yolov5-Flask-VUE\back-end\models\experimental.py", line 137, in attempt_load
    model.append(torch.load(w, map_location=map_location)['model'].float().fuse().eval())  # load FP32 model
  File "H:\Yolov5-Flask-VUE\back-end\processor\AIDetector_pytorch.py", line 23, in init_model
    model = attempt_load(self.weights, map_location=self.device)
  File "H:\Yolov5-Flask-VUE\back-end\processor\AIDetector_pytorch.py", line 16, in __init__
    self.init_model()
  File "H:\Yolov5-Flask-VUE\back-end\app.py", line 89, in <module>
    current_app.model = Detector()

使用YOLOv5 5.0训练得到的权重弹出在Visual Studio Code中报错

你好,我也遇到这个问题,请问你解决了吗,我的qq:1757030891,麻烦您加个好友,我想请教一下

XhHello commented 2 years ago

我跑的是他训练好的检测安全帽的 ……m.pt 能启动

你好,我也遇到这个问题,请问你解决了吗,我的qq:1757030891,麻烦您加个好友,我想请教一下

412869434 commented 2 years ago

我跑的是他训练好的检测安全帽的 ……m.pt 能启动

你好,我也遇到这个问题,请问你解决了吗,我的qq:1757030891,麻烦您加个好友,我想请教一下

你好,我想问下你解决了这个问题吗