Skip to content

Commit 96285f1

Browse files
authored
Merge pull request #1529 from twosixlabs/develop
Version 0.15.1 PR
2 parents 744875d + 30b4e7d commit 96285f1

File tree

121 files changed

+6057
-2203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+6057
-2203
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@v2
3434
with:
35+
fetch-depth: 0
3536
ref: ${{ github.event.client_payload.branch }}
3637
- uses: actions/setup-python@v1
3738
with:
3839
python-version: '3.7'
3940
- name: Build and release docker images
4041
run: |
4142
rm -rf /usr/share/dotnet &
42-
python -m pip install -r requirements.txt
43-
version=$(python -c "import armory; print(armory.__version__)")
43+
pip install -r requirements.txt
44+
version=$(python -m armory --version)
4445
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
4546
docker pull twosixarmory/tf2:latest
4647
python docker/build.py tf2
@@ -54,15 +55,16 @@ jobs:
5455
steps:
5556
- uses: actions/checkout@v2
5657
with:
58+
fetch-depth: 0
5759
ref: ${{ github.event.client_payload.branch }}
5860
- uses: actions/setup-python@v1
5961
with:
6062
python-version: '3.7'
6163
- name: Build and release docker images
6264
run: |
6365
rm -rf /usr/share/dotnet &
64-
python -m pip install -r requirements.txt
65-
version=$(python -c "import armory; print(armory.__version__)")
66+
pip install -r requirements.txt
67+
version=$(python -m armory --version)
6668
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
6769
docker pull twosixarmory/pytorch:latest
6870
python docker/build.py pytorch
@@ -76,15 +78,16 @@ jobs:
7678
steps:
7779
- uses: actions/checkout@v2
7880
with:
81+
fetch-depth: 0
7982
ref: ${{ github.event.client_payload.branch }}
8083
- uses: actions/setup-python@v1
8184
with:
8285
python-version: '3.7'
8386
- name: Build and release docker images
8487
run: |
8588
rm -rf /usr/share/dotnet &
86-
python -m pip install -r requirements.txt
87-
version=$(python -c "import armory; print(armory.__version__)")
89+
pip install -r requirements.txt
90+
version=$(python -m armory --version)
8891
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
8992
docker pull twosixarmory/pytorch-deepspeech:latest
9093
python docker/build.py pytorch-deepspeech

armory-base-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ scipy==1.7.*
3434
matplotlib==3.*
3535

3636
# ART
37-
adversarial-robustness-toolbox==1.10.0
37+
adversarial-robustness-toolbox==1.10.2
3838

3939
# Data dependencies
4040
Pillow==9.0.*

armory/__init__.py

Lines changed: 8 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,20 @@
1-
"""Adversarial Robustness Evaluation Test Bed
2-
3-
ARMORY Versions use "Semantic Version" scheme where stable releases will have versions
4-
like `0.14.6`. Armory uses `setuptools_scm` which pulls the version from the tags most
5-
recent git tag. For example if the most recent git tag is `v0.14.6`, then the version
6-
will be `0.14.6`.
7-
8-
If you are a developer, the version will be constructed from the most recent tag plus a
9-
suffix of gHASH where HASH is the short hash of the most recent commit. For example,
10-
if the most recent git tag is v0.14.6 and the most recent commit hash is 1234567 then
11-
the version will be 0.14.6.g1234567. This scheme does differ from the scm strings
12-
which also have a commit count and date in them like 1.0.1.dev2+g0c5ffd9.d20220314181920
13-
which is a bit ungainly.
1+
"""
2+
Adversarial Robustness Evaluation Test Bed
143
"""
154

16-
try:
17-
from importlib.metadata import version, PackageNotFoundError
18-
except ModuleNotFoundError:
19-
from importlib_metadata import version, PackageNotFoundError
20-
21-
import pathlib
22-
import re
23-
import sys
24-
import subprocess
5+
from typing import Dict, Any
256

267
from armory.logs import log
8+
from armory.version import get_version
279

2810

29-
def get_dynamic_version():
30-
"""
31-
Produce the version dynamically from setup.py if available.
32-
33-
Return None if setup.py is not available
34-
"""
35-
armory_repo_root = pathlib.Path(__file__).parent.parent
36-
setup = armory_repo_root / "setup.py"
37-
if not setup.is_file():
38-
return None
39-
40-
completed = subprocess.run(
41-
["python", str(setup), "--version"],
42-
cwd=str(armory_repo_root),
43-
capture_output=True,
44-
text=True,
45-
)
46-
try:
47-
completed.check_returncode()
48-
except subprocess.CalledProcessError:
49-
log.critical("setup.py exists but 'python setup.py --version' failed.")
50-
raise
51-
version = completed.stdout.strip()
52-
return version
53-
54-
55-
__version__ = get_dynamic_version()
56-
if __version__ is None:
57-
try:
58-
__version__ = version("armory-testbed")
59-
except PackageNotFoundError:
60-
log.critical("armory package is not pip installed and not locally cloned")
61-
raise
62-
__version__ = re.sub(r"dev\d+\+(g[0-9a-f]+)(\.d\d+)?$", r"\1", __version__)
63-
11+
def __getattr__(name):
12+
if name == "__version__":
13+
return get_version()
14+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
6415

65-
# If just querying version, stop and exit
66-
if (
67-
len(sys.argv) == 2
68-
and (sys.argv[0] == "-m" or pathlib.Path(sys.argv[0]).stem == "armory")
69-
and sys.argv[1] in ("-v", "--version", "version")
70-
):
71-
print(f"{__version__}")
72-
sys.exit(0)
73-
74-
# Handle PyTorch / TensorFlow interplay
75-
76-
# import torch before tensorflow to ensure torch.utils.data.DataLoader can utilize
77-
# all CPU resources when num_workers > 1
78-
try:
79-
import torch # noqa: F401
80-
except ImportError:
81-
pass
82-
83-
# From: https://www.tensorflow.org/guide/gpu#limiting_gpu_memory_growth
84-
try:
85-
import tensorflow as tf
86-
87-
gpus = tf.config.list_physical_devices("GPU")
88-
if gpus:
89-
# Currently, memory growth needs to be the same across GPUs
90-
for gpu in gpus:
91-
tf.config.experimental.set_memory_growth(gpu, True)
92-
log.info("Setting tf.config.experimental.set_memory_growth to True on all GPUs")
93-
except RuntimeError:
94-
log.exception("Import armory before initializing GPU tensors")
95-
raise
96-
except ImportError:
97-
pass
98-
99-
# Handle ART configuration
100-
101-
from armory import paths
102-
103-
try:
104-
paths.set_art_data_path()
105-
except OSError:
106-
# If running in --no-docker mode, catch write error based on default DockerPaths
107-
# the later call to paths.set_mode("host") will set this properly
108-
pass
10916

11017
# typedef for a widely used JSON-like configuration specification
111-
from typing import Dict, Any
112-
11318
Config = Dict[str, Any]
11419

115-
# Submodule imports
116-
try:
117-
from armory import art_experimental
118-
from armory import baseline_models
119-
from armory import data
120-
from armory import docker
121-
from armory import eval
122-
from armory import paths
123-
from armory import utils
124-
from armory import webapi
125-
except ImportError as e:
126-
module = e.name
127-
print(f"ERROR: cannot import '{module}' module")
128-
print(" Please run: $ pip install -r requirements.txt")
129-
raise
130-
13120
END_SENTINEL = "Scenario has finished running cleanly"

armory/art_experimental/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
This subpackage will contain experimental ART features that are not merged into
33
the PyPi package.
44
"""
5+
from armory import delayed_imports

armory/art_experimental/attacks/carla_adversarial_texture.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,20 @@ def generate(self, x, y, y_patch_metadata=None, **kwargs):
213213

214214
# green screen coordinates used for placement of a rectangular patch
215215
gs_coords = y_patch_metadata[0]["gs_coords"]
216-
patch_width = int(np.max(gs_coords[:, 0]) - np.min(gs_coords[:, 0]))
217-
patch_height = int(np.max(gs_coords[:, 1]) - np.min(gs_coords[:, 1]))
218-
219-
x_min = int(np.min(gs_coords[:, 1]))
220-
y_min = int(np.min(gs_coords[:, 0]))
216+
if gs_coords.ndim == 2: # same location for all frames
217+
patch_width = int(np.max(gs_coords[:, 0]) - np.min(gs_coords[:, 0]))
218+
patch_height = int(np.max(gs_coords[:, 1]) - np.min(gs_coords[:, 1]))
219+
else:
220+
patch_widths = []
221+
patch_heights = []
222+
for coords in gs_coords:
223+
patch_widths.append(int(np.max(coords[:, 0]) - np.min(coords[:, 0])))
224+
patch_heights.append(int(np.max(coords[:, 1]) - np.min(coords[:, 1])))
225+
patch_width = max(patch_widths)
226+
patch_height = max(patch_heights)
221227

222228
self.patch_height = patch_height
223229
self.patch_width = patch_width
224-
self.x_min = x_min
225-
self.y_min = y_min
226230

227231
# reinitialize patch
228232
self.patch_shape = (patch_height, patch_width, 3)

0 commit comments

Comments
 (0)