Comments (5)
-
train_mode == 'batch'
won't modify dataset, it's attaching the trigger on demand duringget_data
by callingadd_mark
method
Related codes:trojanzoo/trojanvision/attacks/abstract.py
Lines 114 to 132 in d5085fd
-
When
train_mode == 'batch'
, callingadd_mark(_input)
(where_input
is the clean batch image) shall return the entire image with the trigger.If you want to access the trigger image only, you need to view
attack.mark.mark
, which is a [4, H, W] tensor and the last channel is the transparency following RGBA color channel standard.
Related docs: https://ain-soph.github.io/trojanzoo/trojanvision/marks.html#trojanvision.marks.WatermarkYou also mentioned calling
add_mark
will only return image contain the trigger. I'm confused why it is the case. Please show a brief snippet and its running results. A possible reason might be your trigger size is 32*32, which is the same as image size and it overwrites all pixels. -
When
train_mode == 'dataset'
, there will be a new property calledpoison_set
.
Related codes:
trojanzoo/trojanvision/attacks/abstract.py
Line 106 in d5085fd
Related docs:
https://ain-soph.github.io/trojanzoo/trojanvision/attacks/index.html#trojanvision.attacks.BackdoorAttack
![image](https://private-user-images.githubusercontent.com/13214530/279524237-854021cf-89f0-497e-82f8-629322d81dd2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE1MTYyMjAsIm5iZiI6MTcyMTUxNTkyMCwicGF0aCI6Ii8xMzIxNDUzMC8yNzk1MjQyMzctODU0MDIxY2YtODlmMC00OTdlLTgyZjgtNjI5MzIyZDgxZGQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIwVDIyNTIwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY4OThhYmM3ZWMxMTA0MDRmZWI5MTEwMTgxN2FjY2U5NGI1MTgyODlhYThkOTY3MTI3ZGM0NGIyYmMwOWRkOTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.FG7CecT3OXZkrvCZwrMwiTVVgoh1vns6yGpIdzIpfjg)
from trojanzoo.
Btw, just a trick, using torchvision.utils.save_image(backdoored_img, "trigger_img.jpg")
is easier than plt.imsave("trigger_img.jpg", backdoored_img.cpu().numpy())
from trojanzoo.
This doesn't seem to be a trigger either. I think plt.imsave
requires HWC rather than CHW order (not sure, never use it).
So you might only output 3-pixel width somehow.
from trojanzoo.
Thank you for your quick response! :)
I tried it again with train_mode == 'dataset'
and it worked
For train_mode == 'batch'
:
I tried using torchvision.utils.save_image(backdoored_img, "trigger_img.jpg")
instead of plt.imsave
and everything worked fine! The "trigger_img" contained the images with the trigger attached.
So the issue seems to be only related to plt.imsave
.
This is how "trigger_img" looks like if I use plt.imsave
:
from trojanzoo.
I guess your problem has been solved in previous discussion. I'll close this issue. Feel free to re-open if there is still any problem related to this issue.
from trojanzoo.
Related Issues (20)
- BackdoorAttack class has no argument for source_class HOT 1
- Low effective loading in get_class_subset function HOT 1
- Install newest version fail HOT 1
- Using a custom model HOT 4
- RuntimeError: Dataset not found or corrupted. You can use download=True to download it HOT 10
- Clean label attack accuracy is wrong HOT 5
- In new push model path is not working HOT 1
- badnet folder information HOT 1
- [Error] When I test Neural Cleanse i got a error HOT 2
- Is it possible to apply methods to graph? HOT 6
- Input aware dynamic backdoor error HOT 5
- trojanvision.datasets.ImageFolder HOT 1
- Possible bug: target_class not changed when computing ASR for reversed triggers HOT 2
- problem about saving the intermediate results and config problem HOT 6
- strange mark saved HOT 2
- Hyperparameters for training Resnet18 on CIFAR10? HOT 1
- STRIP implementation doesn't match original codebase HOT 1
- Attack saving and loading is not working HOT 2
- Comp version of networks HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trojanzoo.