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
Added support for SNAL attack #2440
base: dev_1.18.0
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev_1.18.0 #2440 +/- ##
==============================================
- Coverage 85.39% 80.70% -4.69%
==============================================
Files 327 328 +1
Lines 30205 30660 +455
Branches 5589 5651 +62
==============================================
- Hits 25794 24745 -1049
- Misses 2964 4500 +1536
+ Partials 1447 1415 -32
|
x_out = x_init.clone() | ||
x_eval = self._assemble(tile_mat, x_org) | ||
adv_patch, adv_position = collect_patches_from_images(self.estimator, x_eval) | ||
cur_patch = adv_patch[0] |
Check notice
Code scanning / CodeQL
Unused local variable Note
|
||
# select n_sample candidates | ||
c_tile = r_tile | ||
c_mask = r_mask |
Check warning
Code scanning / CodeQL
Variable defined multiple times Warning
redefined
else: | ||
target = bcount_list[0].patch[None, :] | ||
x_ref = x[b, :, y1:y2, x1:x2] | ||
pert = target - x_ref |
Check warning
Code scanning / CodeQL
Variable defined multiple times Warning
redefined
# update results | ||
adv_patch, adv_position = collect_patches_from_images(self.estimator, x_cand) | ||
for idx in range(n_samples): | ||
cur_patch = adv_patch[idx] |
Check warning
Code scanning / CodeQL
Variable defined multiple times Warning
redefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @CNOCycle Thank you very much for you pull request. I think it looks good, I have only found a few formatting and documentation issues. Could you please take a look and let me know if you have questions?
@@ -0,0 +1,747 @@ | |||
# | |||
# Copyright (C) The Adversarial Robustness Toolbox (ART) Authors 2018 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Copyright (C) The Adversarial Robustness Toolbox (ART) Authors 2018 | |
# Copyright (C) The Adversarial Robustness Toolbox (ART) Authors 2024 |
""" | ||
This module implements the paper: "Steal Now and Attack Later: Evaluating Robustness of Object Detection against Black-box Adversarial Attacks" | ||
| Paper link: https://arxiv.org/abs/2304.05370 | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | |
This module implements the paper: "Steal Now and Attack Later: Evaluating Robustness of Object Detection against Black-box Adversarial Attacks" | |
| Paper link: https://arxiv.org/abs/2304.05370 | |
""" | |
""" | |
This module implements the paper: "Steal Now and Attack Later: Evaluating Robustness of Object Detection against Black-box Adversarial Attacks" | |
| Paper link: https://arxiv.org/abs/2304.05370 | |
""" |
import logging | ||
from typing import Optional, Tuple, TYPE_CHECKING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import logging | |
from typing import Optional, Tuple, TYPE_CHECKING | |
import logging | |
import random | |
from typing import Optional, Tuple, TYPE_CHECKING |
from typing import Optional, Tuple, TYPE_CHECKING | ||
|
||
import numpy as np | ||
import random |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import random |
|
||
x_out[:, :, y1:y2, x1:x2] = updated | ||
|
||
return x_out, tile_mat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add empty line at end of file
return x_out, tile_mat | |
return x_out, tile_mat | |
import torch | ||
TRIAL = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import torch | |
TRIAL = 10 | |
import torch | |
TRIAL = 10 |
|
||
def __init__( | ||
self, | ||
estimator: "torch.nn.Module", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
estimator: "torch.nn.Module", | |
estimator: PYTORCH_OBJECT_DETECTION_TYPE, |
and please add
PYTORCH_OBJECT_DETECTION_TYPE = Union[PyTorchObjectDetector]
to art/utils.py with the other type definitions at the tope of that file.
# pylint: disable=C0412 | ||
import torch | ||
|
||
logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add docstrings to all functions in this module?
|
||
logger = logging.getLogger(__name__) | ||
|
||
def _bbox_ioa(box1: "torch.tenosr", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please include the license text of the file yolov5/utils/metrics.py to this docstring?
block_size: int): | ||
""" | ||
=== NOTE === | ||
This function is modified from torchvision (torchvision/ops/drop_block.py) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please include the license text of the file yolov5/utils/metrics.py to this docstring?
Description
This pull request adds the support of the SNAL Attack proposed in [1].
[1]Steal Now and Attack Later: Evaluating Robustness of Object Detection against Black-box Adversarial Attacks. [Paper]
Fixes # (issue)
Type of change
Please check all relevant options.
Testing
Please describe the tests that you ran to verify your changes. Consider listing any relevant details of your test configuration.
Test Configuration:
Checklist