Skip to content

Commit b5abf25

Browse files
authored
Merge pull request #86 from BloodAxe/develop
Release 0.6.1
2 parents c831072 + 546817e commit b5abf25

File tree

7 files changed

+38
-24
lines changed

7 files changed

+38
-24
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
operating-system: [ubuntu-latest, windows-latest, macos-latest]
11-
python-version: [3.6, 3.7, 3.8, 3.9]
11+
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
1212
pytorch-toolbelt-version: [tests]
1313
fail-fast: false
1414
steps:
@@ -20,16 +20,8 @@ jobs:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Update pip
2222
run: python -m pip install --upgrade pip
23-
- name: Install PyTorch on Linux and Windows
24-
if: >
25-
matrix.operating-system == 'ubuntu-latest' ||
26-
matrix.operating-system == 'windows-latest'
27-
run: >
28-
pip install torch==1.10.1+cpu torchvision==0.11.2+cpu
29-
-f https://download.pytorch.org/whl/torch_stable.html
30-
- name: Install PyTorch on MacOS
31-
if: matrix.operating-system == 'macos-latest'
32-
run: pip install torch==1.10.1 torchvision==0.11.2
23+
- name: Install PyTorch
24+
run: pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
3325
- name: Install dependencies
3426
run: pip install .[${{ matrix.pytorch-toolbelt-version }}]
3527
- name: Install linters
@@ -48,7 +40,7 @@ jobs:
4840
runs-on: ubuntu-latest
4941
strategy:
5042
matrix:
51-
python-version: [3.8, 3.9]
43+
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
5244
steps:
5345
- name: Checkout
5446
uses: actions/checkout@v2

pytorch_toolbelt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from __future__ import absolute_import
22

3-
__version__ = "0.6.0"
3+
__version__ = "0.6.1"

pytorch_toolbelt/datasets/mean_std.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def accumulate(self, image: np.ndarray, mask: Optional[np.ndarray] = None) -> No
5151
image = image.reshape((-1, self.num_channels))
5252

5353
if mask is not None:
54-
mask = mask.reshape((mask.shape[0] * mask.shape[1], 1))
55-
image = image[mask]
54+
mask = mask.reshape((mask.shape[0] * mask.shape[1]))
55+
image = image[mask, :]
5656

5757
# In case the whole image is masked out, we exclude it entirely
5858
if len(image) == 0:

pytorch_toolbelt/utils/torch_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,11 @@ def describe_outputs(outputs: Union[Tensor, Dict[str, Tensor], Iterable[Tensor]]
311311
"""
312312
if torch.is_tensor(outputs):
313313
desc = dict(size=tuple(outputs.size()), mean=outputs.mean().item(), std=outputs.std().item())
314-
elif isinstance(outputs, collections.Mapping):
314+
elif isinstance(outputs, collections.abc.Mapping):
315315
desc = {}
316316
for key, value in outputs.items():
317317
desc[key] = describe_outputs(value)
318-
elif isinstance(outputs, collections.Iterable):
318+
elif isinstance(outputs, collections.abc.Iterable):
319319
desc = []
320320
for index, output in enumerate(outputs):
321321
desc.append(describe_outputs(output))

setup.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66

77
from setuptools import find_packages, setup
8+
from distutils.version import LooseVersion
89

910

1011
def is_docker() -> bool:
@@ -88,9 +89,9 @@ def get_opencv_requirement():
8889

8990
DEPENDENCIES = [
9091
# We rely on particular activation functions that were added in 1.8.1
91-
"torch>=1.8.1",
92+
"torch>=1.11.0" if LooseVersion(sys.version) >= LooseVersion("3.7") else "torch>=1.10.0",
9293
# We use some pretrained models from torchvision
93-
"torchvision>=0.9.1",
94+
"torchvision",
9495
# Library uses scipy for linear_sum_assignment for match_bboxes.
9596
# 1.4.0 is the first release where `maximize` argument gets introduced to this function
9697
"scipy>=1.4.0",
@@ -116,9 +117,7 @@ def load_readme():
116117

117118

118119
def get_test_requirements():
119-
requirements = ["pytest", "onnx==1.9.0", "black==22.8.0", "timm==0.6.7", "matplotlib"]
120-
if sys.version_info < (3, 3):
121-
requirements.append("mock")
120+
requirements = ["pytest", "black==22.8.0", "timm==0.6.7", "matplotlib"]
122121
return requirements
123122

124123

@@ -147,6 +146,10 @@ def get_test_requirements():
147146
"Unet",
148147
"Focal",
149148
"FPN",
149+
"EfficientNet",
150+
"Test-Time Augmentation",
151+
"Model Ensembling",
152+
"Model Surgery",
150153
],
151154
scripts=[],
152155
license="License :: OSI Approved :: MIT License",
@@ -158,9 +161,14 @@ def get_test_requirements():
158161
"Programming Language :: Python :: 3",
159162
"Programming Language :: Python :: 3.6",
160163
"Programming Language :: Python :: 3.7",
164+
"Programming Language :: Python :: 3.8",
165+
"Programming Language :: Python :: 3.9",
166+
"Programming Language :: Python :: 3.10",
161167
"Operating System :: OS Independent",
162168
"Topic :: Scientific/Engineering :: Mathematics",
163169
"Topic :: Scientific/Engineering :: Image Recognition",
170+
"Topic :: Scientific/Engineering :: Deep Learning",
171+
"Topic :: Scientific/Engineering :: Computer Vision",
164172
"Topic :: Scientific/Engineering :: Artificial Intelligence",
165173
"Topic :: Software Development :: Libraries",
166174
"Topic :: Software Development :: Libraries :: Python Modules",

tests/test_encoders.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytorch_toolbelt.modules.encoders as E
55
from pytorch_toolbelt.modules.backbone.inceptionv4 import inceptionv4
6-
from pytorch_toolbelt.utils.torch_utils import maybe_cuda, count_parameters
6+
from pytorch_toolbelt.utils.torch_utils import maybe_cuda, count_parameters, describe_outputs
77
from pytorch_toolbelt.modules.encoders import timm
88

99
skip_if_no_cuda = pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA is not available")
@@ -249,6 +249,8 @@ def test_timm_encoders(encoder, encoder_params):
249249
assert feature_map.size(2) * expected_stride == x.size(2)
250250
assert feature_map.size(3) * expected_stride == x.size(3)
251251

252+
print(describe_outputs(output))
253+
252254

253255
@pytest.mark.parametrize(
254256
["encoder", "encoder_params"],

tests/test_onnx.py renamed to tests/test_model_export.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66
from pytorch_toolbelt.utils.torch_utils import maybe_cuda, count_parameters
77
from pytorch_toolbelt.modules.encoders import timm
88

9-
skip_if_no_cuda = pytest.mark.skipif(not torch.cuda.is_available(), reason="Cuda is not available")
9+
10+
def is_onnx_available():
11+
try:
12+
import onnx
13+
14+
return True
15+
except ImportError:
16+
return False
17+
18+
19+
skip_if_no_cuda = pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA is not available")
20+
skip_if_no_onnx = pytest.mark.skipif(not is_onnx_available, reason="ONNX is not available")
1021

1122

1223
@pytest.mark.parametrize(
@@ -26,6 +37,7 @@
2637
],
2738
)
2839
@skip_if_no_cuda
40+
@skip_if_no_onnx
2941
def test_onnx_export(encoder, encoder_params):
3042
import onnx
3143

0 commit comments

Comments
 (0)