From c5f00a8d7091b46b0ecd175f722d98ea8bea485e Mon Sep 17 00:00:00 2001 From: HaodongDuan Date: Fri, 16 Oct 2020 17:35:47 +0800 Subject: [PATCH 1/7] resolve comments --- tools/data/hvu/generate_sub_file_list.py | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tools/data/hvu/generate_sub_file_list.py diff --git a/tools/data/hvu/generate_sub_file_list.py b/tools/data/hvu/generate_sub_file_list.py new file mode 100644 index 0000000000..77c7bed651 --- /dev/null +++ b/tools/data/hvu/generate_sub_file_list.py @@ -0,0 +1,49 @@ +import argparse +import os.path as osp + +import mmcv + + +def main(annotation_file, category): + assert category in [ + 'action', 'attribute', 'concept', 'event', 'object', 'scene' + ] + + data = mmcv.load(annotation_file) + basename = osp.basename(annotation_file) + dirname = osp.dirname(annotation_file) + basename = basename.replace('hvu', f'hvu_{category}') + + target_file = osp.join(dirname, basename) + + def parse_item(item, category): + label = item['label'] + if category in label: + item['label'] = label[category] + return item + else: + return None + + result = [] + for item in data: + label = item['label'] + if category in label: + item['label'] = label[category] + result.append(item) + + mmcv.dump(data, target_file) + + +if __name__ == '__main__': + description = 'Helper script for generating HVU per-category file list.' + p = argparse.ArgumentParser(description=description) + p.add_argument( + 'annotation_file', + type=str, + help=('The annotation file which contains tags of all categories.')) + p.add_argument( + 'category', + type=str, + choices=['action', 'attribute', 'concept', 'event', 'object', 'scene'], + help='The tag category that you want to generate file list for.') + main(**vars(p.parse_args())) From 05575c18bf7dbba7e6e9f9a0f1c4f973668d2c44 Mon Sep 17 00:00:00 2001 From: HaodongDuan Date: Fri, 16 Oct 2020 17:37:19 +0800 Subject: [PATCH 2/7] update changelog --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index d0fe20a249..3cff48664d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,7 @@ **Improvements** - Set default values of 'average_clips' in each config file so that there is no need to set it explicitly during testing in most cases ([#232](https://github.com/open-mmlab/mmaction2/pull/232)) +- Extend HVU datatools to generate individual file list for each tag category ([#258](https://github.com/open-mmlab/mmaction2/pull/258)) **Bug Fixes** - Fix the potential bug for default value in dataset_setting ([#245](https://github.com/open-mmlab/mmaction2/pull/245)) From 8b88f8324749a4d57558f8eb4edecc91554ddbcc Mon Sep 17 00:00:00 2001 From: kenny Date: Mon, 28 Dec 2020 13:38:25 +0800 Subject: [PATCH 3/7] remove -q to check --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e687716b87..ec53b2c061 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,7 @@ jobs: - name: Install MMCV run: pip install mmcv-full==1.2.2 -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.torch}}/index.html - name: Install MMDet - run: pip install -q git+https://github.com/open-mmlab/mmdetection/ + run: pip install git+https://github.com/open-mmlab/mmdetection/ - name: Install unittest dependencies run: pip install -r requirements/tests.txt -r requirements/optional.txt - name: Build and install @@ -139,7 +139,7 @@ jobs: - name: Install mmaction dependencies run: | pip install mmcv-full==1.2.2 -f https://download.openmmlab.com/mmcv/dist/index.html - pip install -q git+https://github.com/open-mmlab/mmdetection/ + pip install git+https://github.com/open-mmlab/mmdetection/ pip install -r requirements.txt - name: Build and install run: | From 4181f7c9c6ebaeda277ac150eff53d5ce363ec20 Mon Sep 17 00:00:00 2001 From: kenny Date: Mon, 28 Dec 2020 14:36:39 +0800 Subject: [PATCH 4/7] update checking --- mmaction/core/bbox/assigners/max_iou_assigner_ava.py | 5 +++-- mmaction/models/backbones/resnet3d.py | 5 +++-- mmaction/models/backbones/resnet3d_slowfast.py | 5 +++-- mmaction/models/backbones/resnet3d_slowonly.py | 5 +++-- mmaction/models/heads/bbox_head.py | 5 +++-- mmaction/models/heads/roi_head.py | 5 +++-- mmaction/models/roi_extractors/single_straight3d.py | 5 +++-- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/mmaction/core/bbox/assigners/max_iou_assigner_ava.py b/mmaction/core/bbox/assigners/max_iou_assigner_ava.py index 17d4d22482..2af7c2915f 100644 --- a/mmaction/core/bbox/assigners/max_iou_assigner_ava.py +++ b/mmaction/core/bbox/assigners/max_iou_assigner_ava.py @@ -3,14 +3,15 @@ import torch try: - import mmdet # noqa from mmdet.core.bbox import AssignResult, MaxIoUAssigner from mmdet.core.bbox.builder import BBOX_ASSIGNERS + mmdet_imported = True except (ImportError, ModuleNotFoundError): warnings.warn('Please install mmdet to use AssignResult, MaxIoUAssigner ' 'and BBOX_ASSIGNERS') + mmdet_imported = False -if 'mmdet' in dir(): +if mmdet_imported: @BBOX_ASSIGNERS.register_module() class MaxIoUAssignerAVA(MaxIoUAssigner): diff --git a/mmaction/models/backbones/resnet3d.py b/mmaction/models/backbones/resnet3d.py index 4b91f06f51..db9a6a4d4e 100644 --- a/mmaction/models/backbones/resnet3d.py +++ b/mmaction/models/backbones/resnet3d.py @@ -12,10 +12,11 @@ from ..registry import BACKBONES try: - import mmdet # noqa from mmdet.models.builder import SHARED_HEADS as MMDET_SHARED_HEADS + mmdet_imported = True except (ImportError, ModuleNotFoundError): warnings.warn('Please install mmdet to use MMDET_SHARED_HEADS') + mmdet_imported = False class BasicBlock3d(nn.Module): @@ -999,5 +1000,5 @@ def train(self, mode=True): m.eval() -if 'mmdet' in dir(): +if mmdet_imported: MMDET_SHARED_HEADS.register_module()(ResNet3dLayer) diff --git a/mmaction/models/backbones/resnet3d_slowfast.py b/mmaction/models/backbones/resnet3d_slowfast.py index 01316d83f4..e98e94d1bf 100644 --- a/mmaction/models/backbones/resnet3d_slowfast.py +++ b/mmaction/models/backbones/resnet3d_slowfast.py @@ -11,10 +11,11 @@ from .resnet3d import ResNet3d try: - import mmdet # noqa from mmdet.models import BACKBONES as MMDET_BACKBONES + mmdet_imported = True except (ImportError, ModuleNotFoundError): warnings.warn('Please install mmdet to use MMDET_BACKBONES') + mmdet_imported = False class ResNet3dPathway(ResNet3d): @@ -507,5 +508,5 @@ def forward(self, x): return out -if 'mmdet' in dir(): +if mmdet_imported: MMDET_BACKBONES.register_module()(ResNet3dSlowFast) diff --git a/mmaction/models/backbones/resnet3d_slowonly.py b/mmaction/models/backbones/resnet3d_slowonly.py index 8e39bd288a..f5aef34d70 100644 --- a/mmaction/models/backbones/resnet3d_slowonly.py +++ b/mmaction/models/backbones/resnet3d_slowonly.py @@ -4,10 +4,11 @@ from .resnet3d_slowfast import ResNet3dPathway try: - import mmdet # noqa from mmdet.models.builder import BACKBONES as MMDET_BACKBONES + mmdet_imported = True except (ImportError, ModuleNotFoundError): warnings.warn('Please install mmdet to use MMDET_BACKBONES') + mmdet_imported = False @BACKBONES.register_module() @@ -50,5 +51,5 @@ def __init__(self, assert not self.lateral -if 'mmdet' in dir(): +if mmdet_imported: MMDET_BACKBONES.register_module()(ResNet3dSlowOnly) diff --git a/mmaction/models/heads/bbox_head.py b/mmaction/models/heads/bbox_head.py index 208e2f3897..357d4e5a0f 100644 --- a/mmaction/models/heads/bbox_head.py +++ b/mmaction/models/heads/bbox_head.py @@ -7,10 +7,11 @@ from mmaction.core.bbox import bbox_target try: - import mmdet # noqa from mmdet.models.builder import HEADS as MMDET_HEADS + mmdet_imported = True except (ImportError, ModuleNotFoundError): warnings.warn('Please install mmdet to use MMDET_HEADS') + mmdet_imported = False class BBoxHeadAVA(nn.Module): @@ -217,5 +218,5 @@ def _bbox_crop_undo(bboxes, crop_quadruple): return bboxes, scores -if 'mmdet' in dir(): +if mmdet_imported: MMDET_HEADS.register_module()(BBoxHeadAVA) diff --git a/mmaction/models/heads/roi_head.py b/mmaction/models/heads/roi_head.py index f94aa85a6a..bc258602a9 100644 --- a/mmaction/models/heads/roi_head.py +++ b/mmaction/models/heads/roi_head.py @@ -5,15 +5,16 @@ from mmaction.core.bbox import bbox2result try: - import mmdet # noqa from mmdet.core.bbox import bbox2roi from mmdet.models import HEADS as MMDET_HEADS from mmdet.models.roi_heads import StandardRoIHead + mmdet_imported = True except (ImportError, ModuleNotFoundError): warnings.warn('Please install mmdet to use bbox2roi, MMDET_HEADS ' 'and StandardRoIHead') + mmdet_imported = False -if 'mmdet' in dir(): +if mmdet_imported: @MMDET_HEADS.register_module() class AVARoIHead(StandardRoIHead): diff --git a/mmaction/models/roi_extractors/single_straight3d.py b/mmaction/models/roi_extractors/single_straight3d.py index 09d40b1dcf..3dfe9a9756 100644 --- a/mmaction/models/roi_extractors/single_straight3d.py +++ b/mmaction/models/roi_extractors/single_straight3d.py @@ -5,10 +5,11 @@ from mmcv.ops import RoIAlign, RoIPool try: - import mmdet # noqa from mmdet.models import ROI_EXTRACTORS + mmdet_imported = True except (ImportError, ModuleNotFoundError): warnings.warn('Please install mmdet to use ROI_EXTRACTORS') + mmdet_imported = False class SingleRoIExtractor3D(nn.Module): @@ -81,5 +82,5 @@ def forward(self, feat, rois): return torch.stack(roi_feats, dim=2) -if 'mmdet' in dir(): +if mmdet_imported: ROI_EXTRACTORS.register_module()(SingleRoIExtractor3D) From 5264a79783807f4a0b7585e2e8b3051053e3b6f6 Mon Sep 17 00:00:00 2001 From: lizz Date: Tue, 29 Dec 2020 14:52:55 +0800 Subject: [PATCH 5/7] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec53b2c061..03bdec12d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -138,7 +138,7 @@ jobs: run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install mmaction dependencies run: | - pip install mmcv-full==1.2.2 -f https://download.openmmlab.com/mmcv/dist/index.html + pip install mmcv-full==1.2.2 -f https://download.openmmlab.com/mmcv/dist/${{matrix.mmcv}}/index.html pip install git+https://github.com/open-mmlab/mmdetection/ pip install -r requirements.txt - name: Build and install From 49c920a4f48f44d0889d0f040544b98b06e6ab08 Mon Sep 17 00:00:00 2001 From: kenny Date: Tue, 29 Dec 2020 16:04:24 +0800 Subject: [PATCH 6/7] update CI, GPU use torch 1.5.0 --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec53b2c061..becedce9ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -80,14 +80,14 @@ jobs: strategy: matrix: python-version: [3.7] - torch: [1.3.0, 1.5.1+cu101, 1.6.0+cu101, 1.7.0+cu101] + torch: [1.3.0, 1.5.0+cu101, 1.6.0+cu101, 1.7.0+cu101] include: - torch: 1.3.0 torchvision: 0.4.1 mmcv: "cu101/torch1.3.0" - - torch: 1.5.1+cu101 + - torch: 1.5.0+cu101 torchvision: 0.6.1+cu101 - mmcv: "cu101/torch1.5.1" + mmcv: "cu101/torch1.5.0" - torch: 1.6.0+cu101 torchvision: 0.7.0+cu101 mmcv: "cu101/torch1.6.0" @@ -138,7 +138,7 @@ jobs: run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install mmaction dependencies run: | - pip install mmcv-full==1.2.2 -f https://download.openmmlab.com/mmcv/dist/index.html + pip install mmcv-full==1.2.2 -f https://download.openmmlab.com/mmcv/dist/${{matrix.mmcv}}/index.html pip install git+https://github.com/open-mmlab/mmdetection/ pip install -r requirements.txt - name: Build and install From f0b55f8a621d9b060224fa8af86108b5cc415e56 Mon Sep 17 00:00:00 2001 From: kenny Date: Tue, 29 Dec 2020 16:29:54 +0800 Subject: [PATCH 7/7] switch torchvision to 0.6.0 --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index becedce9ad..32bc8b0e69 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,12 +26,12 @@ jobs: strategy: matrix: python-version: [3.7] - torch: [1.3.0, 1.5.1, 1.6.0, 1.7.0] + torch: [1.3.0, 1.5.0, 1.6.0, 1.7.0] include: - torch: 1.3.0 torchvision: 0.4.1 - - torch: 1.5.1 - torchvision: 0.6.1 + - torch: 1.5.0 + torchvision: 0.6.0 - torch: 1.6.0 torchvision: 0.7.0 - torch: 1.7.0 @@ -86,7 +86,7 @@ jobs: torchvision: 0.4.1 mmcv: "cu101/torch1.3.0" - torch: 1.5.0+cu101 - torchvision: 0.6.1+cu101 + torchvision: 0.6.0+cu101 mmcv: "cu101/torch1.5.0" - torch: 1.6.0+cu101 torchvision: 0.7.0+cu101