Skip to content

Commit

Permalink
Merging 13.2 to dev (#1109)
Browse files Browse the repository at this point in the history
* update version

* revert version

* 0.13.1 release (#1068)

* update version (#1034)

* update version

* update json version

* set channels_first False for relevant pytorch models (#1037)

* Resisc10 poison dataset (#1038)

* update version

* revert version

* added resisc10 poison dataset

* Update refs to point to S3, add cached dataset

* Add test for resisc10 dataset

Co-authored-by: David Slater <david.slater@twosixlabs.com>
Co-authored-by: Neal Gupta <neal.gupta@twosixlabs.com>

* Build tag script (#1035)

* update build script

* added command echoes

* pinning to numpy 1.19.2 to avoid ART error (#1056)

* updating comment on relevant np issue (#1057)

* CIFAR-100 dataset (#1048)

* Add CIFAR100 dataset

* Typo

* label targeter refactor (#1052)

* renamed file

* fix typo while remaining backwards compatible

* refactored label targeter config loading logic

* updating configs accordingly

* adding one more config

* changing filename back to labels.py

* adding warning message for deprecated 'scheme' key

* removing code that shouldn't have been pushed/fixing typo

* update configs for label_targeters.py --> labels.py change

* removing configs i didn't meant to push

* keyword-only args; change config 'args' --> 'kwargs'

* refactor object detection metrics (#1046)

* refactored object_detection_AP_per_class

* refactor dapricot and apricot AP functions

* update tests for od metrics refactor

* removing od metrics that aren't useful

* modify od format check function; renamed a couple variables

* refactor to remove unnecessary elifs; rename append() to add_results()

* formatting

* renamed method

* document function input format

* bumping ART 1.6.0 --> 1.6.1 (#1062)

* updating baseline config to be compatible with newer versions of ART (#1063)

* don't assume default branch is named master (#1064)

* Poisoning scenario with blended trigger (#1049)

* * Update image-based trigger to allow blending
* Use blended trigger to enable bullethole clbd attack

* Update docker image reference in config

* Update pathing to load image path when armory is pip installed

* Use armory.__file__ to simplify relative pathing

* preprocessing defense fixes (#1060)

* call set_params() so classifier.all_framework_preprocessing attribute is updated

* no longer using kwarg which ART has removed

* use get_params() to append defenses; removed if ART < 1.5 logic

* flake8

* dapricot updates (#1040)

* adjust scale for insert_patch(); make patch shape square

* force dapricot attacks to be targeted

* formatting

* increment label index in loss_gradient for baseline 0-indexed model

* need to decrement not increment

* adding dapricot_patch_target_success metric

* resetting this variable to empty list since dparicot has no nontargeted tasks

* this workaround is no longer necessary per previous commit

* deleting commented out code that was accidentally pushed

* removing config since DPatch doesn't support targeted attack yet

* formatting

* reshape box to flat array

* add docs for fn input format

* formatting

* updated dapricot RobustDPatch attack and associated files

* ran black, flake8, and format_json

* adding targeted Dpatch to file itself so we dont need to use dev version of ART

* minor documentation/error msg update

* removing channels_first logic since x will always be channels_last with armory

* black formatting

* adding clarifying comment

* set num_images_per_patch in scenario code; force threat model to be specified in scenario code

* minor modifications to error messages

* dont overwrite model kwargs; add 'batch_size' kwarg to baseline models get_art_model()

* add warning if batch_size model_kwarg isnt set; also edited comment at top of script

* removing unused line of code

* removing code that has no effect on attack

* avoid warning message by renaming colour fn to its updated name

* set check on lower bound of brightness range

* fix typo

* point to armory 0.13.1 in config

* point to armory 0.13.1 in pgd config too

* only display warning for physical attacks

* flake8

* the code in this file was moved to inside the attack

* removing dapricot robust dpatch attack and associated utility functions

* flake8

Co-authored-by: Yusong Tan <ytan@mitre.org>

* Resisc10 poison (#1065)

* * Update image-based trigger to allow blending
* Use blended trigger to enable bullethole clbd attack

* Update docker image reference in config

* Update pathing to load image path when armory is pip installed

* resisc10 poison scenario related files

* Updated poisoning attack call based on ART updates, fix channel ordering for image data

* Update metrics method names

* Update config to work with pip-installed armory

Co-authored-by: Neal Gupta <neal.gupta@twosixlabs.com>

* Poisoning scenario Pytorch example (#1067)

* Pytorch compatibility for poisoning scenarios, example Pytorch config for dlbd

* Configs closer to eval approach

Co-authored-by: davidslater <david.slater@twosixlabs.com>
Co-authored-by: yusong-tan <59029053+yusong-tan@users.noreply.github.com>
Co-authored-by: Neal Gupta <neal.gupta@twosixlabs.com>
Co-authored-by: Yusong Tan <ytan@mitre.org>

* Update dockerfile for tf1 (#1086)

* 0.13.2 (#1102)

* Increment version to 0.13.2 (#1095)

* Bump version

* Update configs

* dapricot test set (#1096)

* cherry-picked dapricot test commits from 1088

* correct checksum filename

* Coco (#1097)

* cherry-picking commits from 1085, excluding the commit merging in dev branch

* adding coco tests, skipping if not available locally

* adding note to docs about apricot class indexing

* updated checksum after new upload to s3

Co-authored-by: ng390 <neal.gupta@twosixlabs.com>

Co-authored-by: David Slater <david.slater@twosixlabs.com>
Co-authored-by: lcadalzo <39925313+lcadalzo@users.noreply.github.com>
Co-authored-by: yusong-tan <59029053+yusong-tan@users.noreply.github.com>
Co-authored-by: Yusong Tan <ytan@mitre.org>
  • Loading branch information
5 people authored Jun 14, 2021
1 parent 3784f60 commit eb8f989
Show file tree
Hide file tree
Showing 12 changed files with 708 additions and 124 deletions.
72 changes: 19 additions & 53 deletions armory/baseline_models/tf_graph/mscoco_frcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,29 @@
import tensorflow as tf


class TensorFlowFasterRCNNOneIndexed(TensorFlowFasterRCNN):
"""
This is an MSCOCO pre-trained model. Note that the inherited TensorFlowFasterRCMM class
outputs 0-indexed classes, while this wrapper class outputs 1-indexed classes. A label map can be found at
https://github.com/tensorflow/models/blob/master/research/object_detection/data/mscoco_label_map.pbtxt
This model only performs inference and is not trainable. To train
or fine-tune this model, please follow instructions at
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1.md
"""

def __init__(self, images):
super().__init__(
images,
model=None,
filename="faster_rcnn_resnet50_coco_2018_01_28",
url="http://download.tensorflow.org/models/object_detection/faster_rcnn_resnet50_coco_2018_01_28.tar.gz",
sess=None,
is_training=False,
clip_values=(0, 1),
channels_first=False,
preprocessing_defences=None,
postprocessing_defences=None,
attack_losses=(
"Loss/RPNLoss/localization_loss",
"Loss/RPNLoss/objectness_loss",
"Loss/BoxClassifierLoss/localization_loss",
"Loss/BoxClassifierLoss/classification_loss",
),
)

def compute_loss(self, x, y):
raise NotImplementedError

def loss_gradient(self, x, y, **kwargs):
y_zero_indexed = []
for y_dict in y:
y_dict_zero_indexed = y_dict.copy()
y_dict_zero_indexed["labels"] = y_dict_zero_indexed["labels"] - 1
y_zero_indexed.append(y_dict_zero_indexed)
return super().loss_gradient(x, y_zero_indexed, **kwargs)

def predict(self, x, **kwargs):
list_of_zero_indexed_pred_dicts = super().predict(x, **kwargs)
list_of_one_indexed_pred_dicts = []
for img_pred_dict in list_of_zero_indexed_pred_dicts:
zero_indexed_pred_labels = img_pred_dict["labels"]
img_pred_dict["labels"] = zero_indexed_pred_labels + 1
list_of_one_indexed_pred_dicts.append(img_pred_dict)
return list_of_one_indexed_pred_dicts


def get_art_model(model_kwargs, wrapper_kwargs, weights_file=None):
# APRICOT inputs should have shape (1, None, None, 3) while DAPRICOT inputs have shape
# (3, None, None, 3)
images = tf.placeholder(
tf.float32, shape=(model_kwargs.get("batch_size", 1), None, None, 3)
)
model = TensorFlowFasterRCNNOneIndexed(images)
model = TensorFlowFasterRCNN(
images,
model=None,
filename="faster_rcnn_resnet50_coco_2018_01_28",
url="http://download.tensorflow.org/models/object_detection/faster_rcnn_resnet50_coco_2018_01_28.tar.gz",
sess=None,
is_training=False,
clip_values=(0, 1),
channels_first=False,
preprocessing_defences=None,
postprocessing_defences=None,
attack_losses=(
"Loss/RPNLoss/localization_loss",
"Loss/RPNLoss/objectness_loss",
"Loss/BoxClassifierLoss/localization_loss",
"Loss/BoxClassifierLoss/classification_loss",
),
)

return model
Loading

0 comments on commit eb8f989

Please sign in to comment.