-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 Overload attack #2337
Added support for Overload attack #2337
Conversation
Hi @CNOCycle Thank you very much for your pull request! Could you please change the target and rebase on to dev branch |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev_1.18.0 #2337 +/- ##
==============================================
- Coverage 85.66% 77.55% -8.12%
==============================================
Files 327 329 +2
Lines 29954 30073 +119
Branches 5540 5173 -367
==============================================
- Hits 25661 23322 -2339
- Misses 2866 5449 +2583
+ Partials 1427 1302 -125
|
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 mich for your pull request! I have added a few review requests, please let me know what you think.
art/attacks/evasion/overload.py
Outdated
@@ -0,0 +1,260 @@ | |||
# MIT License | |||
# | |||
# 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 |
art/attacks/evasion/overload.py
Outdated
"batch_size", | ||
] | ||
|
||
_estimator_requirements = () |
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.
Please add parent classes for object detection estimators for PyTorch-specific models, similar to #2440.
art/attacks/evasion/overload.py
Outdated
|
||
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.
Please add type for object detection models in PyTorch using the types to be defined in #2440 for the same purpose.
art/attacks/evasion/overload.py
Outdated
""" | ||
Create a overload attack instance. | ||
|
||
:param estimator: A trained YOLO5 model. |
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.
:param estimator: A trained YOLO5 model. | |
:param estimator: A PyTorch object detection estimator for a YOLO5 model. |
art/attacks/evasion/overload.py
Outdated
""" | ||
|
||
import torch |
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 | |
""" | |
import torch | |
try: | ||
import torch | ||
model = torch.hub.load('ultralytics/yolov5:v7.0', model='yolov5s') | ||
x = np.random(0.0, 1.0, size=(100, 3, 640, 640)) |
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 check this line, should it not be np.random.normal
?
|
||
|
||
@pytest.mark.only_with_platform("pytorch") | ||
def test_check_params(art_warning): |
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 test seems to be failing.
|
||
x_adv = attack.generate(x) | ||
|
||
assert x.shape == x_adv.shape |
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 additional asserts to check the expected values in x_adv
?
art/attacks/evasion/overload.py
Outdated
""" | ||
|
||
import torch |
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 | |
""" | |
import torch |
art/attacks/evasion/overload.py
Outdated
# IoU = inter / (area1 + area2 - inter) | ||
return inter / ((a2 - a1).prod(2) + (b2 - b1).prod(2) - inter + eps) | ||
|
||
def _check_params(self) -> None: |
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.
I think it would be very helpful if we could add a check if the provided model is a Yolo v5 model.
|
||
def __init__( | ||
self, | ||
estimator: PyTorchObjectDetector, |
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.
We cannot directly use the class as type definition. Could you please create or use a type definition in art/utils.py
?
:param x: A given image | ||
:return: Overload loss and the weight of each pixel | ||
""" | ||
|
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.
@CNOCycle Thank you very much for your first accepted pull request to ART! |
Description
This pull request adds the support of the Overload Attack proposed in [1].
[1] Overload: Latency Attacks on Object Detection for Edge Devices. [Paper]
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