Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
174e135d
Unverified
Commit
174e135d
authored
Jun 20, 2019
by
Francisco Massa
Committed by
GitHub
Jun 20, 2019
Browse files
Make test_save_image more robust (#1037)
parent
3b8a1403
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
test/test_utils.py
test/test_utils.py
+5
-5
No files found.
test/test_utils.py
View file @
174e135d
import
os
import
os
import
tempfile
import
torch
import
torch
import
torchvision.utils
as
utils
import
torchvision.utils
as
utils
import
unittest
import
unittest
...
@@ -37,11 +38,10 @@ class Tester(unittest.TestCase):
...
@@ -37,11 +38,10 @@ class Tester(unittest.TestCase):
assert
torch
.
equal
(
norm_min
,
rounded_grid_min
),
'Normalized min is not equal to 0'
assert
torch
.
equal
(
norm_min
,
rounded_grid_min
),
'Normalized min is not equal to 0'
def
test_save_image
(
self
):
def
test_save_image
(
self
):
t
=
torch
.
rand
(
2
,
3
,
64
,
64
)
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'.png'
)
as
f
:
file_name
=
'test_image.png'
t
=
torch
.
rand
(
2
,
3
,
64
,
64
)
utils
.
save_image
(
t
,
file_name
)
utils
.
save_image
(
t
,
f
.
name
)
assert
os
.
path
.
exists
(
file_name
),
'The image is not present after save'
assert
os
.
path
.
exists
(
f
.
name
),
'The image is not present after save'
os
.
remove
(
file_name
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment