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
511511 if self .patch_location is not None and mask is not None :
512512 raise ValueError ("Masks can only be used if the `patch_location` is `None`." )
513513
514+ if y is None and self .targeted :
515+ raise ValueError ("The targeted version of AdversarialPatch attack requires provided target labels." )
516+
514517 if hasattr (self .estimator , "nb_classes" ):
515518
516519 y_array : np .ndarray
517520
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-
521521 if y is None : # pragma: no cover
522522 logger .info ("Setting labels to estimator classification predictions." )
523523 y_array = to_categorical (
@@ -536,9 +536,6 @@ def generate( # type: ignore
536536 else :
537537 self .use_logits = True
538538 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-
542539 if y is None : # pragma: no cover
543540 logger .info ("Setting labels to estimator object detection predictions." )
544541 y = self .estimator .predict (x = x )
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ def generate( # type: ignore
155155 if y is None and self .targeted :
156156 raise ValueError ("The targeted version of RobustDPatch attack requires target labels provided to `y`." )
157157 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' ." )
159159 if x .ndim != 4 : # pragma: no cover
160160 raise ValueError ("The adversarial patch can only be applied to images." )
161161
You can’t perform that action at this time.
0 commit comments