Skip to content

Commit 02ef0e6

Browse files
authored
Feature/torchvision 0.3 (#16)(#25)
Fix vgg.config import Update requirements Update tests
1 parent 3e9b263 commit 02ef0e6

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

.travis.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ python:
55
stages:
66
- test
77

8-
install:
8+
before_install:
99

1010
- sudo apt-get update
1111
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
@@ -14,19 +14,21 @@ install:
1414
- hash -r
1515
- conda config --set always_yes yes --set changeps1 no
1616
- conda update -q conda
17+
- conda info -a
1718

1819
# Useful for debugging any issues with conda
1920
- conda info -a
20-
- conda create -q -n test-environment -c pytorch python=$TRAVIS_PYTHON_VERSION numpy mock pytorch-cpu
21-
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install enum34; fi
21+
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pytorch-cpu scipy -c pytorch
22+
# - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install enum34; fi
2223
- source activate test-environment
2324

24-
# Dependencies
25-
- pip install -r requirements.txt
25+
- pip install future
26+
- pip install pytest pytest-cov codecov
27+
- pip install mock
2628

27-
# Package
28-
- python setup.py install
29-
- pip install --upgrade pytest #codecov pytest-cov
29+
install:
30+
31+
- pip install .
3032

3133
script:
3234
- python -m pytest -s tests

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
torchvision==0.2.2
1+
torchvision>=0.2.2
22
pretrainedmodels==0.7.4
3-
torchnet==0.0.4
3+
torchnet==0.0.4

segmentation_models_pytorch/encoders/vgg.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import torch.nn as nn
22
from torchvision.models.vgg import VGG
33
from torchvision.models.vgg import make_layers
4-
from torchvision.models.vgg import cfg
54
from pretrainedmodels.models.torchvision_models import pretrained_settings
65

76

7+
cfg = {
8+
'A': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
9+
'B': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
10+
'D': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512, 'M', 512, 512, 512, 'M'],
11+
'E': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 512, 512, 512, 512, 'M', 512, 512, 512, 512, 'M'],
12+
}
13+
14+
815
class VGGEncoder(VGG):
916

1017
def __init__(self, config, batch_norm=False, *args, **kwargs):

tests/test_models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import os
2+
import sys
3+
import mock
24
import pytest
35
import torch
46
import random
57

8+
# mock detection module
9+
sys.modules['torchvision._C'] = mock.Mock()
10+
611
import segmentation_models_pytorch as smp
712

813

tests/test_preprocessing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import os
2+
import sys
3+
import mock
24
import pytest
35
import numpy as np
46

7+
# mock detection module
8+
sys.modules['torchvision._C'] = mock.Mock()
9+
510
import segmentation_models_pytorch as smp
611

712

0 commit comments

Comments
 (0)