Skip to content
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

Detection Transformer Estimator #2192

Merged

Conversation

kieranfraser
Copy link
Collaborator

Description

Adding DEtection TRansformer (DETR) to ART to facilitate object detection using Transformers.

  • DETR estimator added to art/estimators/object_detection
  • requires additional method in art/estimators/pytorch.py which sets MultiheadAttention layer into train/eval mode
  • associated tests added
  • notebook demonstrating use of DETR estimator detecting objects and under adversarial patch attack added to notebooks/adversarial_patch/ and updated notebooks/ README

Paper: "End-to-End Object Detection with Transformers"

Fixes # (issue)
#1638

Type of change

Please check all relevant options.

  • Improvement (non-breaking)
  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing

Please describe the tests that you ran to verify your changes. Consider listing any relevant details of your test configuration.

  • Test prediction of DETR
  • Test loss gradient
  • Test applying preprocessing defences
  • Test computation of losses (classification, bbox, giou)
  • Test DETR with PGD attack

Test Configuration:

  • OS
  • Python version
  • ART version or commit number
  • TensorFlow / Keras / PyTorch / MXNet version

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

kieranfraser and others added 24 commits June 14, 2023 10:26
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
…utils from torchvision repo. pretrained vit output to be investigated after training.

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
…nd robust dpatch attack (for COCO image, still to check: IN images)

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
… object detection under attack.

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
…pdated notebook. Formatting files.

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>

rebased to dev_1.14.1

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
…d notebooks README with DETR notebook.

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: signedqiu <10063108+signedqiu@user.noreply.gitee.com>
Signed-off-by: signedqiu <chunlinqiu@whu.edu.cn>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
…tebook: validated attack with PGD. Updates to test: correct loss computation and PGD.

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2023

Codecov Report

Merging #2192 (81408e5) into dev_1.15.0 (28a3f8c) will decrease coverage by 0.05%.
The diff coverage is 69.19%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.15.0    #2192      +/-   ##
==============================================
- Coverage       85.66%   85.61%   -0.05%     
==============================================
  Files             306      308       +2     
  Lines           27022    27448     +426     
  Branches         4962     5044      +82     
==============================================
+ Hits            23148    23500     +352     
- Misses           2602     2668      +66     
- Partials         1272     1280       +8     
Impacted Files Coverage Δ
.../object_detection/pytorch_detection_transformer.py 63.26% <63.26%> (ø)
art/estimators/object_detection/detr.py 73.87% <73.87%> (ø)
art/estimators/object_detection/__init__.py 100.00% <100.00%> (ø)
art/estimators/pytorch.py 85.71% <100.00%> (+2.09%) ⬆️

... and 8 files with indirect coverage changes

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
@kieranfraser kieranfraser marked this pull request as ready for review June 14, 2023 17:39
@beat-buesser beat-buesser self-requested a review June 14, 2023 21:23
@beat-buesser beat-buesser self-assigned this Jun 14, 2023
@beat-buesser beat-buesser added the enhancement New feature or request label Jun 14, 2023
@beat-buesser beat-buesser added this to Pull request open in ART 1.15.0 via automation Jun 14, 2023
@beat-buesser beat-buesser added this to the ART 1.15.0 milestone Jun 14, 2023
Copy link
Collaborator

@beat-buesser beat-buesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kieranfraser Thank you very much for your PR. I think we need to include the license of reused code somewhere. I think the patches don't have a lot of effects on the detections, is there a way how we could generate a stronger patch?

ART 1.15.0 automation moved this from Pull request open to Pull request review Jun 14, 2023
@beat-buesser beat-buesser mentioned this pull request Jun 14, 2023
17 tasks
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
…nd untargeted

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
@kieranfraser
Copy link
Collaborator Author

Hi @kieranfraser Thank you very much for your PR. I think we need to include the license of reused code somewhere. I think the patches don't have a lot of effects on the detections, is there a way how we could generate a stronger patch?

Thanks @beat-buesser. I have added references to the license (Apache 2.0) in the Docstrings of reused code. Also updated the notebook with stronger Adversarial Patch attacks (targeted and untargeted). Seems that unless a fixed patch location is passed, the attack fails to converge to a patch that fools the DETR - plan to experiment further with this. But the notebook now demonstrates working patches as well as PGD for the DETR.

kieranfraser and others added 11 commits June 15, 2023 13:44
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
…ed test so consistently passes on both CPU and GPU.

Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
Signed-off-by: Kieran Fraser <Kieran.Fraser@ibm.com>
@beat-buesser beat-buesser merged commit 82f8fa2 into Trusted-AI:dev_1.15.0 Jun 28, 2023
37 checks passed
ART 1.15.0 automation moved this from Pull request review to Pull request done Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
ART 1.15.0
Pull request done
Development

Successfully merging this pull request may close these issues.

Implement object detection estimators for Vision Transformers (ViT)
3 participants