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

varagrawal picture varagrawal  路  3Comments

Linardos picture Linardos  路  4Comments

bodokaiser picture bodokaiser  路  3Comments

datumbox picture datumbox  路  3Comments

feiyangsuo picture feiyangsuo  路  3Comments