INFO:rldata.rlpedata:Loading dataset from zh-plus/tiny-imagenet Fast image processor…
- User
INFO:rldata.rlpedata:Loading dataset from zh-plus/tiny-imagenet Fast image processor class <class 'transformers.models.vit.image_processing_vit_fast.ViTImageProcessorFast'> is available for this model. Using slow image processor class. To use the fast image processor class set
use_fast=True. Some weights of ViTForImageClassification were not initialized from the model checkpoint at google/vit-base-patch16-224-in21k and are newly initialized: ['classifier.bias', 'classifier.weight'] You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference. INFO:model.modelloader:Successfully initialized transformers model: google/vit-base-patch16-224-in21k INFO:art.estimators.classification.pytorch:Inferred 2 hidden layers on PyTorch classifier. INFO:defences.defencerlpe:DefenseManager initialized with available defenses. ['SpatialSmoothing', 'FeatureSqueezing', 'JpegCompression'] INFO:attacks.attackrlpe:Initializing attack: CarliniL2Method C&W L_2: 0%| | 0/32 [00:00<?, ?it/s] ERROR:attacks.attackrlpe:Attack generation failed: 'ImageClassifierOutput' object has no attribute 'detach' ERROR:attacks.attackrlpe:Unexpected error during 'CarliniL2Method': 'ImageClassifierOutput' object has no attribute 'detach' Traceback (most recent call last): File "/scratch/hemanth/Hemanth/RLPE/rlpe.py", line 82, in images=apply_attack(attack_name=attack,classifier=classifier,x=images,y=labels) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/scratch/hemanth/Hemanth/RLPE/attacks/attackrlpe.py", line 938, in apply_attack adversarial_examples = attack.generate(x=x_numpy, y=y_numpy) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/scratch/hemanth/anaconda/envs/rlpe/lib/python3.12/site-packages/art/attacks/evasion/carlini.py", line 302, in generate z_logits, l2dist, loss = self._loss(x_batch, x_adv_batch, y_batch, c_current) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/scratch/hemanth/anaconda/envs/rlpe/lib/python3.12/site-packages/art/attacks/evasion/carlini.py", line 151, in _loss z_predicted = self.estimator.predict( ^^^^^^^^^^^^^^^^^^^^^^^ File "/scratch/hemanth/anaconda/envs/rlpe/lib/python3.12/site-packages/art/estimators/classification/classifier.py", line 75, in replacement_function return fdict[func_name](self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/scratch/hemanth/anaconda/envs/rlpe/lib/python3.12/site-packages/art/estimators/classification/pytorch.py", line 331, in predict output = output.detach().cpu().numpy().astype(np.float32) ^^^^^^^^^^^^^ AttributeError: 'ImageClassifierOutput' object has no attribute 'detach'def apply_attack( attack_name: str, classifier: Any, x: np.ndarray, y: Optional[np.ndarray] = None, new_params: Optional[Dict[str, Any]] = None, ) -> np.ndarray: """ Apply a single adversarial attack with the ability to update attack parameters. """ logger.info(f"Initializing attack: {attack_name}") try: attack_class = get_attack_class(attack_name) if not attack_class: raise NotImplementedError(f"The attack '{attack_name}' is not supported.")
- Assistant