File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Python tests
2+
3+ on :
4+ push :
5+ branches : [ master ]
6+ pull_request :
7+ branches : [ master ]
8+
9+ jobs :
10+ test :
11+ name : Run tests on ${{ matrix.os }} with Python ${{ matrix.python }}
12+ strategy :
13+ matrix :
14+ os : [ubuntu-latest, macOS-latest]
15+ python : ['3.8']
16+ torch : ['1.5.0']
17+ torchvision : ['0.6.0']
18+ runs-on : ${{ matrix.os }}
19+
20+ steps :
21+ - uses : actions/checkout@v2
22+ - name : Set up Python ${{ matrix.python }}
23+ uses : actions/setup-python@v1
24+ with :
25+ python-version : ${{ matrix.python }}
26+ - name : Install testing dependencies
27+ run : |
28+ python -m pip install --upgrade pip
29+ pip install pytest pytest-timeout
30+ - name : Install torch on mac
31+ if : startsWith(matrix.os, 'macOS')
32+ run : pip install torch==${{ matrix.torch }} torchvision==${{ matrix.torchvision }}
33+ - name : Install torch on ubuntu
34+ if : startsWith(matrix.os, 'ubuntu')
35+ run : pip install torch==${{ matrix.torch }}+cpu torchvision==${{ matrix.torchvision }}+cpu -f https://download.pytorch.org/whl/torch_stable.html
36+ - name : Install requirements
37+ run : |
38+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
39+ pip install scipy
40+ pip install git+https://github.com/mapillary/inplace_abn.git@v1.0.11
41+ - name : Run tests
42+ run : |
43+ pytest -vv --durations=0 ./tests
Original file line number Diff line number Diff line change 1+ import pytest
2+ import torch
3+
4+ from timm import list_models , create_model
5+
6+
7+ @pytest .mark .timeout (60 )
8+ @pytest .mark .parametrize ('model_name' , list_models ())
9+ @pytest .mark .parametrize ('batch_size' , [1 ])
10+ def test_model_forward (model_name , batch_size ):
11+ """Run a single forward pass with each model"""
12+ model = create_model (model_name , pretrained = False )
13+ model .eval ()
14+
15+ inputs = torch .randn ((batch_size , * model .default_cfg ['input_size' ]))
16+ outputs = model (inputs )
17+
18+ assert outputs .shape [0 ] == batch_size
19+ assert not torch .isnan (outputs ).any (), 'Output included NaNs'
You can’t perform that action at this time.
0 commit comments