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

Fix #2321 Subclass PyTorchYolo and PyTorchDetectionTransformer off PyTorchObjectDetector #2371

Closed
wants to merge 31 commits into from

Conversation

beat-buesser
Copy link
Collaborator

Description

This pull request continues #2321 and fixes the failing unit tests.

f4str and others added 20 commits November 8, 2023 17:00
Signed-off-by: Farhan Ahmed <[email protected]>
Signed-off-by: Farhan Ahmed <[email protected]>
Signed-off-by: Farhan Ahmed <[email protected]>
Signed-off-by: Farhan Ahmed <[email protected]>
Signed-off-by: Farhan Ahmed <[email protected]>
Signed-off-by: Farhan Ahmed <[email protected]>
Signed-off-by: Farhan Ahmed <[email protected]>
Signed-off-by: Farhan Ahmed <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
@beat-buesser beat-buesser self-assigned this Dec 23, 2023
@beat-buesser beat-buesser added the improvement Improve implementation label Dec 23, 2023
@beat-buesser beat-buesser added this to the ART 1.17.0 milestone Dec 23, 2023
@beat-buesser beat-buesser changed the base branch from main to dev_1.17.0 December 23, 2023 22:31
@beat-buesser beat-buesser changed the base branch from dev_1.17.0 to main December 23, 2023 22:40
@beat-buesser beat-buesser changed the base branch from main to dev_1.17.0 December 23, 2023 22:40
Signed-off-by: Beat Buesser <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2023

Codecov Report

Attention: 74 lines in your changes are missing coverage. Please review.

Comparison is base (25f7ac0) 85.35% compared to head (bb1e089) 84.79%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.17.0    #2371      +/-   ##
==============================================
- Coverage       85.35%   84.79%   -0.57%     
==============================================
  Files             327      327              
  Lines           30622    29887     -735     
  Branches         5779     5526     -253     
==============================================
- Hits            26138    25342     -796     
- Misses           3043     3132      +89     
+ Partials         1441     1413      -28     
Files Coverage Δ
...ators/certification/object_seeker/object_seeker.py 93.27% <100.00%> (-4.89%) ⬇️
...ertification/randomized_smoothing/macer/pytorch.py 98.38% <ø> (ø)
...ification/randomized_smoothing/macer/tensorflow.py 91.89% <ø> (ø)
...tors/certification/randomized_smoothing/pytorch.py 85.54% <ø> (ø)
...ication/randomized_smoothing/smooth_adv/pytorch.py 98.36% <ø> (ø)
...tion/randomized_smoothing/smooth_adv/tensorflow.py 94.11% <ø> (ø)
...ication/randomized_smoothing/smooth_mix/pytorch.py 97.22% <ø> (ø)
...s/certification/randomized_smoothing/tensorflow.py 87.09% <ø> (ø)
art/estimators/classification/keras.py 82.63% <100.00%> (ø)
art/estimators/classification/pytorch.py 86.45% <ø> (ø)
... and 6 more

... and 13 files with indirect coverage changes

Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Signed-off-by: Beat Buesser <[email protected]>
Comment on lines +192 to +204
# def test_errors(art_warning):
# try:
# from torch import hub
#
# from art.estimators.object_detection.pytorch_detection_transformer import PyTorchDetectionTransformer
#
# model = hub.load("facebookresearch/detr", "detr_resnet50", pretrained=True)
#
# with pytest.raises(ValueError):
# PyTorchDetectionTransformer(
# model=model,
# clip_values=(1, 2),
# attack_losses=("loss_ce", "loss_bbox", "loss_giou"),

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
Comment on lines +207 to +211
# with pytest.raises(ValueError):
# PyTorchDetectionTransformer(
# model=model,
# clip_values=(-1, 1),
# attack_losses=("loss_ce", "loss_bbox", "loss_giou"),

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
Comment on lines +217 to +222
# with pytest.raises(ValueError):
# PyTorchDetectionTransformer(
# model=model,
# clip_values=(0, 1),
# attack_losses=("loss_ce", "loss_bbox", "loss_giou"),
# postprocessing_defences=post_def,

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
Comment on lines +225 to +226
# except ARTTestException as e:
# art_warning(e)

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
Comment on lines +230 to +243
# def test_preprocessing_defences(art_warning, get_pytorch_detr):
# try:
# object_detector, x_test, _ = get_pytorch_detr
#
# from art.defences.preprocessor.spatial_smoothing_pytorch import SpatialSmoothingPyTorch
#
# pre_def = SpatialSmoothingPyTorch()
#
# object_detector.set_params(preprocessing_defences=pre_def)
#
# # Create labels
# result = object_detector.predict(x=x_test)
#
# y = [

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
Comment on lines +261 to +262
# except ARTTestException as e:
# art_warning(e)

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
Comment on lines +266 to +273
# def test_compute_losses(art_warning, get_pytorch_detr):
# try:
# object_detector, x_test, y_test = get_pytorch_detr
# losses = object_detector.compute_losses(x=x_test, y=y_test)
# assert len(losses) == 3
#
# except ARTTestException as e:
# art_warning(e)

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
Comment on lines +277 to +287
# def test_compute_loss(art_warning, get_pytorch_detr):
# try:
# object_detector, x_test, y_test = get_pytorch_detr
#
# # Compute loss
# loss = object_detector.compute_loss(x=x_test, y=y_test)
#
# assert pytest.approx(6.7767677, abs=0.1) == float(loss)
#
# except ARTTestException as e:
# art_warning(e)

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
Comment on lines +291 to +302
# def test_pgd(art_warning, get_pytorch_detr):
# try:
# from art.attacks.evasion import ProjectedGradientDescent
#
# object_detector, x_test, y_test = get_pytorch_detr
#
# attack = ProjectedGradientDescent(estimator=object_detector, max_iter=2)
# x_test_adv = attack.generate(x=x_test, y=y_test)
# np.testing.assert_raises(AssertionError, np.testing.assert_array_equal, x_test_adv, x_test)
#
# except ARTTestException as e:
# art_warning(e)

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
@f4str
Copy link
Collaborator

f4str commented Jan 19, 2024

@beat-buesser PR #2321 should now be fixed. It's also been rebased to the dev_1.18.0 branch. Feel free to close this PR in favor of the other one.

@beat-buesser
Copy link
Collaborator Author

fixed by #2321

@beat-buesser beat-buesser deleted the f4str-pytorch-yolo-rebase branch October 1, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improve implementation
Projects
No open projects
Status: Pull request done
Development

Successfully merging this pull request may close these issues.

3 participants