Comments (5)
Hi @OrsonTyphanel93,
Thanks for bringing this up!
So HuggingFaceClassifierPyTorch will try and perform a forward pass to determine the model structure - something that is often needed for poisoning attacks and defences. To do so a dummy input sample will be created based on the supplied input_shape
. In which case, if the model expects 1D inputs the input_shape
should just be the sequence length: i.e. without any batching.
The code snippet below should work.
What's the motivation in your case which requires the input_shape
to be different compared to the standard Wav2Vec2ForCTC format? Perhaps it is a use-case we have not considered and we can look into supporting it.
model = transformers.AutoModelForAudioClassification.from_pretrained(
'facebook/wav2vec2-base-960h',
ignore_mismatched_sizes=True,
num_labels=2
)
input_values = np.random.normal(size=1000)
_ = HuggingFaceClassifierPyTorch(
model=model,
loss=torch.nn.CrossEntropyLoss(),
optimizer=torch.optim.Adam(model.parameters(), lr=1e-4),
input_shape=input_values.shape,
nb_classes=2,
)
from adversarial-robustness-toolbox.
In my case, for example, I'm using Hugging Face's Wav2Vec2ForCTC template, which expects input in a specific format. However, I'm providing input with a shape (124, 129, 1) that matches my data, which I think is causing the mismatch.
To solve this problem, I guess I need to adjust the shape of the input to match what the model expects. According to the Hugging Face documentation, the Wav2Vec2ForCTC model expects input in the form of (batch_size, sequence_length) I've already tried this but still get the same error.
from adversarial-robustness-toolbox.
Hi guys, thanks! I just had to customize this ART classifier and transpose my data to 3 channels.
@i'll be making the notebook public soon, just reorganize it .... : )
from adversarial-robustness-toolbox.
notebook HugginFace Backdoor link HugginFace Backdoor attack
hi guys @beat-buesser ! here is the final notebook you can now test it with codecov please , i think it has a very fast optimization ,
I've tested it with all the audio models available on HugginFace, and they've all been 'backdoored'! as far as I know, you can keep the classifier as it is. I've customized the classifier in this code so that users who play with audio data won't have any trouble using your classifier.
thanks again guys!
from adversarial-robustness-toolbox.
Thank you very much Dear @GiulioZizzo ! , for your intervention!
Some particular requirements, such as the following, may be the reason for HuggingFaceClassifierPyTorch to specify an alternate input format instead of the normal Wav2Vec2ForCTC format:
Individual audio sequence processing: Rather than combining similar audio sequences, the model might be built to handle each one separately. Applications such as processing audio fragments of varying lengths or real-time speech recognition may benefit from this.
Specific procedures or layers in the model may call for a particular type of 1D input due to its specialized architecture)
from adversarial-robustness-toolbox.
Related Issues (20)
- Incorrect Documentation regarding attacks.poisoning HOT 1
- Auto PGD not working with DLR loss for binary classification HOT 1
- ERROR collecting tests/attacks/evasion/test_brendel_and_bethge.py
- Measured Linf norm exceeds epsilon for ACG HOT 1
- Risky values in tests
- Gradient Explosion
- Robust
- Rr
- adversarial audio example notebook not giving the same results HOT 2
- Unable to utilize PytorchClassifier for ASR model HOT 1
- List of projects/tools utilising ART [JATIC-I4-IBM]
- Attack > Evasion > Momentum Iterative Method: major issues HOT 1
- Package cannot be imported after installing with pip HOT 3
- Deprecated `pkg_resources` raises `DeprecationWarning`s HOT 3
- UserWarning and RuntimeError in ProjectedGradientDescent due to Non-Writable NumPy Array and Device Mismatch HOT 1
- Acknowledged contributor (mistakenly?) removed from `AUTHORS` off-PR HOT 2
- KerasClassifier not compatible with latest versions of Keras and TensorFlow HOT 2
- Yolox Integration
- Semantic version checking in some modules/tests do not account for epoch, pre/post-release, or development release segments HOT 1
- float type mismatch
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 adversarial-robustness-toolbox.