Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio echo #1030

Merged
merged 5 commits into from
Mar 25, 2021
Merged

Audio echo #1030

merged 5 commits into from
Mar 25, 2021

Conversation

davidslater
Copy link
Contributor

@davidslater davidslater commented Mar 25, 2021

Fixes #1016

I'm running into issues in a couple of places outside my code:

  1. When running on art 1.6.0, I can't instantiate the PyTorchDeepSpeech class:
>>> from art.estimators.speech_recognition import PyTorchDeepSpeech
>>> PyTorchDeepSpeech()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can't instantiate abstract class PyTorchDeepSpeech with abstract methods compute_loss
>>> import art
>>> art.__version__
'1.6.0'
  1. When running on art 1.5.3, I run into this error when the attack is run (benign works fine):
Attack:   0%|                                                                                                                                                  | 0/1 [00:00<?, ?it/s]
2021-03-25 00:34:53 a4b546f3d365 armory.scenarios.base[2547] ERROR Encountered error during scenario evaluation.
Traceback (most recent call last):
  File "/workspace/armory/scenarios/base.py", line 84, in evaluate
    config, num_eval_batches, skip_benign, skip_attack, skip_misclassified
  File "/workspace/armory/scenarios/audio_asr.py", line 236, in _evaluate
    x_adv = attack.generate(x=x, y=y_target)
  File "/workspace/art/attacks/attack.py", line 74, in replacement_function
    return fdict[func_name](self, *args, **kwargs)
  File "/workspace/art/attacks/evasion/fast_gradient.py", line 279, in generate
    adv_x_best = self._compute(x, x, y, None, self.eps, self.eps, self._project, self.num_random_init > 0,)
  File "/workspace/art/attacks/evasion/fast_gradient.py", line 431, in _compute
    perturbation = self._compute_perturbation(batch, batch_labels, mask_batch)
  File "/workspace/art/attacks/evasion/fast_gradient.py", line 342, in _compute_perturbation
    grad = self.estimator.loss_gradient(batch, batch_labels) * (1 - 2 * int(self.targeted))
  File "/workspace/art/estimators/speech_recognition/pytorch_deep_speech.py", line 370, in loss_gradient
    from warpctc_pytorch import CTCLoss
  File "/opt/conda/lib/python3.7/site-packages/warpctc_pytorch/__init__.py", line 6, in <module>
    from ._warp_ctc import *  # noqa
ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory
  1. The ASR model seems to ignore the preprocessing and preprocessing_defenses, so the channel never gets called. (This is running on 1.5.3).

@davidslater
Copy link
Contributor Author

davidslater commented Mar 25, 2021

I think I solved the preprocessing_defences thing:

classifier._update_preprocessing_operations() was needed - I think this is a broader bug.

@lcadalzo
Copy link
Contributor

@davidslater I assume the ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory error still persists for you? It looks like warp_ctc requires cuda 10.* (or less), so I think we might need to revert the pytorch-deepspeech image to cuda 10.

The available versions of warp_ctc for PyTorch 1.6: 0.2.1+torch16.cpu, 0.2.1+torch16.cuda100, 0.2.1+torch16.cuda101, 0.2.1+torch16.cuda102, 0.2.1+torch16.cuda92

@lcadalzo
Copy link
Contributor

If we want to get past TypeError: Can't instantiate abstract class PyTorchDeepSpeech with abstract methods compute_loss without waiting for an ART patch, we could modify the baseline model to something like:

class PyTorchDeepSpeechModel(PyTorchDeepSpeech):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def compute_loss(self):
        raise NotImplementedError


def get_art_model(
    model_kwargs: dict, wrapper_kwargs: dict, weights_path: Optional[str] = None
) -> PyTorchDeepSpeech:
    return PyTorchDeepSpeechModel(**wrapper_kwargs)

@lcadalzo
Copy link
Contributor

Are some of the logger.error() calls there for debugging purposes? Should they be removed?

Copy link
Contributor

@lcadalzo lcadalzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lcadalzo lcadalzo merged commit 1ad288d into twosixlabs:dev Mar 25, 2021
lcadalzo added a commit that referenced this pull request Mar 25, 2021
* Run CI tests on PRs/commits to dev (#1000)

* add indexing to datasets (#1003)

* kwargs

* update slicing

* update data loader

* add tests

* neal change

* Docker updates (#1008)

* added object detection metrics

* WIP: update docker dependencies (#1006)

* updating docker dependencies

* removing poisoning images

* update deepspeech image dependencies

* update host-requirements.txt

* removing poisoning images from release.yml

* add coloredlogs

* update ART pip install command

* remove accidental new line character

* Docker build simplification (#1017)

* remove -dev

* update

* docker build

* distribute docker containers

* update dockerfiles and github workflows

* update docs

* add pytorch-deepspeech to images

* add dev tag

* update release

* update error handling

* remove comment

* remove unneeded command

* tool to update versions

* removing calls to ART's set_learning_phase()

* updating image version

* formatting

* apricot skip (#1020)

Co-authored-by: davidslater <david.slater@twosixlabs.com>

* Fix missing validation folder in whl (#972)

* Fix missing validation folder in whl

* Automatically find test folder relative to armory installation

* Ignore pytest cache warning

* Fix import, add warning filter

* Disable test caching

* skip misclassified examples (#1005)

* added object detection metrics

* adding proof of concept

* black formatting

* move cli/config check to base scenario before _evaluate()

* refactor image_classification skip_misclassified

* update __main__ with skip-misclassified

* record_metric_per_sample doesn't need to be true

* add skip_misclassified to so2sat scenario

* adding skip_misclassified to scenarios where it shouldnt be used

* add skip_misclassified to video

* minor refactor of audio_classification plus adding in skip_misclassified

* docs for skip-misclassified

* Filter by class (#1019)

* added object detection metrics

* adding ability to filter by class; also modified error messages for filter_by_index()

* flake8

* fix new test

* updated docs

* update warning logic for filter_by_index

* add warning if filtering by class and using train split

* fix filter by class dset test

* Micronnet model using pytorch sequential api (#1023)

* Sequential API Pytorch version of MicronNet

* Fix pytest

* unify sysconfig and command line directives (#1027)

* merge sysconfig and command arguments

* unit test for config merge

arguments.py created because __main__  is not pytest importable
(or at least not easily)

additional args like filepath get added to sysconfig, I don't know
if that's a bad thing

* code correct but the test was wrong

* flake8 compliance

* args merge documented

* collapse loops to comprehensions

* remove obsoleted truth table comment

* add cross-reference to command_line.md

* DAPRICOT integration (#1021)

* initial draft of DAPRICOT dataset

* ran black and flake8'

* updating checksums for now

* add dapricot dataset fn

* refactor preprocessing + setting cache=False temporarily

* add WIP dapricot scenario and config

* update scenario

* add label preprocessing to unify label format with other OD datasets

* added attack skeleton and minor scenario updates

* testing insertion of random patch

* changes necessary for upgrade to ART 1.6

* update config for attack rename

* typo

* use robust dpatch to generate attack

* update dapricot config

* black formatting

* format json

* flake8

* add masked pgd attack for dapricot

* formatting

* adding dapricot utils script

* fix channel order

* return batch in (3, H, W, C) shape

* fixing case when x_key is a tuple

* update model to be compatible with ART 1.6

* dont slice channel dim in reverse

* updated dapricot_dev with access to all three cameras

* minor update

* ran black, flake8

* update dapricot version and add new cached checksum file

* use cached by default

* add metric fn for dapricot

* parse patch shape

* fixes bug that arises bc there are no non-targeted adversarial metrics

* make scenario code more specific to dapricot threat model

* move config checks to before model loading

* update configs with label targeters

* add physical threat model

* removing some patch insertion functionality

* remove unused variable

* adding cv2 and necessary dependencies

* add skip-misclassified to dapricot scenario

* removing outdated dockerfile that isnt used anymore

* updating dockerfiles with opencv

* add DEBIAN_FRONTEND=noninteractive to dockerfiles

* docs and minor modification of attack config params

* no longer need to pin to ART dev branch

* adding dapricot test

* tweak to label preprocessing

* typo in sysconfig

* enforce batch_size 1 earlier; fix dapricot config

* fix typo

* json formatting

* reset patch_location and patch_shape per example

* add opencv to host_requirements.txt

* keep everything (3, H, W, 3)

* add comments to host_requirements.txt re cv2

Co-authored-by: lucas.cadalzo <lucas.cadalzo@twosixlabs.com>

* Audio echo (#1030)

* added logic

* audio channel

* audio channel

* audio fixes

* Dev merge (#1032)

* Bump pillow from 7.1.2 to 8.1.1 (#1024)

Bumps [pillow](https://github.com/python-pillow/Pillow) from 7.1.2 to 8.1.1.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/master/CHANGES.rst)
- [Commits](python-pillow/Pillow@7.1.2...8.1.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump tensorflow-gpu from 1.15.0 to 2.4.0 (#1025)

* Bump tensorflow-gpu from 1.15.0 to 2.4.0

Bumps [tensorflow-gpu](https://github.com/tensorflow/tensorflow) from 1.15.0 to 2.4.0.
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](tensorflow/tensorflow@v1.15.0...v2.4.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Update host-requirements.txt

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: davidslater <david.slater@twosixlabs.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: davidslater <david.slater@twosixlabs.com>

Co-authored-by: ng390 <neal.gupta@twosixlabs.com>
Co-authored-by: lcadalzo <39925313+lcadalzo@users.noreply.github.com>
Co-authored-by: kevinmerchant <67436031+kevinmerchant@users.noreply.github.com>
Co-authored-by: matt wartell <matt.wartell@twosixlabs.com>
Co-authored-by: yusong-tan <59029053+yusong-tan@users.noreply.github.com>
Co-authored-by: lucas.cadalzo <lucas.cadalzo@twosixlabs.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants