Vision: torch.utills.save_image modifying the original tensor

Created on 6 Aug 2019  路  2Comments  路  Source: pytorch/vision

I think it makes sense to just save the tensor as image without modifying it. But looks like it modifies it.

enhancement help wanted utils

Most helpful comment

Thanks for opening the issue!

This seems like a corner case in make_grid which doesn't return a copy, but a view.
I think a solution would be to make a clone in https://github.com/pytorch/vision/blob/6c7189fcada6f95ab615e08838b1d7fdb148c268/torchvision/utils.py#L69-L70
or, more simply, replace the first mul_ in
https://github.com/pytorch/vision/blob/6c7189fcada6f95ab615e08838b1d7fdb148c268/torchvision/utils.py#L103
with mul.

All 2 comments

Thanks for opening the issue!

This seems like a corner case in make_grid which doesn't return a copy, but a view.
I think a solution would be to make a clone in https://github.com/pytorch/vision/blob/6c7189fcada6f95ab615e08838b1d7fdb148c268/torchvision/utils.py#L69-L70
or, more simply, replace the first mul_ in
https://github.com/pytorch/vision/blob/6c7189fcada6f95ab615e08838b1d7fdb148c268/torchvision/utils.py#L103
with mul.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bodokaiser picture bodokaiser  路  3Comments

zhang-zhenyu picture zhang-zhenyu  路  3Comments

xuanqing94 picture xuanqing94  路  3Comments

IssamLaradji picture IssamLaradji  路  3Comments

carlocab picture carlocab  路  3Comments