• 尝试转换,报错,日志如下
AttributeError                            Traceback (most recent call last)
<ipython-input-24-0cf9bfd4fe52> in <module>20     img = torch.zeros((1, 3) + img_size).cuda().half()21 #     x = torch.rand(size=(1, 3,  opt.img_size, opt.img_size)).cuda().half()
---> 22     model_trt = torch2trt(model, [img], fp16_mode=True)23 24 /usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py in torch2trt(module, inputs, input_names, output_names, log_level, max_batch_size, fp16_mode, max_workspace_size, strict_type_constraints, keep_network, int8_mode, int8_calib_dataset, int8_calib_algorithm)375         ctx.add_inputs(inputs, input_names)376
--> 377         outputs = module(*inputs)378 379         if not isinstance(outputs, tuple) and not isinstance(outputs, list):~/.local/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)530             result = self._slow_forward(*input, **kwargs)531         else:
--> 532             result = self.forward(*input, **kwargs)533         for hook in self._forward_hooks.values():534             hook_result = hook(self, input, result)~/Desktop/HelmetWearingDetection20200303/models.py in forward(self, x, var)319 320         ptr = 0
--> 321         for i, (module_def, module) in enumerate(zip(self.module_defs, self.module_list)):322             if i == cutoff:323                 break~/.local/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)530             result = self._slow_forward(*input, **kwargs)531         else:
--> 532             result = self.forward(*input, **kwargs)533         for hook in self._forward_hooks.values():534             hook_result = hook(self, input, result)~/Desktop/HelmetWearingDetection20200303/models.py in forward(self, p, img_size, var)242             # s = 1.5  # scale_xy  (pxy = pxy * s - (s - 1) / 2)243             io = p.clone()  # inference output,测试过程输出就是io
--> 244             io[..., :2] = torch.sigmoid(io[..., :2]) + self.grid_xy  # xy245             # grid_xy是左上角再加上偏移量io[...:2]代表xy偏移246             io[..., 2:4] = torch.exp(io[..., 2:4]) * self.anchor_wh  # wh yolo method/usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py in wrapper(*args, **kwargs)200 201 #             print('%s' % (converter.__name__,))
--> 202             converter['converter'](ctx)203 204             # convert to None so conversion will fail for unsupported layers/usr/local/lib/python3.6/dist-packages/torch2trt/converters/getitem.py in convert_tensor_getitem(ctx)28     output = ctx.method_return29
---> 30     input_trt = input._trt31 32     # Step 1 - Replace ellipsis with expanded slicesAttributeError: 'Tensor' object has no attribute '_trt'

初步判定:

  • tensorRT不支持YOLO层,或者说是torch2trt没实现,那么YOLO层的实现就只能手动实现,也就是吧YOLO从网络结构中摘出来,自定义,不参与模型转换。

测试(占坑)



  • 看了下源码,还在整理中

结论(占坑)

  • 结论是torch2trt不支持YOLO层,我对比过两个项目的源码(一个实现torch2trt一个报错),他们在Darknet上读取的区别是:YOLO及相关层是否马上读取,实现了的项目是不读取的,因为torch2trt(或者说tensorrt)不支持YOLO层,因此需要自己另外定义,就是手动吧YOLO层需要的数据detach出来~

Jetson Nano【13】关于torch2trt报错:AttributeError: ‘Tensor‘ object has no attribute ‘_trt‘的一种可能性相关推荐

  1. Scrapy爬虫报错AttributeError: ‘NoneType‘ object has no attribute ‘write‘

    前言 一.报错 AttributeError: 'NoneType' object has no attribute 'write' 二.报错原因 1.piplines文件中的方法不能自定义的呢 开始 ...

  2. 关于在《python编程从入门到实践》书中练习“外星人大战”报错“AttributeError: ‘AlienInvasion‘ object has no attribute ‘blit‘”

    关于在<python编程从入门到实践>书中练习"外星人大战"报错"AttributeError: 'AlienInvasion' object has no ...

  3. 爬虫的自创建请求对象:报错AttributeError: 'str' object has no attribute 'items'

    在使用爬虫库创建自定义请求对象时 将值传入headers agent = random.choice(userAgent) REQ = request.Request(url,headers=agen ...

  4. 运行项目时flask_sqlalchemy报错AttributeError: ‘LocalStack‘ object has no attribute ‘__ident_func__‘

    运行项目时flask_sqlalchemy报错AttributeError: 'LocalStack' object has no attribute '__ident_func__' 1.原因 2. ...

  5. python3 多进程 multiprocessing 报错 AttributeError: ‘ForkAwareLocal‘ object has no attribute ‘connection‘

    目录 错误代码 报错信息 错误原因 解决方法 错误代码 python多进程管理manager时候,当不使用join对当前进程(主进程)进行阻塞时会报错,具体代码及错误如下: from multipro ...

  6. 报错AttributeError: ‘NoneType‘ object has no attribute ‘shape‘

    环境: python3.6.4 opencv3.4.1.15 运行目标跟踪object_tracking文件夹中的mean函数时报错且不显示视频结果 Traceback (most recent ca ...

  7. python的mysql数据查询及报错AttributeError: 'Connection' object has no attribute 'curson'

    import pymysql #创建连接 con = pymysql.connect(host='localhost',user='root',password='123456',port=3306, ...

  8. Python之报错AttributeError:'CocaCola' object has no attribute 'local_logo'

    试运行class类的代码如下,然而有报错信息:AttributeError:'CocaCola' object has no attribute 'local_logo' class CocaCola ...

  9. python 执行报错AttributeError: 'list' object has no attribute 'g'

    ^ SyntaxError: invalid syntax E:\数学-机器学习-西瓜书-周志华\UDACITY购课\project1 矩阵操作>python test.py Traceback ...

最新文章

  1. 同济大学计算机云南2019,同济大学录取分数线2019(在各省市录取数据)
  2. 老男孩教育每日一题-2017年4月28日- MySQL主从复制常见故障及解决方法?
  3. mysql 返回的查询结果为空 (即零行)._Mysql数据同步(单向)
  4. java: 在相应的 try 语句主体中不能抛出异常错误java.io.IOException
  5. jenkins+maven+ansible实现测试环境完全自动发布
  6. 开源自然语言处理工具包hanlp中CRF分词实现详解
  7. 小米4系统定位服务器地址,小米4原装浏览器怎么开启定位系统
  8. Colly实现豆瓣电影Top250爬取
  9. Arm架构下VUE环境的安装
  10. 软件设计师08-程序语言基础知识
  11. acm运行时错误_计人即讯|ACM纳新赛
  12. 使用猎码的浏览器组件开发安卓H5打包APK
  13. 西门子plc程序好坏判定
  14. 各种泵的图形符号_水泵cad画法
  15. E盾V60原版网络验证包含个人动手改IP地址源码软件加密一机一码
  16. HTML个人简历代码模板(静态页面)
  17. BUUCTF-[网鼎杯 2020 青龙组]虚幻2
  18. 动态数据采集业务逻辑
  19. SCRUM:敏捷团队的故事(SCRUM: The Story of an Agile Team)——(1)
  20. 旋转变换(一)旋转矩阵

热门文章

  1. 关于浏览器请求PHP一次请求执行了两次
  2. windows8 linux双系统,小白如何在Windows 8.1的笔记本上安装ubuntu双系统
  3. 企业微信应用实战踩坑之路
  4. 光明区关于促进科技创新的若干措施(征求意见稿)
  5. 网络7层协议详解——Network layer protocol
  6. 2018考研数学二答案真题解析.pdf
  7. 开关功率器件(MOSFET IGBT)损耗仿真方法
  8. Sequence Number
  9. MT6572,JB3,EMMC换nandflash问题!
  10. MATLAB fsparse()函数使用教程