Skip to content

Commit a94382c

Browse files
authoredFeb 18, 2022
[CI] Support Windows CI (open-mmlab#1448)
* windows CI * update * update * update CI * fix windows CI * fix CI * fix CI * update * update * update dependencies * update
1 parent 69a12b4 commit a94382c

File tree

13 files changed

+114
-53
lines changed

13 files changed

+114
-53
lines changed
 

‎.github/workflows/build.yml

+56-10
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@ name: build
22

33
on:
44
push:
5-
paths:
6-
- '!demo/**'
7-
- '!docker/**'
8-
- '!tools/**'
5+
paths-ignore:
6+
- ".github/**.md"
7+
- "demo/**"
8+
- "docker/**"
9+
- "tools/**"
10+
- "README.md"
11+
- "README_zh-CN.md"
912

1013
pull_request:
11-
paths:
12-
- '!demo/**'
13-
- '!docker/**'
14-
- '!tools/**'
15-
- '!docs/**'
16-
- '!docs_zh_CN/**'
14+
paths-ignore:
15+
- ".github/**.md"
16+
- "demo/**"
17+
- "docker/**"
18+
- "docs/**"
19+
- "docs_zh-CN/**"
20+
- "tools/**"
21+
- "README.md"
22+
- "README_zh-CN.md"
1723

1824
concurrency:
1925
group: ${{ github.workflow }}-${{ github.ref }}
@@ -192,3 +198,43 @@ jobs:
192198
coverage run --branch --source mmaction -m pytest tests/
193199
coverage xml
194200
coverage report -m
201+
202+
test_windows:
203+
runs-on: ${{ matrix.os }}
204+
strategy:
205+
matrix:
206+
os: [windows-2022]
207+
python: [3.8]
208+
platform: [cpu]
209+
steps:
210+
- uses: actions/checkout@v2
211+
- name: Set up Python ${{ matrix.python }}
212+
uses: actions/setup-python@v2
213+
with:
214+
python-version: ${{ matrix.python }}
215+
- name: Upgrade pip
216+
run: pip install pip --upgrade --user
217+
- name: Install librosa and soundfile
218+
run: python -m pip install librosa soundfile
219+
- name: Install lmdb
220+
run: python -m pip install lmdb
221+
- name: Install PyTorch
222+
# As a complement to Linux CI, we test on PyTorch LTS version
223+
run: pip install torch==1.8.2+${{ matrix.platform }} torchvision==0.9.2+${{ matrix.platform }} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
224+
- name: Install MMCV
225+
run: pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.8/index.html --only-binary mmcv-full
226+
- name: Install mmaction dependencies
227+
run: |
228+
python -V
229+
python -m pip install -q git+https://github.com/open-mmlab/mmdetection/
230+
python -m pip install -q git+https://github.com/open-mmlab/mmclassification/
231+
python -m pip install -r requirements.txt
232+
python -c 'import mmcv; print(mmcv.__version__)'
233+
- name: Install PytorchVideo
234+
run: python -m pip install pytorchvideo
235+
- name: Show pip list
236+
run: pip list
237+
- name: Build and install
238+
run: pip install -e .
239+
- name: Run unittests
240+
run: coverage run --branch --source mmedit -m pytest tests -sv

‎mmaction/core/evaluation/accuracy.py

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def confusion_matrix(y_pred, y_real, normalize=None):
2222

2323
if isinstance(y_pred, list):
2424
y_pred = np.array(y_pred)
25+
if y_pred.dtype == np.int32:
26+
y_pred = y_pred.astype(np.int64)
2527
if not isinstance(y_pred, np.ndarray):
2628
raise TypeError(
2729
f'y_pred must be list or np.ndarray, but got {type(y_pred)}')
@@ -31,6 +33,8 @@ def confusion_matrix(y_pred, y_real, normalize=None):
3133

3234
if isinstance(y_real, list):
3335
y_real = np.array(y_real)
36+
if y_real.dtype == np.int32:
37+
y_real = y_real.astype(np.int64)
3438
if not isinstance(y_real, np.ndarray):
3539
raise TypeError(
3640
f'y_real must be list or np.ndarray, but got {type(y_real)}')

‎requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
-r requirements/build.txt
22
-r requirements/optional.txt
3-
-r requirements/runtime.txt
43
-r requirements/tests.txt

‎requirements/build.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
# These must be installed before building mmaction2
1+
decord >= 0.4.1
2+
einops
3+
matplotlib
24
numpy
5+
opencv-contrib-python
6+
Pillow
7+
scipy
38
torch>=1.3

‎requirements/optional.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
av
2-
decord >= 0.4.1
3-
einops
42
imgaug
53
librosa
64
lmdb

‎requirements/runtime.txt

-7
This file was deleted.

‎setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,10 @@ def add_mim_extension():
186186
],
187187
url='https://github.com/open-mmlab/mmaction2',
188188
license='Apache License 2.0',
189-
install_requires=parse_requirements('requirements/runtime.txt'),
189+
install_requires=parse_requirements('requirements/build.txt'),
190190
extras_require={
191191
'all': parse_requirements('requirements.txt'),
192192
'tests': parse_requirements('requirements/tests.txt'),
193-
'build': parse_requirements('requirements/build.txt'),
194193
'optional': parse_requirements('requirements/optional.txt'),
195194
},
196195
zip_safe=False)

‎tests/test_data/test_pipelines/test_loadings/test_decode.py

+30-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
import copy
3+
import platform
34

45
import numpy as np
56
from mmcv.utils import assert_dict_has_keys
@@ -408,34 +409,35 @@ def test_rawframe_decode(self):
408409
240, 320)
409410
assert results['original_shape'] == (240, 320)
410411

411-
# test frame selector in turbojpeg decoding backend
412-
# when start_index = 0
413-
inputs = copy.deepcopy(self.frame_results)
414-
inputs['frame_inds'] = np.arange(0, self.total_frames, 5)
415-
# since the test images start with index 1, we plus 1 to frame_inds
416-
# in order to pass the CI
417-
inputs['frame_inds'] = inputs['frame_inds'] + 1
418-
frame_selector = RawFrameDecode(
419-
io_backend='disk', decoding_backend='turbojpeg')
420-
results = frame_selector(inputs)
421-
assert assert_dict_has_keys(results, target_keys)
422-
assert np.shape(results['imgs']) == (len(inputs['frame_inds']), 240,
423-
320, 3)
424-
assert results['original_shape'] == (240, 320)
425-
426-
# test frame selector in turbojpeg decoding backend
427-
inputs = copy.deepcopy(self.frame_results)
428-
inputs['frame_inds'] = np.arange(1, self.total_frames, 5)
429-
frame_selector = RawFrameDecode(
430-
io_backend='disk', decoding_backend='turbojpeg')
431-
results = frame_selector(inputs)
432-
assert assert_dict_has_keys(results, target_keys)
433-
assert np.shape(results['imgs']) == (len(inputs['frame_inds']), 240,
434-
320, 3)
435-
assert results['original_shape'] == (240, 320)
436-
assert repr(frame_selector) == (f'{frame_selector.__class__.__name__}('
437-
f'io_backend=disk, '
438-
f'decoding_backend=turbojpeg)')
412+
if platform.system() != 'Windows':
413+
# test frame selector in turbojpeg decoding backend
414+
# when start_index = 0
415+
inputs = copy.deepcopy(self.frame_results)
416+
inputs['frame_inds'] = np.arange(0, self.total_frames, 5)
417+
# since the test images start with index 1, we plus 1 to frame_inds
418+
# in order to pass the CI
419+
inputs['frame_inds'] = inputs['frame_inds'] + 1
420+
frame_selector = RawFrameDecode(
421+
io_backend='disk', decoding_backend='turbojpeg')
422+
results = frame_selector(inputs)
423+
assert assert_dict_has_keys(results, target_keys)
424+
assert np.shape(results['imgs']) == (len(inputs['frame_inds']),
425+
240, 320, 3)
426+
assert results['original_shape'] == (240, 320)
427+
428+
# test frame selector in turbojpeg decoding backend
429+
inputs = copy.deepcopy(self.frame_results)
430+
inputs['frame_inds'] = np.arange(1, self.total_frames, 5)
431+
frame_selector = RawFrameDecode(
432+
io_backend='disk', decoding_backend='turbojpeg')
433+
results = frame_selector(inputs)
434+
assert assert_dict_has_keys(results, target_keys)
435+
assert np.shape(results['imgs']) == (len(inputs['frame_inds']),
436+
240, 320, 3)
437+
assert results['original_shape'] == (240, 320)
438+
assert repr(frame_selector) == (
439+
f'{frame_selector.__class__.__name__}(io_backend=disk, '
440+
f'decoding_backend=turbojpeg)')
439441

440442
def test_audio_decode_init(self):
441443
target_keys = ['audios', 'length', 'sample_rate']

‎tests/test_metrics/test_accuracy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def test_top_k_accurate_classes():
320320
np.array([0.25, 0.1, 0.3, 0.35]), # 3
321321
np.array([0.2, 0.15, 0.3, 0.35]), # 3
322322
]
323-
label = np.array([3, 2, 2, 1, 3, 3])
323+
label = np.array([3, 2, 2, 1, 3, 3], dtype=np.int64)
324324

325325
with pytest.raises(AssertionError):
326326
top_k_classes(scores, label, 1, mode='wrong')
@@ -333,7 +333,7 @@ def test_top_k_accurate_classes():
333333
assert results_top1 == [(3, 1.)]
334334
assert results_top3 == [(3, 1.), (2, 0.5), (1, 0.0)]
335335

336-
label = np.array([3, 2, 1, 1, 3, 0])
336+
label = np.array([3, 2, 1, 1, 3, 0], dtype=np.int64)
337337
results_top1 = top_k_classes(scores, label, 1, mode='inaccurate')
338338
results_top3 = top_k_classes(scores, label, 3, mode='inaccurate')
339339
assert len(results_top1) == 1

‎tests/test_models/test_localizers/test_bmn.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
2+
import platform
3+
24
import numpy as np
5+
import pytest
36
import torch
47

58
from mmaction.models import build_localizer
69
from ..base import get_localizer_cfg
710

811

12+
@pytest.mark.skipif(platform.system() == 'Windows', reason='Windows mem limit')
913
def test_bmn():
1014
model_cfg = get_localizer_cfg(
1115
'bmn/bmn_400x100_2x8_9e_activitynet_feature.py')

‎tests/test_models/test_localizers/test_pem.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
2+
import platform
3+
4+
import pytest
25
import torch
36

47
from mmaction.models import build_localizer
58
from ..base import get_localizer_cfg
69

710

11+
@pytest.mark.skipif(platform.system() == 'Windows', reason='Windows mem limit')
812
def test_pem():
913
model_cfg = get_localizer_cfg(
1014
'bsn/bsn_pem_400x100_1x16_20e_activitynet_feature.py')

‎tests/test_models/test_localizers/test_ssn.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
import copy
3+
import platform
34

45
import mmcv
56
import pytest
@@ -8,6 +9,7 @@
89
from mmaction.models import build_localizer
910

1011

12+
@pytest.mark.skipif(platform.system() == 'Windows', reason='Windows mem limit')
1113
def test_ssn_train():
1214
train_cfg = mmcv.ConfigDict(
1315
dict(
@@ -105,6 +107,7 @@ def test_ssn_train():
105107
assert isinstance(losses, dict)
106108

107109

110+
@pytest.mark.skipif(platform.system() == 'Windows', reason='Windows mem limit')
108111
def test_ssn_test():
109112
test_cfg = mmcv.ConfigDict(
110113
dict(

‎tests/test_models/test_localizers/test_tem.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
2+
import platform
3+
4+
import pytest
25
import torch
36

47
from mmaction.models import build_localizer
58
from ..base import get_localizer_cfg
69

710

11+
@pytest.mark.skipif(platform.system() == 'Windows', reason='Windows mem limit')
812
def test_tem():
913
model_cfg = get_localizer_cfg(
1014
'bsn/bsn_tem_400x100_1x16_20e_activitynet_feature.py')

0 commit comments

Comments
 (0)