Skip to content

Commit 8759f30

Browse files
Ashok93soumith
authored andcommitted
Added test for save image in utils (#847)
1 parent 6c77fdf commit 8759f30

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/test_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import torch
23
import torchvision.utils as utils
34
import unittest
@@ -35,6 +36,13 @@ def test_normalize_in_make_grid(self):
3536
assert torch.equal(norm_max, rounded_grid_max), 'Normalized max is not equal to 1'
3637
assert torch.equal(norm_min, rounded_grid_min), 'Normalized min is not equal to 0'
3738

39+
def test_save_image(self):
40+
t = torch.rand(2, 3, 64, 64)
41+
file_name = 'test_image.png'
42+
utils.save_image(t, file_name)
43+
assert os.path.exists(file_name), 'The image is not present after save'
44+
os.remove(file_name)
45+
3846

3947
if __name__ == '__main__':
4048
unittest.main()

0 commit comments

Comments
 (0)