Git Product home page Git Product logo

segmentshards's Introduction

Segment Shards

This repository is the official implementation of Segment Shards: Prompt Batch Adversarial Attack to Segment Anything Model.

Requirements

To install requirements:

pip install -r requirements.txt

env : Ubuntu 18.04 python 3.8 Pytorch 1.8.1+cu111

Attacking

To generate the adversarial example(s) in the paper, run this command:

  • PBA

    python attack_pba.py --config config/PBA/Apollo_10_816b.yaml
  • SPA

    python attack.py --config config/SPA/Apollo_10_816b.yaml
  • PA

    python attack.py --config config/PA/Apollo_10_864b.yaml
  • NPA

    python attack_npa.py --config config/NPA/Apollo_10_816b.yaml

ps. You can use the config file to change the detial of attacking

Evaluation

To evaluate the adversarial examples generated, run:

# calculate miou
python eval_miou.py --config config/PBA/eval_Apollo_10_816b_816b.yaml
# calculate ssim
python eval_ssim.py --config config/PBA/Apollo_10_816b.yaml

the output of evaluation is a file named *.csv

Pre-trained Models

You can download pretrained models here:

Then, put them into checkpoints directory, your project tree may like:

<root of code>
├── checkpoints
│   ├── sam_vit_b01ec64.pth
│   └── sam_vit_h_4b8939.pth
├── add_permutations.ipynb
├── attack_pba.py
├── attack_npa.py
├── attack.py
|...

Download Datasets

You can download datasets from Apollo Dataset link, BDD100k Dataset link, CBCL Dataset link.

You can put these data in advDataset directory. Your project tree may like:

<root of code>
├── checkpoints
│   ├── sam_vit_b01ec64.pth
│   └── sam_vit_h_4b8939.pth
├── advDataset
│   ├── advApollo
│   |   └──...
│   └── advBDD
│       └──...
├── add_permutations.ipynb
├── attack_pba.py
├── attack_npa.py
├── attack.py
|...

Contributing

The Segment Shards project was made with the help of Segment Anything project.

segmentshards's People

Contributors

fffqh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.