-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: dev_1.18.0
Are you sure you want to change the base?
Conversation
Hi @CNOCycle Thank you very much for your pull request! Could you please change the target and rebase on to dev branch |
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## dev_1.18.0 #2337 +/- ##
===============================================
- Coverage 85.60% 69.87% -15.73%
===============================================
Files 324 325 +1
Lines 29326 29443 +117
Branches 5407 5426 +19
===============================================
- Hits 25104 20574 -4530
- Misses 2840 7674 +4834
+ Partials 1382 1195 -187
|
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)) |
Check failure
Code scanning / CodeQL
Non-callable called Error
non-callable
builtin-class module
|
||
idx_min = torch.argmin(scores) | ||
grid_min = grid_box[idx_min] | ||
x1, y1, x2, y2 = grid_min.int() |
Check notice
Code scanning / CodeQL
Unused local variable Note
|
||
idx_min = torch.argmin(scores) | ||
grid_min = grid_box[idx_min] | ||
x1, y1, x2, y2 = grid_min.int() |
Check notice
Code scanning / CodeQL
Unused local variable Note
|
||
idx_min = torch.argmin(scores) | ||
grid_min = grid_box[idx_min] | ||
x1, y1, x2, y2 = grid_min.int() |
Check notice
Code scanning / CodeQL
Unused local variable Note
|
||
idx_min = torch.argmin(scores) | ||
grid_min = grid_box[idx_min] | ||
x1, y1, x2, y2 = grid_min.int() |
Check notice
Code scanning / CodeQL
Unused local variable Note
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.
@@ -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 |
"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.
|
||
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.
""" | ||
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. |
""" | ||
|
||
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
?
""" | ||
|
||
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 |
# 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.
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