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
b5f29cc3
Unverified
Commit
b5f29cc3
authored
Mar 01, 2021
by
Philip Meier
Committed by
GitHub
Mar 01, 2021
Browse files
add tests for SBU dataset (#3464)
Co-authored-by:
Vasilis Vryniotis
<
datumbox@users.noreply.github.com
>
parent
1e20b9d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
test/test_datasets.py
test/test_datasets.py
+33
-0
No files found.
test/test_datasets.py
View file @
b5f29cc3
...
@@ -1122,5 +1122,38 @@ class OmniglotTestCase(datasets_utils.ImageDatasetTestCase):
...
@@ -1122,5 +1122,38 @@ class OmniglotTestCase(datasets_utils.ImageDatasetTestCase):
return
num_images_total
return
num_images_total
class
SBUTestCase
(
datasets_utils
.
ImageDatasetTestCase
):
DATASET_CLASS
=
datasets
.
SBU
FEATURE_TYPES
=
(
PIL
.
Image
.
Image
,
str
)
def
inject_fake_data
(
self
,
tmpdir
,
config
):
num_images
=
3
dataset_folder
=
pathlib
.
Path
(
tmpdir
)
/
"dataset"
images
=
datasets_utils
.
create_image_folder
(
tmpdir
,
"dataset"
,
self
.
_create_file_name
,
num_images
)
self
.
_create_urls_txt
(
dataset_folder
,
images
)
self
.
_create_captions_txt
(
dataset_folder
,
num_images
)
return
num_images
def
_create_file_name
(
self
,
idx
):
part1
=
datasets_utils
.
create_random_string
(
10
,
string
.
digits
)
part2
=
datasets_utils
.
create_random_string
(
10
,
string
.
ascii_lowercase
,
string
.
digits
[:
6
])
return
f
"
{
part1
}
_
{
part2
}
.jpg"
def
_create_urls_txt
(
self
,
root
,
images
):
with
open
(
root
/
"SBU_captioned_photo_dataset_urls.txt"
,
"w"
)
as
fh
:
for
image
in
images
:
fh
.
write
(
f
"http://static.flickr.com/
{
datasets_utils
.
create_random_string
(
4
,
string
.
digits
)
}
/
{
image
.
name
}
\n
"
)
def
_create_captions_txt
(
self
,
root
,
num_images
):
with
open
(
root
/
"SBU_captioned_photo_dataset_captions.txt"
,
"w"
)
as
fh
:
for
_
in
range
(
num_images
):
fh
.
write
(
f
"
{
datasets_utils
.
create_random_string
(
10
)
}
\n
"
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
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