Skip to content

Commit

Permalink
RESISC45 attacks in png format (twosixlabs#568)
Browse files Browse the repository at this point in the history
* fix accuracy calculation

* add image densenet/resisc scenario

* fix accuracy calculation for example resisc scenario -- affects output to Evaluation Results written <output_dir>/evaluation-results.json

* run black on accuracy fix

* add densenet scenario

* correct scenario file in json, and update total_iterations to batches_per_epoch

* image FGM attack scenario with densenet model and resisc45 dataset

* black resisc45_scenario

* For DenseNet image scenario, if not loading pretrained weights, use Imagenet pre-trained weights

* add dataset generator file in armory/data

* add rest of files without checksum complete

* Adversarial patch attack for image classification

* add univ patch and univ pert for img resisc scenario in phase 1

* resisc universal patch and universal perturbation attacks

* resisc universal patch and universal perturbation attacks

* uploaded file to s3

* moved to adversarial datasets

* remerge master

* remerge master

* adversarial resisc config

* v2 (png) of the resisc adversarial dataset

* change version number to 1.0.1, remove _v2 from dataset name

* updated to use s3

* updated s3 cache

Co-authored-by: David Slater <david.slater@twosixlabs.com>
  • Loading branch information
grobertson-ext and davidslater committed May 27, 2020
1 parent d03a537 commit 7f6f2ae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
_URL = ""
_DL_URL = (
"https://armory-public-data.s3.us-east-2.amazonaws.com/adversarial-datasets/"
"resisc45_densenet121_univpatch_and_univperturbation_adversarial_224x224.tar.gz"
"resisc45_densenet121_univpatch_and_univperturbation_adversarial_224x224_1.0.1.tar.gz"
)
_LABELS = [
"airplane",
Expand Down Expand Up @@ -88,7 +88,7 @@ class Resisc45Densenet121UnivpatchAndUnivperturbationAdversarial224x224(
tfds.core.GeneratorBasedBuilder
):

VERSION = tfds.core.Version("1.0.0")
VERSION = tfds.core.Version("1.0.1")

def _info(self):
return tfds.core.DatasetInfo(
Expand All @@ -98,13 +98,13 @@ def _info(self):
{
"images": {
"clean": tfds.features.Image(
shape=[224, 224, 3], dtype=tf.uint8, encoding_format="jpeg"
shape=[224, 224, 3], dtype=tf.uint8, encoding_format="png"
),
"adversarial_univperturbation": tfds.features.Image(
shape=[224, 224, 3], dtype=tf.uint8, encoding_format="jpeg"
shape=[224, 224, 3], dtype=tf.uint8, encoding_format="png"
),
"adversarial_univpatch": tfds.features.Image(
shape=[224, 224, 3], dtype=tf.uint8, encoding_format="jpeg"
shape=[224, 224, 3], dtype=tf.uint8, encoding_format="png"
),
},
"label": tfds.features.ClassLabel(names=_LABELS),
Expand Down Expand Up @@ -136,15 +136,15 @@ def _generate_examples(self, data_dir_path):
labels.sort()
for label in labels:
image_clean = tf.io.gfile.glob(
os.path.join(data_dir_path, root_dir, split_dirs[0], label, "*.jpg",)
os.path.join(data_dir_path, root_dir, split_dirs[0], label, "*.png",)
)
image_clean.sort()
adv_univpatch = tf.io.gfile.glob(
os.path.join(data_dir_path, root_dir, split_dirs[1], label, "*.jpg",)
os.path.join(data_dir_path, root_dir, split_dirs[1], label, "*.png",)
)
adv_univpatch.sort()
adv_univperturbation = tf.io.gfile.glob(
os.path.join(data_dir_path, root_dir, split_dirs[2], label, "*.jpg",)
os.path.join(data_dir_path, root_dir, split_dirs[2], label, "*.png",)
)
adv_univperturbation.sort()

Expand Down
4 changes: 2 additions & 2 deletions armory/data/adversarial_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Callable

from armory.data import datasets
from armory.data.adversarial import imagenet_adversarial as IA # noqa: F401
from armory.data.adversarial import ( # noqa: F401
imagenet_adversarial as IA,
librispeech_adversarial as LA,
resisc45_densenet121_univpatch_and_univperturbation_adversarial_224x224,
ucf101_mars_perturbation_and_patch_adversarial_112x112,
Expand Down Expand Up @@ -116,7 +116,7 @@ def resisc45_adversarial_224x224(
raise ValueError(f"{adversarial_key} not in {adversarial_keys}")

return datasets._generator_from_tfds(
"resisc45_densenet121_univpatch_and_univperturbation_adversarial224x224:1.0.0",
"resisc45_densenet121_univpatch_and_univperturbation_adversarial224x224:1.0.1",
split_type=split_type,
batch_size=batch_size,
epochs=epochs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
armory-public-data adversarial-datasets/cached/resisc45_densenet121_univpatch_and_univperturbation_adversarial224x224_cached.tar.gz 8770675 4dd6a6c69d6ce4f72db2ab9d8f4c3acf605e5f7a6ffe371617645112d9495737
armory-public-data adversarial-datasets/cached/resisc45_densenet121_univpatch_and_univperturbation_adversarial224x224_1.0.1_cached.tar.gz 67049866 283b2619cfcab353285d50caa5f4f1c8efb4b865d5efc66ca35b72fdcb6ec66a
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://armory-public-data.s3.us-east-2.amazonaws.com/adversarial-datasets/resisc45_densenet121_univpatch_and_univperturbation_adversarial_224x224.tar.gz 9007288 e935888bd8d77fac44e02ad510e0b1368642387c88a7e90e74e58f6a89a74429
https://armory-public-data.s3.us-east-2.amazonaws.com/adversarial-datasets/resisc45_densenet121_univpatch_and_univperturbation_adversarial_224x224_1.0.1.tar.gz 67076158 779a2aed3a5d10f4d62808e7e049e440b0d5691e438e29f7b47084d952a565e8

0 comments on commit 7f6f2ae

Please sign in to comment.