Transformers-Tutorials
Transformers-Tutorials copied to clipboard
Update bbox coordinates to tensor without gradients
I got this error: RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead. So, I apply x.detach() to coordinates of bounding boxes.
I added one line in the loop for the attention visualization:
xmin, ymin, xmax, ymax = map(lambda x: x.detach(), (xmin, ymin, xmax, ymax))
Tensor.detach() is used to detach a tensor from the current computational graph. It returns a new tensor that doesn't require a gradient.
Check out this pull request on ![]()
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB