TexasInstruments / edgeai-yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite. Forked from https://ultralytics.com/yolov5
https://github.com/TexasInstruments/edgeai
GNU General Public License v3.0
649 stars 120 forks source link

error: run python export.py #21

Closed dongxiaolong closed 2 years ago

dongxiaolong commented 2 years ago

Traceback (most recent call last): File "export.py", line 71, in <module> y = model(img) # dry runs File "/home/dong/.conda/envs/yolo-pose/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/dong/Code/yolo-pose/edgeai-yolov5-yolo-pose/models/yolo.py", line 157, in forward return self.forward_once(x, profile) # single-scale inference, train File "/home/dong/Code/yolo-pose/edgeai-yolov5-yolo-pose/models/yolo.py", line 188, in forward_once x = m(x) # run File "/home/dong/.conda/envs/yolo-pose/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/dong/.conda/envs/yolo-pose/lib/python3.8/site-packages/torch/nn/modules/upsampling.py", line 154, in forward recompute_scale_factor=self.recompute_scale_factor) File "/home/dong/.conda/envs/yolo-pose/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1185, in __getattr__ raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'

dongxiaolong commented 2 years ago

fix the bug by: https://github.com/ultralytics/yolov5/issues/6948#issuecomment-1075548218

kadimakipp commented 1 year ago

change models/experimental.py line 124

    for m in model.modules():
        if type(m) in [nn.Hardswish, nn.LeakyReLU, nn.ReLU, nn.ReLU6, nn.SiLU, Detect, Model]:
            m.inplace = inplace  # pytorch 1.7.0 compatibility
        elif type(m) is Conv:
            m._non_persistent_buffers_set = set()  # pytorch 1.6.0 compatibility
        elif type(m) is nn.Upsample and not hasattr(m, 'recompute_scale_factor'):
            m.recompute_scale_factor = None