Code for "Adversarial attack by dropping information." (ICCV 2021)

Overview

AdvDrop

Code for "AdvDrop: Adversarial Attack to DNNs by Dropping Information(ICCV 2021)."

Human can easily recognize visual objects with lost information: even losing most details with only contour reserved, e.g. cartoon. However, in terms of visual perception of Deep Neural Networks (DNNs), the ability for recognizing abstract objects (visual item with lost information) is still a challenge. In this work, we investigate this issue from an adversarial viewpoint: will the performance of DNNs decrease even for the images only losing a little information? Towards this end, we propose a novel adversarial attack, named AdvDrop, which crafts adversarial examples by dropping existing information of images. Previously, most adversarial attacks add extra disturbing information on clean images explicitly. Opposite to previous works, our proposed work explores the adversarial robustness of DNN models in a novel perspective by dropping imperceptible details to craft adversarial examples.

[Paper link](http://arxiv.org/abs/2108.09034)

Installation

We highly recommend using conda.

conda create -n advdrop_env python=3.7
source activate advdrop_env

After activating the virtual environment, install pytorch, numpy and torchattacks with:

pip install --user [the package name]

Download dataset.

Usage

Quick Start

python infod_sample.py
  • Parameters can be speicified in infod_sample.py.

An example

Adv Images

Acknowledgments

Citation


Comments
  • adversarial example

    adversarial example

    Hi, I used the dataset and code you provided to make adversarial examples. Running the program, the correct rate of the adversarial samples is 100% (q=100), but the adversarial examples are sent back to the network for classification, and half of the adversarial examples do not change the original correct classification results.I don't know if you or anyone else has this problem.

    opened by tianxianbaoba 5
  • Question about DCT

    Question about DCT

    Hi, thanks for your work. It is very interesting. But I have a question about mathmatical definition of DCT in your paper: What are the meanings of parameters ‘u, v, k, m’ in the formula? Looking forward to your reply, thanks!!!

    opened by shuangerwaiwai 5
  • Y,Cb,Cr channels of the image?

    Y,Cb,Cr channels of the image?

    Hi @RjDuan Thank you for your work.

    While creating components in following code, RGB channels of the images are being treated as YCbCr channels. If this observation is correct, could you please let me the reason behind re-naming RGB channels to YCbCr channels. Or someone should actually convert an image from RGB to YCbCr color space. https://github.com/RjDuan/AdvDrop/blob/35ceeb0e1c4b258bf3995302fbce9f13b39860f0/infod_sample.py#L72

    Thank you.

    opened by asif-hanif 4
  • OSError: image file is truncated

    OSError: image file is truncated

    After I ran python infod_sample.py, it ran normally in the beginning. However, there occurred this error when iter is 48:

    Step:  100   Loss:  7.811537265777588   Current Suc rate:  0.2
    Step:  110   Loss:  7.403205871582031   Current Suc rate:  0.2
    Step:  120   Loss:  7.0217485427856445   Current Suc rate:  0.2
    Step:  130   Loss:  6.647172451019287   Current Suc rate:  0.2
    Step:  140   Loss:  6.154144763946533   Current Suc rate:  0.25
    Current suc. rate:  0.303125
    Iter:  48
    Traceback (most recent call last):
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/PIL/I                          mageFile.py", line 237, in load
        s = read(self.decodermaxblock)
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/PIL/P                          ngImagePlugin.py", line 896, in load_read
        cid, pos, length = self.png.read()
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/PIL/P                          ngImagePlugin.py", line 162, in read
        length = i32(s)
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/PIL/_                          binary.py", line 75, in i32be
        return unpack_from(">I", c, o)[0]
    struct.error: unpack_from requires a buffer of at least 4 bytes for unpacking                           4 bytes at offset 0 (actual buffer size is 0)
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "infod_sample.py", line 191, in <module>
        images, labels = normal_iter.next()
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/torch                          /utils/data/dataloader.py", line 435, in __next__
        data = self._next_data()
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/torch                          /utils/data/dataloader.py", line 475, in _next_data
        data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/torch                          /utils/data/_utils/fetch.py", line 44, in fetch
        data = [self.dataset[idx] for idx in possibly_batched_index]
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/torch                          /utils/data/_utils/fetch.py", line 44, in <listcomp>
        data = [self.dataset[idx] for idx in possibly_batched_index]
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/torch                          vision/datasets/folder.py", line 151, in __getitem__
        sample = self.loader(path)
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/torch                          vision/datasets/folder.py", line 188, in default_loader
        return pil_loader(path)
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/torch                          vision/datasets/folder.py", line 170, in pil_loader
        return img.convert('RGB')
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/PIL/I                          mage.py", line 904, in convert
        self.load()
      File "/home/miniconda3/envs/pytorch17/lib/python3.8/site-packages/PIL/I                          mageFile.py", line 243, in load
        raise OSError("image file is truncated") from e
    OSError: image file is truncated
    

    Can anyone help me?

    Thanks a lot.

    opened by zhoufengfan 4
  • Values of the elements of Q-table

    Values of the elements of Q-table

    Hi, as you said in your paper (Section 3.4 Quantization) --- 'As the quantization table q should be integers during the optimization'. Do you think the data type of q table really affects the results? I mean what will happen if the elements in the q-table are float numbers. Thanks!

    opened by wangtingwei1993 2
  • RuntimeError

    RuntimeError

    I downloaded the data set, ran the code, and encountered the following error: RuntimeError: The size of tensor a(7) must match the size of tensor b (20) at non-singleton dimension 2

    opened by sunxxxxx 2
  • a minor bug

    a minor bug

    An interesting work. A minor bug was found in the implementation of phi_diff which did not follow the equation 6 of original paper. phi_x = torch.tanh((x - (torch.floor(x) + 0.5)) * k) * s

    opened by Shuaiwu 2
  • size of image

    size of image

    Hi, I run your code and save the adversarial and original images. But I found that the size of adversarial image(such as 12.5KB) is bigger than original images(such as 12.4KB), is it reasonable? Then I calculated the type of color of adversarial and original images, the adversarial image has more colors than original image. It seems violating the article.

    opened by shuangerwaiwai 1
  • Questions about the paper

    Questions about the paper

    Hi, thanks for your interesting work! I have two questions about the paper.

    1. It seems that you borrow the pipeline of JPEG compressor, which aims to compress the image without much quality degradation. From your paper, AdvDrop applies DCT and other operations in 'RGB' space while JPEG does image compression on 'YCbCr' space. Am I right? If I am right, why do not you do information drop in 'YCbCr' space? what is the difference?
    2. In your code, you use torch.floor( ) to process the quantized block which is inconsistent with the Figure 5. Do you think the torch.floor() should be replaced by torch.round() or have you tried torch.round() before?
    opened by wangtingwei1993 1
  • Quantization table - initialization and update

    Quantization table - initialization and update

    Hi @RjDuan Thank you for excellent work. I have a question regarding initialization and update of Q-table.

    (1) In paper, you have mentioned that Q-table is initialized with value of 1 and values are gradually increased during optimization (reference line: after Eq-1 in the paper).

    However, in the code Q-table is being initialized with a user-provided value e.g. 40 https://github.com/RjDuan/AdvDrop/blob/35ceeb0e1c4b258bf3995302fbce9f13b39860f0/infod_sample.py#L52


    (2) Eq-7 in the paper states that q is updated as follows: $\quad q^{'} = q + \text{sign}(\nabla_{q} \mathcal{L}(x^{'},y))\quad \text{s.t.}\quad||q^{'}-q_{\text{init}}||_{\infty} < \epsilon$

    Could you explain if Eq-7 corresponds correctly to the relevant part of the code: https://github.com/RjDuan/AdvDrop/blob/35ceeb0e1c4b258bf3995302fbce9f13b39860f0/infod_sample.py#L108-L110

    I have noted following perceived inconsistencies: a) Negative sign is being used in the update of q-table in code, while Eq-7 uses + sign. b) Eq-7 with $\ell_{\infty}$ norm suggests that maximum allowable difference in q-table is $\epsilon$ or $\mathrm{q_size}$ i.e. $\mathrm{max}(q^{'}-\mathrm{q_size}) \le \epsilon$, however, code part just keeps each entry of updated q-table in the range of [5, q_size] i.e. $\quad 5 \le q^{'} \le \mathrm{q_size}$

    Could you help me clear the above mentioned confusions. Thank you!

    opened by asif-hanif 0
Owner
Ranjie Duan
Ranjie Duan
code for ICCV 2021 paper 'Generalized Source-free Domain Adaptation'

G-SFDA Code (based on pytorch 1.3) for our ICCV 2021 paper 'Generalized Source-free Domain Adaptation'. [project] [paper]. Dataset preparing Download

Shiqi Yang 84 Dec 26, 2022
Code for ICCV 2021 paper: ARAPReg: An As-Rigid-As Possible Regularization Loss for Learning Deformable Shape Generators..

ARAPReg Code for ICCV 2021 paper: ARAPReg: An As-Rigid-As Possible Regularization Loss for Learning Deformable Shape Generators.. Installation The cod

Bo Sun 132 Nov 28, 2022
Code for the ICCV 2021 paper "Pixel Difference Networks for Efficient Edge Detection" (Oral).

Pixel Difference Convolution This repository contains the PyTorch implementation for "Pixel Difference Networks for Efficient Edge Detection" by Zhuo

Alex 236 Dec 21, 2022
Sync2Gen Code for ICCV 2021 paper: Scene Synthesis via Uncertainty-Driven Attribute Synchronization

Sync2Gen Code for ICCV 2021 paper: Scene Synthesis via Uncertainty-Driven Attribute Synchronization 0. Environment Environment: python 3.6 and cuda 10

Haitao Yang 62 Dec 30, 2022
[ICCV 2021] Released code for Causal Attention for Unbiased Visual Recognition

CaaM This repo contains the codes of training our CaaM on NICO/ImageNet9 dataset. Due to my recent limited bandwidth, this codebase is still messy, wh

Wang Tan 66 Dec 31, 2022
Code Release for ICCV 2021 (oral), "AdaFit: Rethinking Learning-based Normal Estimation on Point Clouds"

AdaFit: Rethinking Learning-based Normal Estimation on Point Clouds (ICCV 2021 oral) **Project Page | Arxiv ** Runsong Zhu¹, Yuan Liu², Zhen Dong¹, Te

null 40 Dec 30, 2022
Code for the paper "Spatio-temporal Self-Supervised Representation Learning for 3D Point Clouds" (ICCV 2021)

Spatio-temporal Self-Supervised Representation Learning for 3D Point Clouds This is the official code implementation for the paper "Spatio-temporal Se

Hesper 63 Jan 5, 2023
Official PyTorch code of DeepPanoContext: Panoramic 3D Scene Understanding with Holistic Scene Context Graph and Relation-based Optimization (ICCV 2021 Oral).

DeepPanoContext (DPC) [Project Page (with interactive results)][Paper] DeepPanoContext: Panoramic 3D Scene Understanding with Holistic Scene Context G

Cheng Zhang 66 Nov 16, 2022
Code release for ICCV 2021 paper "Anticipative Video Transformer"

Anticipative Video Transformer Ranked first in the Action Anticipation task of the CVPR 2021 EPIC-Kitchens Challenge! (entry: AVT-FB-UT) [project page

Facebook Research 123 Dec 13, 2022
(ICCV 2021) Official code of "Dressing in Order: Recurrent Person Image Generation for Pose Transfer, Virtual Try-on and Outfit Editing."

Dressing in Order (DiOr) ?? [Paper] ?? [Webpage] ?? [Running this code] The official implementation of "Dressing in Order: Recurrent Person Image Gene

Aiyu Cui 277 Dec 28, 2022
Official code release for ICCV 2021 paper SNARF: Differentiable Forward Skinning for Animating Non-rigid Neural Implicit Shapes.

Official code release for ICCV 2021 paper SNARF: Differentiable Forward Skinning for Animating Non-rigid Neural Implicit Shapes.

null 235 Dec 26, 2022
Demo code for ICCV 2021 paper "Sensor-Guided Optical Flow"

Sensor-Guided Optical Flow Demo code for "Sensor-Guided Optical Flow", ICCV 2021 This code is provided to replicate results with flow hints obtained f

null 10 Mar 16, 2022
Code for 'Single Image 3D Shape Retrieval via Cross-Modal Instance and Category Contrastive Learning', ICCV 2021

CMIC-Retrieval Code for Single Image 3D Shape Retrieval via Cross-Modal Instance and Category Contrastive Learning. ICCV 2021. Introduction In this wo

null 42 Nov 17, 2022
Code for ICCV 2021 paper "HuMoR: 3D Human Motion Model for Robust Pose Estimation"

Code for ICCV 2021 paper "HuMoR: 3D Human Motion Model for Robust Pose Estimation"

Davis Rempe 367 Dec 24, 2022
Code for the ICCV 2021 Workshop paper: A Unified Efficient Pyramid Transformer for Semantic Segmentation.

Unified-EPT Code for the ICCV 2021 Workshop paper: A Unified Efficient Pyramid Transformer for Semantic Segmentation. Installation Linux, CUDA>=10.0,

null 29 Aug 23, 2022
Official code release for "Learned Spatial Representations for Few-shot Talking-Head Synthesis" ICCV 2021

Official code release for "Learned Spatial Representations for Few-shot Talking-Head Synthesis" ICCV 2021

Moustafa Meshry 16 Oct 5, 2022
Tracking code for the winner of track 1 in the MMP-Tracking Challenge at ICCV 2021 Workshop.

Tracking Code for the winner of track1 in MMP-Trakcing challenge This repository contains our tracking code for the Multi-camera Multiple People Track

DamoCV 29 Nov 13, 2022
Starter code for the ICCV 2021 paper, 'Detecting Invisible People'

Detecting Invisible People [ICCV 2021 Paper] [Website] Tarasha Khurana, Achal Dave, Deva Ramanan Introduction This repository contains code for Detect

Tarasha Khurana 28 Sep 16, 2022
Official pytorch code for SSC-GAN: Semi-Supervised Single-Stage Controllable GANs for Conditional Fine-Grained Image Generation(ICCV 2021)

SSC-GAN_repo Pytorch implementation for 'Semi-Supervised Single-Stage Controllable GANs for Conditional Fine-Grained Image Generation'.PDF SSC-GAN:Sem

tyty 4 Aug 28, 2022