ScaledYOLOv4 icon indicating copy to clipboard operation
ScaledYOLOv4 copied to clipboard

Error in generating prediction with torch and cuda version of 1.11.0+cu113 in google colab

Open Atul997 opened this issue 2 years ago • 1 comments

I am trying to inference with model on colab it throws following error -

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-7-07bcaca33852>](https://localhost:8080/#) in <module>()
 12         res_img = cv2.resize(image, (512, 512))
 13         pre_img = preprocess(res_img)
 ---> 14         prediction = model(pre_img)[0]
 15         result = postprocess(prediction, res_img, pre_img, height, width,
 16                         conf_thres, iou_thres)

 5 frames
 [/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in _call_impl(self, *input, **kwargs)
 1108         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
 1109                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1110             return forward_call(*input, **kwargs)
 1111         # Do not call functions when jit is used
 1112         full_backward_hooks, non_full_backward_hooks = [], []

[/content/drive/MyDrive/tablecell_detection/ScaledYOLOv4/models/yolo.py](https://localhost:8080/#) in forward(self, x, augment, 
profile)
107             return torch.cat(y, 1), None  # augmented inference, train
108         else:
 --> 109             return self.forward_once(x, profile)  # single-scale inference, train
110 
111     def forward_once(self, x, profile=False):

[/content/drive/MyDrive/tablecell_detection/ScaledYOLOv4/models/yolo.py](https://localhost:8080/#) in forward_once(self, x, profile)
127                 print('%10.1f%10.0f%10.1fms %-40s' % (o, m.np, dt[-1], m.type))
128 
--> 129             x = m(x)  # run
130             y.append(x if m.i in self.save else None)  # save output
131 

[/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in _call_impl(self, *input, **kwargs)
1108         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1109                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1110             return forward_call(*input, **kwargs)
1111         # Do not call functions when jit is used
1112         full_backward_hooks, non_full_backward_hooks = [], []

[/usr/local/lib/python3.7/dist-packages/torch/nn/modules/upsampling.py](https://localhost:8080/#) in forward(self, input)
152     def forward(self, input: Tensor) -> Tensor:
153         return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
 --> 154                              recompute_scale_factor=self.recompute_scale_factor)
155 
156     def extra_repr(self) -> str:

[/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in __getattr__(self, name)
1184                 return modules[name]
1185         raise AttributeError("'{}' object has no attribute '{}'".format(
-> 1186             type(self).__name__, name))
1187 
1188     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'

Colab version pytorch and cuda - 1.11.0+cu113

Atul997 avatar May 02 '22 06:05 Atul997

Hi, same issue here. @Atul997 any solution so far?

kXborg avatar May 16 '22 18:05 kXborg