Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add indexing to datasets #1003

Merged
merged 5 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions armory/data/adversarial_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def imagenet_adversarial(
adversarial_key: str = "adversarial",
targeted: bool = False,
shuffle_files: bool = False,
**kwargs,
) -> datasets.ArmoryDataGenerator:
"""
ILSVRC12 adversarial image dataset for ResNet50
Expand Down Expand Up @@ -97,6 +98,7 @@ def imagenet_adversarial(
framework=framework,
lambda_map=lambda x, y: ((x[clean_key], x[adversarial_key]), y),
context=imagenet_adversarial_context,
**kwargs,
)


Expand All @@ -112,6 +114,7 @@ def librispeech_adversarial(
adversarial_key: str = "adversarial_perturbation",
targeted: bool = False,
shuffle_files: bool = False,
**kwargs,
) -> datasets.ArmoryDataGenerator:
"""
Adversarial dataset based on Librispeech-dev-clean including clean,
Expand Down Expand Up @@ -145,6 +148,7 @@ def librispeech_adversarial(
framework=framework,
lambda_map=lambda x, y: ((x[clean_key], x[adversarial_key]), y),
context=librispeech_adversarial_context,
**kwargs,
)


Expand All @@ -160,6 +164,7 @@ def resisc45_adversarial_224x224(
adversarial_key: str = "adversarial_univperturbation",
targeted: bool = False,
shuffle_files: bool = False,
**kwargs,
) -> datasets.ArmoryDataGenerator:
"""
resisc45 Adversarial Dataset of size (224, 224, 3),
Expand Down Expand Up @@ -201,6 +206,7 @@ def lambda_map(x, y):
framework=framework,
lambda_map=lambda_map,
context=resisc45_adversarial_context,
**kwargs,
)


Expand All @@ -216,6 +222,7 @@ def ucf101_adversarial_112x112(
adversarial_key: str = "adversarial_perturbation",
targeted: bool = False,
shuffle_files: bool = False,
**kwargs,
) -> datasets.ArmoryDataGenerator:
"""
UCF 101 Adversarial Dataset of size (112, 112, 3),
Expand Down Expand Up @@ -259,6 +266,7 @@ def lambda_map(x, y):
framework=framework,
lambda_map=lambda_map,
context=ucf101_adversarial_context,
**kwargs,
)


Expand All @@ -273,6 +281,7 @@ def gtsrb_poison(
clean_key: str = None,
adversarial_key: str = None,
shuffle_files: bool = False,
**kwargs,
) -> datasets.ArmoryDataGenerator:
"""
German traffic sign poison dataset of size (48, 48, 3),
Expand All @@ -294,6 +303,7 @@ def gtsrb_poison(
cache_dataset=cache_dataset,
framework=framework,
lambda_map=lambda x, y: (x, y),
**kwargs,
)


Expand All @@ -317,6 +327,7 @@ def apricot_dev_adversarial(
cache_dataset: bool = True,
framework: str = "numpy",
shuffle_files: bool = False,
**kwargs,
) -> datasets.ArmoryDataGenerator:
if batch_size != 1:
raise NotImplementedError("Currently working only with batch size = 1")
Expand Down Expand Up @@ -360,6 +371,7 @@ def replace_magic_val(data, raw_val, transformed_val, sub_key):
),
),
context=apricot_adversarial_context,
**kwargs,
)


Expand All @@ -373,6 +385,7 @@ def apricot_test_adversarial(
cache_dataset: bool = True,
framework: str = "numpy",
shuffle_files: bool = False,
**kwargs,
) -> datasets.ArmoryDataGenerator:
if batch_size != 1:
raise NotImplementedError("Currently working only with batch size = 1")
Expand Down Expand Up @@ -416,4 +429,5 @@ def replace_magic_val(data, raw_val, transformed_val, sub_key):
),
),
context=apricot_adversarial_context,
**kwargs,
)
Loading