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
1e20b9d4
Unverified
Commit
1e20b9d4
authored
Mar 01, 2021
by
Philip Meier
Committed by
GitHub
Mar 01, 2021
Browse files
add tests for Omniglot dataset (#3461)
Co-authored-by:
Vasilis Vryniotis
<
datumbox@users.noreply.github.com
>
parent
e9a9493b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
test/test_datasets.py
test/test_datasets.py
+30
-0
No files found.
test/test_datasets.py
View file @
1e20b9d4
...
...
@@ -1092,5 +1092,35 @@ class HMDB51TestCase(datasets_utils.VideoDatasetTestCase):
return
num_train_videos
if
train
else
(
num_videos
-
num_train_videos
)
class
OmniglotTestCase
(
datasets_utils
.
ImageDatasetTestCase
):
DATASET_CLASS
=
datasets
.
Omniglot
CONFIGS
=
datasets_utils
.
combinations_grid
(
background
=
(
True
,
False
))
def
inject_fake_data
(
self
,
tmpdir
,
config
):
target_folder
=
(
pathlib
.
Path
(
tmpdir
)
/
"omniglot-py"
/
f
"images_
{
'background'
if
config
[
'background'
]
else
'evaluation'
}
"
)
os
.
makedirs
(
target_folder
)
num_images
=
0
for
name
in
(
"Alphabet_of_the_Magi"
,
"Tifinagh"
):
num_images
+=
self
.
_create_alphabet_folder
(
target_folder
,
name
)
return
num_images
def
_create_alphabet_folder
(
self
,
root
,
name
):
num_images_total
=
0
for
idx
in
range
(
torch
.
randint
(
1
,
4
,
size
=
()).
item
()):
num_images
=
torch
.
randint
(
1
,
4
,
size
=
()).
item
()
num_images_total
+=
num_images
datasets_utils
.
create_image_folder
(
root
/
name
,
f
"character
{
idx
:
02
d
}
"
,
lambda
image_idx
:
f
"
{
image_idx
:
02
d
}
.png"
,
num_images
)
return
num_images_total
if
__name__
==
"__main__"
:
unittest
.
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