File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -511,13 +511,13 @@ def generate( # type: ignore
511
511
if self .patch_location is not None and mask is not None :
512
512
raise ValueError ("Masks can only be used if the `patch_location` is `None`." )
513
513
514
+ if y is None and self .targeted :
515
+ raise ValueError ("The targeted version of AdversarialPatch attack requires provided target labels." )
516
+
514
517
if hasattr (self .estimator , "nb_classes" ):
515
518
516
519
y_array : np .ndarray
517
520
518
- if y is not None and not self .targeted :
519
- raise ValueError ("The untargeted version of AdversarialPatch attack does not use target labels." )
520
-
521
521
if y is None : # pragma: no cover
522
522
logger .info ("Setting labels to estimator classification predictions." )
523
523
y_array = to_categorical (
@@ -536,9 +536,6 @@ def generate( # type: ignore
536
536
else :
537
537
self .use_logits = True
538
538
else :
539
- if y is not None and not self .targeted :
540
- raise ValueError ("The untargeted version of AdversarialPatch attack does not use target labels." )
541
-
542
539
if y is None : # pragma: no cover
543
540
logger .info ("Setting labels to estimator object detection predictions." )
544
541
y = self .estimator .predict (x = x )
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ def generate( # type: ignore
155
155
if y is None and self .targeted :
156
156
raise ValueError ("The targeted version of RobustDPatch attack requires target labels provided to `y`." )
157
157
if y is not None and not self .targeted :
158
- raise ValueError ("The RobustDPatch attack does not use target labels." )
158
+ raise ValueError ("The untargeted version of RobustDPatch attack does not use target labels provided to 'y' ." )
159
159
if x .ndim != 4 : # pragma: no cover
160
160
raise ValueError ("The adversarial patch can only be applied to images." )
161
161
You can’t perform that action at this time.
0 commit comments