repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
mmdetection
docs/zh_cn/conf.py
.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
119
3,459
mmdetection
tests/test_apis/test_inference.py
.py
import os from pathlib import Path import numpy as np import pytest import torch from mmdet.apis import inference_detector, init_detector from mmdet.structures import DetDataSample from mmdet.utils import register_all_modules # TODO: Waiting to fix multiple call error bug register_all_modules() @pytest.mark.parame...
77
2,733
mmdetection
tests/test_apis/test_det_inferencer.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import tempfile from unittest import TestCase, mock from unittest.mock import Mock, patch import mmcv import mmengine import numpy as np import torch from mmengine.structures import InstanceData from mmengine.utils import is_list_of from parameteriz...
166
6,858
mmdetection
tests/test_datasets/test_objects365.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest from mmdet.datasets import Objects365V1Dataset, Objects365V2Dataset class TestObjects365V1Dataset(unittest.TestCase): def test_obj365v1_dataset(self): # test Objects365V1Dataset metainfo = dict(classes=('bus', 'car'), task_name='new...
80
3,362
mmdetection
tests/test_datasets/test_cityscapes.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os import unittest from mmengine.fileio import dump from mmdet.datasets import CityscapesDataset class TestCityscapesDataset(unittest.TestCase): def setUp(self) -> None: image1 = { 'file_name': 'munster/munster_000102_000019_leftImg8bit...
207
6,498
mmdetection
tests/test_datasets/test_youtube_vis_dataset.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase from mmdet.datasets import YouTubeVISDataset class TestYouTubeVISDataset(TestCase): @classmethod def setUpClass(cls): cls.dataset = YouTubeVISDataset( ann_file='tests/data/vis_sample.json', dataset_version='20...
18
480
mmdetection
tests/test_datasets/test_lvis.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os import unittest from mmengine.fileio import dump from mmdet.datasets import LVISV1Dataset, LVISV05Dataset try: import lvis except ImportError: lvis = None class TestLVISDataset(unittest.TestCase): def setUp(self) -> None: image1 = { ...
232
7,429
mmdetection
tests/test_datasets/test_dsdldet.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest from mmdet.datasets import DSDLDetDataset try: from dsdl.dataset import DSDLDataset except ImportError: DSDLDataset = None class TestDSDLDetDataset(unittest.TestCase): def test_dsdldet_init(self): if DSDLDataset is not None: ...
26
734
mmdetection
tests/test_datasets/test_coco.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest from mmdet.datasets import CocoDataset class TestCocoDataset(unittest.TestCase): def test_coco_dataset(self): # test CocoDataset metainfo = dict(classes=('bus', 'car'), task_name='new_task') dataset = CocoDataset( ...
49
1,771
mmdetection
tests/test_datasets/test_coco_panoptic.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os import unittest from mmengine.fileio import dump from mmdet.datasets import CocoPanopticDataset class TestCocoPanopticDataset(unittest.TestCase): def setUp(self): image1 = { 'id': 0, 'width': 640, 'height': 64...
250
8,201
mmdetection
tests/test_datasets/test_coco_api_wrapper.py
.py
import os.path as osp import tempfile import unittest from mmengine.fileio import dump from mmdet.datasets.api_wrappers import COCOPanoptic class TestCOCOPanoptic(unittest.TestCase): def setUp(self): self.tmp_dir = tempfile.TemporaryDirectory() def tearDown(self): self.tmp_dir.cleanup() ...
68
1,647
mmdetection
tests/test_datasets/test_crowdhuman.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest from mmdet.datasets import CrowdHumanDataset class TestCrowdHumanDataset(unittest.TestCase): def test_crowdhuman_init(self): dataset = CrowdHumanDataset( data_root='tests/data/crowdhuman_dataset/', ann_file='test_ann...
17
521
mmdetection
tests/test_datasets/test_wider_face.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest import cv2 import numpy as np from mmdet.datasets import WIDERFaceDataset class TestWIDERFaceDataset(unittest.TestCase): def setUp(self) -> None: img_path = 'tests/data/WIDERFace/WIDER_train/0--Parade/0_Parade_marchingband_1_5.jpg' # noqa...
29
880
mmdetection
tests/test_datasets/test_tta.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from unittest import TestCase import mmcv import pytest from mmdet.datasets.transforms import * # noqa from mmdet.registry import TRANSFORMS class TestMuitiScaleFlipAug(TestCase): def test_exception(self): with pytest.raises(TypeErr...
178
7,531
mmdetection
tests/test_datasets/test_reid_dataset.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from unittest import TestCase from mmdet.datasets import ReIDDataset PREFIX = osp.join(osp.dirname(__file__), '../data') # This is a demo annotation file for ReIDDataset. REID_ANN_FILE = f'{PREFIX}/demo_reid_data/mot17_reid/ann.txt' class TestReI...
65
2,231
mmdetection
tests/test_datasets/test_openimages.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest from mmdet.datasets import OpenImagesChallengeDataset, OpenImagesDataset class TestOpenImagesDataset(unittest.TestCase): def test_init(self): dataset = OpenImagesDataset( data_root='tests/data/OpenImages/', ann_file=...
37
1,439
mmdetection
tests/test_datasets/test_pascal_voc.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest from mmdet.datasets import VOCDataset class TestVOCDataset(unittest.TestCase): def test_voc2007_init(self): dataset = VOCDataset( data_root='tests/data/VOCdevkit/', ann_file='VOC2007/ImageSets/Main/trainval.txt', ...
39
1,367
mmdetection
tests/test_datasets/test_mot_challenge_dataset.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest from mmdet.datasets import MOTChallengeDataset class TestMOTChallengeDataset(unittest.TestCase): def test_mot_challenge_dataset(self): # test CocoDataset metainfo = dict(classes=('pedestrian'), task_name='new_task') dataset ...
38
1,553
mmdetection
tests/test_datasets/test_samplers/test_track_img_sampler.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from collections.abc import Iterable from copy import deepcopy from unittest import TestCase from mmengine.dataset import ClassBalancedDataset, ConcatDataset from mmdet.datasets import MOTChallengeDataset, TrackImgSampler class TestTrackImgSampler(TestCase): def ...
93
3,601
mmdetection
tests/test_datasets/test_samplers/test_batch_sampler.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase from unittest.mock import patch import numpy as np from mmengine.dataset import DefaultSampler from torch.utils.data import Dataset from mmdet.datasets.samplers import AspectRatioBatchSampler class DummyDataset(Dataset): def __init_...
81
2,989
mmdetection
tests/test_datasets/test_samplers/test_multi_source_sampler.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import bisect from unittest import TestCase from unittest.mock import patch import numpy as np from torch.utils.data import ConcatDataset, Dataset from mmdet.datasets.samplers import GroupMultiSourceSampler, MultiSourceSampler class DummyDataset(Dataset): def __...
108
3,732
mmdetection
tests/test_datasets/test_transforms/test_geometric.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import unittest import numpy as np from mmdet.datasets.transforms import (GeomTransform, Rotate, ShearX, ShearY, TranslateX, TranslateY) from mmdet.structures.bbox import HorizontalBoxes from mmdet.structures.mask impor...
753
34,115
mmdetection
tests/test_datasets/test_transforms/test_instaboost.py
.py
import os.path as osp import unittest import numpy as np from mmdet.registry import TRANSFORMS from mmdet.utils import register_all_modules register_all_modules() class TestInstaboost(unittest.TestCase): def setUp(self): """Setup the model and optimizer which are used in every test method. Te...
59
1,782
mmdetection
tests/test_datasets/test_transforms/utils.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np from mmengine.testing import assert_allclose from mmdet.structures.bbox import BaseBoxes, HorizontalBoxes from mmdet.structures.mask import BitmapMasks, PolygonMasks def create_random_bboxes(num_bboxes, img_w, img_h): bboxes_left_top = np.random....
77
3,135
mmdetection
tests/test_datasets/test_transforms/test_transforms.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import os.path as osp import unittest import mmcv import numpy as np import torch from mmcv.transforms import LoadImageFromFile # yapf:disable from mmdet.datasets.transforms import (CopyPaste, CutOut, Expand, FixScaleRe...
1,791
75,490
mmdetection
tests/test_datasets/test_transforms/test_wrappers.py
.py
import copy import os.path as osp import unittest from mmcv.transforms import Compose from mmdet.datasets.transforms import MultiBranch, RandomOrder from mmdet.utils import register_all_modules from .utils import construct_toy_data register_all_modules() class TestMultiBranch(unittest.TestCase): def setUp(sel...
174
6,834
mmdetection
tests/test_datasets/test_transforms/test_augment_wrappers.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import unittest from mmdet.datasets.transforms import (AutoAugment, AutoContrast, Brightness, Color, Contrast, Equalize, Invert, Posterize, RandAugment, Rotate, ...
250
10,790
mmdetection
tests/test_datasets/test_transforms/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .utils import construct_toy_data, create_full_masks, create_random_bboxes __all__ = ['create_random_bboxes', 'create_full_masks', 'construct_toy_data']
5
206
mmdetection
tests/test_datasets/test_transforms/test_colorspace.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import unittest from mmdet.datasets.transforms import (AutoContrast, Brightness, Color, ColorTransform, Contrast, Equalize, Invert, Posterize, Sharpness, Solarize, ...
366
14,352
mmdetection
tests/test_datasets/test_transforms/test_formatting.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import os.path as osp import unittest import numpy as np import torch from mmengine.structures import InstanceData, LabelData, PixelData from mmdet.datasets.transforms import (PackDetInputs, PackReIDInputs, PackTrackInp...
247
10,369
mmdetection
tests/test_datasets/test_transforms/test_frame_sampling.py
.py
import unittest import numpy as np from mmdet.datasets.transforms import BaseFrameSample, UniformRefFrameSample class TestFrameSample(unittest.TestCase): def setUp(self): """Setup the model and optimizer which are used in every test method. TestCase calls functions in this order: setUp() -> te...
120
4,798
mmdetection
tests/test_datasets/test_transforms/test_loading.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import os import os.path as osp import sys import unittest from unittest.mock import MagicMock, Mock, patch import mmcv import numpy as np from mmdet.datasets.transforms import (FilterAnnotations, LoadAnnotations, LoadE...
540
20,474
mmdetection
tests/test_visualization/test_local_visualizer.py
.py
import os from unittest import TestCase import cv2 import numpy as np import torch from mmengine.structures import InstanceData, PixelData from mmdet.evaluation import INSTANCE_OFFSET from mmdet.structures import DetDataSample from mmdet.visualization import DetLocalVisualizer, TrackLocalVisualizer def _rand_bboxes...
200
7,076
mmdetection
tests/test_visualization/test_palette.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np from mmdet.datasets import CocoDataset from mmdet.visualization import get_palette, jitter_color, palette_val def test_palette(): assert palette_val([(1, 2, 3)])[0] == (1 / 255, 2 / 255, 3 / 255) # test list palette = [(1, 0, 0), (0, 1, ...
59
2,013
mmdetection
tests/test_utils/test_setup_env.py
.py
import datetime import sys from unittest import TestCase from mmengine import DefaultScope from mmdet.utils import register_all_modules class TestSetupEnv(TestCase): def test_register_all_modules(self): from mmdet.registry import DATASETS # not init default scope sys.modules.pop('mmdet...
39
1,426
mmdetection
tests/test_utils/test_replace_cfg_vals.py
.py
import os.path as osp import tempfile from copy import deepcopy import pytest from mmengine.config import Config from mmdet.utils import replace_cfg_vals def test_replace_cfg_vals(): temp_file = tempfile.NamedTemporaryFile() cfg_path = f'{temp_file.name}.py' with open(cfg_path, 'w') as f: f.writ...
84
2,985
mmdetection
tests/test_utils/test_benchmark.py
.py
import copy import os import tempfile import unittest import torch from mmengine import Config, MMLogger from mmengine.dataset import Compose from mmengine.model import BaseModel from torch.utils.data import Dataset from mmdet.registry import DATASETS, MODELS from mmdet.utils import register_all_modules from mmdet.ut...
310
11,696
mmdetection
tests/test_utils/test_memory.py
.py
import numpy as np import pytest import torch from mmdet.utils import AvoidOOM from mmdet.utils.memory import cast_tensor_type def test_avoidoom(): tensor = torch.from_numpy(np.random.random((20, 20))) if torch.cuda.is_available(): tensor = tensor.cuda() # get default result default_r...
99
4,261
mmdetection
tests/test_engine/test_hooks/test_num_class_check_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from copy import deepcopy from unittest import TestCase from unittest.mock import Mock from mmcv.cnn import VGG from mmengine.dataset import BaseDataset from torch import nn from mmdet.engine.hooks import NumClassCheckHook from mmdet.models.roi_heads.mask_heads import F...
107
3,988
mmdetection
tests/test_engine/test_hooks/test_pipeline_switch_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase from unittest.mock import Mock from mmdet.engine.hooks import PipelineSwitchHook class TestPipelineSwitchHook(TestCase): def test_persistent_workers_on(self): runner = Mock() runner.model = Mock() runner.model....
85
3,469
mmdetection
tests/test_engine/test_hooks/test_visualization_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import shutil import time from unittest import TestCase from unittest.mock import Mock import torch from mmengine.structures import InstanceData from mmdet.engine.hooks import DetVisualizationHook, TrackVisualizationHook from mmdet.structures impor...
121
4,533
mmdetection
tests/test_engine/test_hooks/test_mean_teacher_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import tempfile from unittest import TestCase import torch import torch.nn as nn from mmengine.evaluator import BaseMetric from mmengine.model import BaseModel from mmengine.optim import OptimWrapper from mmengine.registry import MODEL_WRAPPERS from...
176
5,299
mmdetection
tests/test_engine/test_hooks/test_sync_norm_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase from unittest.mock import Mock, patch import torch.nn as nn from mmdet.engine.hooks import SyncNormHook class TestSyncNormHook(TestCase): @patch( 'mmdet.engine.hooks.sync_norm_hook.get_dist_info', return_value=(0, 1)) def...
42
1,374
mmdetection
tests/test_engine/test_hooks/test_memory_profiler_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase from unittest.mock import Mock from mmdet.engine.hooks import MemoryProfilerHook class TestMemoryProfilerHook(TestCase): def test_after_train_iter(self): hook = MemoryProfilerHook(2) runner = Mock() runner.logg...
39
1,222
mmdetection
tests/test_engine/test_hooks/test_yolox_mode_switch_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase from unittest.mock import Mock, patch from mmdet.engine.hooks import YOLOXModeSwitchHook class TestYOLOXModeSwitchHook(TestCase): @patch('mmdet.engine.hooks.yolox_mode_switch_hook.is_model_wrapper') def test_is_model_wrapper_and_p...
75
3,085
mmdetection
tests/test_engine/test_hooks/test_checkloss_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase from unittest.mock import Mock import torch from mmdet.engine.hooks import CheckInvalidLossHook class TestCheckInvalidLossHook(TestCase): def test_after_train_iter(self): n = 50 hook = CheckInvalidLossHook(n) ...
38
1,372
mmdetection
tests/test_engine/test_optimizers/test_layer_decay_optimizer_constructor.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmcv.cnn import ConvModule from mmdet.engine import LearningRateDecayOptimizerConstructor base_lr = 1 decay_rate = 2 base_wd = 0.05 weight_decay = 0.05 expected_stage_wise_lr_wd_convnext = [{ 'weight_decay': 0.0, 'lr_scal...
169
4,532
mmdetection
tests/test_engine/test_runner/test_loops.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import tempfile from unittest import TestCase from unittest.mock import Mock import torch import torch.nn as nn from mmengine.evaluator import Evaluator from mmengine.model import BaseModel from mmengine.optim import OptimWrapper from mmengine.runner import Runner from t...
114
3,296
mmdetection
tests/test_engine/test_schedulers/test_quadratic_warmup.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase import torch import torch.nn.functional as F import torch.optim as optim from mmengine.optim.scheduler import _ParamScheduler from mmengine.testing import assert_allclose from mmdet.engine.schedulers import (QuadraticWarmupLR, ...
109
4,323
mmdetection
tests/data/dsdl_det/config.py
.py
local = dict( type='LocalFileReader', working_dir='local path', )
5
74
mmdetection
tests/data/configs_mmtrack/tracktor_faster-rcnn_r50_fpn_4e.py
.py
_base_ = [ './faster-rcnn_r50_fpn.py', './mot_challenge.py', '../../../configs/_base_/default_runtime.py' ] model = dict( type='Tracktor', pretrains=dict( detector= # noqa: E251 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot17-half-64ee2ed4.pth', ...
71
2,309
mmdetection
tests/data/configs_mmtrack/faster_rcnn_r50_fpn.py
.py
model = dict( detector=dict( type='FasterRCNN', backbone=dict( type='ResNet', depth=18, base_channels=2, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), ...
110
4,013
mmdetection
tests/data/configs_mmtrack/faster_rcnn_r50_dc5.py
.py
model = dict( detector=dict( type='FasterRCNN', backbone=dict( type='ResNet', depth=18, base_channels=2, num_stages=4, out_indices=(3, ), strides=(1, 2, 2, 1), dilations=(1, 1, 1, 2), frozen_stages=1, ...
114
4,091
mmdetection
tests/data/configs_mmtrack/mot_challenge.py
.py
# dataset settings dataset_type = 'MOTChallengeDataset' img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [ dict(type='LoadMultiImagesFromFile', to_float32=True), dict(type='SeqLoadAnnotations', with_bbox=True, with_track=True), dict( ...
75
2,465
mmdetection
tests/data/configs_mmtrack/selsa_faster_rcnn_r101_dc5_1x.py
.py
_base_ = [ './faster_rcnn_r50_dc5.py', './mot_challenge.py', '../../../configs/_base_/default_runtime.py' ] model = dict( type='SELSA', pretrains=None, detector=dict( backbone=dict(depth=18, base_channels=2), roi_head=dict( type='SelsaRoIHead', bbox_head=dict(...
49
1,351
mmdetection
tests/test_evaluation/test_metrics/test_coco_video_metric.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import tempfile from unittest import TestCase import numpy as np import pycocotools.mask as mask_util import torch from mmengine.fileio import dump from mmengine.structures import BaseDataElement, InstanceData from mmdet.evaluation import CocoVideo...
414
16,028
mmdetection
tests/test_evaluation/test_metrics/test_coco_metric.py
.py
import os.path as osp import tempfile from unittest import TestCase import numpy as np import pycocotools.mask as mask_util import torch from mmengine.fileio import dump from mmdet.evaluation import CocoMetric class TestCocoMetric(TestCase): def _create_dummy_coco_json(self, json_name): dummy_mask = np...
402
14,349
mmdetection
tests/test_evaluation/test_metrics/test_coco_occluded_metric.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from tempfile import TemporaryDirectory import mmengine import numpy as np from mmdet.datasets import CocoDataset from mmdet.evaluation import CocoOccludedSeparatedMetric def test_coco_occluded_separated_metric(): ann = [[ 'fake1.jpg'...
47
1,470
mmdetection
tests/test_evaluation/test_metrics/test_coco_panoptic_metric.py
.py
import os import os.path as osp import tempfile import unittest from copy import deepcopy import mmcv import numpy as np import torch from mmengine.fileio import dump from mmdet.evaluation import INSTANCE_OFFSET, CocoPanopticMetric try: import panopticapi except ImportError: panopticapi = None class TestCo...
286
9,287
mmdetection
tests/test_evaluation/test_metrics/test_crowdhuman_metric.py
.py
import os.path as osp import tempfile from unittest import TestCase import numpy as np import torch from mmdet.evaluation import CrowdHumanMetric class TestCrowdHumanMetric(TestCase): def _create_dummy_results(self): bboxes = np.array([[1330, 317, 418, 1338], [792, 24, 723, 2017], ...
55
1,834
mmdetection
tests/test_evaluation/test_metrics/test_cityscapes_metric.py
.py
import os import os.path as osp import tempfile import unittest import numpy as np import torch from PIL import Image from mmdet.evaluation import CityScapesMetric try: import cityscapesscripts except ImportError: cityscapesscripts = None class TestCityScapesMetric(unittest.TestCase): def setUp(self):...
103
3,528
mmdetection
tests/test_evaluation/test_metrics/test_lvis_metric.py
.py
import os.path as osp import tempfile import unittest import numpy as np import pycocotools.mask as mask_util import torch from mmdet.evaluation.metrics import LVISMetric try: import lvis except ImportError: lvis = None from mmengine.fileio import dump class TestLVISMetric(unittest.TestCase): def _cr...
364
13,025
mmdetection
tests/test_evaluation/test_metrics/test_youtube_vis_metric.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os import tempfile from unittest import TestCase import numpy as np import pycocotools.mask as mask_util import torch from mmengine.registry import init_default_scope from mmengine.structures import BaseDataElement, InstanceData from mmdet.registry import METRICS...
172
6,308
mmdetection
tests/test_evaluation/test_metrics/test_reid_metric.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase import torch from mmengine.registry import init_default_scope from mmdet.registry import METRICS from mmdet.structures import ReIDDataSample class TestReIDMetrics(TestCase): @classmethod def setUpClass(cls): init_default_...
56
2,016
mmdetection
tests/test_evaluation/test_metrics/test_openimages_metric.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest import numpy as np import torch from mmdet.datasets import OpenImagesDataset from mmdet.evaluation import OpenImagesMetric from mmdet.utils import register_all_modules class TestOpenImagesMetric(unittest.TestCase): def _create_dummy_results(self):...
73
2,768
mmdetection
tests/test_evaluation/test_metrics/test_mot_challenge_metrics.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import os import tempfile from unittest import TestCase import torch from mmengine.structures import BaseDataElement, InstanceData from mmdet.evaluation import MOTChallengeMetric from mmdet.structures import DetDataSample, TrackDataSample class TestMOTChal...
117
4,061
mmdetection
tests/test_evaluation/test_metrics/test_dump_det_results.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import tempfile from unittest import TestCase import torch from mmengine.fileio import load from torch import Tensor from mmdet.evaluation import DumpDetResults from mmdet.structures.mask import encode_mask_results class TestDumpResults(TestCase)...
54
1,963
mmdetection
tests/test_models/test_backbones/test_renext.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.backbones import ResNeXt from mmdet.models.backbones.resnext import Bottleneck as BottleneckX from .utils import is_block def test_renext_bottleneck(): with pytest.raises(AssertionError): # Style must be in ['pyt...
106
3,528
mmdetection
tests/test_models/test_backbones/test_regnet.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.backbones import RegNet regnet_test_data = [ ('regnetx_400mf', dict(w0=24, wa=24.48, wm=2.54, group_w=16, depth=22, bot_mul=1.0), [32, 64, 160, 384]), ('regnetx_800mf', dict(w0=56, wa=35.73, wm=2.2...
59
2,177
mmdetection
tests/test_models/test_backbones/test_detectors_resnet.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest from mmdet.models.backbones import DetectoRS_ResNet def test_detectorrs_resnet_backbone(): detectorrs_cfg = dict( depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requi...
48
1,611
mmdetection
tests/test_models/test_backbones/test_mobilenet_v2.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from torch.nn.modules import GroupNorm from torch.nn.modules.batchnorm import _BatchNorm from mmdet.models.backbones.mobilenet_v2 import MobileNetV2 from .utils import check_norm_state, is_block, is_norm def test_mobilenetv2_backbone(): w...
174
6,546
mmdetection
tests/test_models/test_backbones/utils.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from torch.nn.modules import GroupNorm from torch.nn.modules.batchnorm import _BatchNorm from mmdet.models.backbones.res2net import Bottle2neck from mmdet.models.backbones.resnet import BasicBlock, Bottleneck from mmdet.models.backbones.resnext import Bottleneck as Bottl...
33
1,027
mmdetection
tests/test_models/test_backbones/test_efficientnet.py
.py
import pytest import torch from mmdet.models.backbones import EfficientNet def test_efficientnet_backbone(): """Test EfficientNet backbone.""" with pytest.raises(AssertionError): # EfficientNet arch should be a key in EfficientNet.arch_settings EfficientNet(arch='c3') model = EfficientNe...
26
859
mmdetection
tests/test_models/test_backbones/test_trident_resnet.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.backbones import TridentResNet from mmdet.models.backbones.trident_resnet import TridentBottleneck def test_trident_resnet_bottleneck(): trident_dilations = (1, 2, 3) test_branch_idx = 1 concat_output = True ...
181
6,372
mmdetection
tests/test_models/test_backbones/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .utils import check_norm_state, is_block, is_norm __all__ = ['is_block', 'is_norm', 'check_norm_state']
5
158
mmdetection
tests/test_models/test_backbones/test_swin.py
.py
import pytest import torch from mmdet.models.backbones.swin import SwinBlock, SwinTransformer def test_swin_block(): # test SwinBlock structure and forward block = SwinBlock(embed_dims=64, num_heads=4, feedforward_channels=256) assert block.ffn.embed_dims == 64 assert block.attn.w_msa.num_heads == 4 ...
83
2,648
mmdetection
tests/test_models/test_backbones/test_hourglass.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.backbones.hourglass import HourglassNet def test_hourglass_backbone(): with pytest.raises(AssertionError): # HourglassNet's num_stacks should larger than 0 HourglassNet(num_stacks=0) with pytest.rais...
50
1,464
mmdetection
tests/test_models/test_backbones/test_pvt.py
.py
import pytest import torch from mmdet.models.backbones.pvt import (PVTEncoderLayer, PyramidVisionTransformer, PyramidVisionTransformerV2) def test_pvt_block(): # test PVT structure and forward block = PVTEncoderLayer( emb...
104
3,332
mmdetection
tests/test_models/test_backbones/test_csp_darknet.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from torch.nn.modules.batchnorm import _BatchNorm from mmdet.models.backbones.csp_darknet import CSPDarknet from .utils import check_norm_state, is_norm def test_csp_darknet_backbone(): with pytest.raises(ValueError): # frozen_sta...
117
4,117
mmdetection
tests/test_models/test_backbones/test_res2net.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.backbones import Res2Net from mmdet.models.backbones.res2net import Bottle2neck from .utils import is_block def test_res2net_bottle2neck(): with pytest.raises(AssertionError): # Style must be in ['pytorch', 'caff...
63
1,976
mmdetection
tests/test_models/test_backbones/test_hrnet.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.backbones.hrnet import HRModule, HRNet from mmdet.models.backbones.resnet import BasicBlock, Bottleneck @pytest.mark.parametrize('block', [BasicBlock, Bottleneck]) def test_hrmodule(block): # Test multiscale forward ...
112
3,089
mmdetection
tests/test_models/test_backbones/test_resnest.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.backbones import ResNeSt from mmdet.models.backbones.resnest import Bottleneck as BottleneckS def test_resnest_bottleneck(): with pytest.raises(AssertionError): # Style must be in ['pytorch', 'caffe'] Bot...
48
1,473
mmdetection
tests/test_models/test_backbones/test_resnet.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmcv.ops import DeformConv2dPack from torch.nn.modules import AvgPool2d, GroupNorm from torch.nn.modules.batchnorm import _BatchNorm from mmdet.models.backbones import ResNet, ResNetV1d from mmdet.models.backbones.resnet import BasicBlock,...
655
23,003
mmdetection
tests/test_models/test_vis/test_masktrack_rcnn.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import time import unittest from unittest import TestCase import torch from mmengine.logging import MessageHub from mmengine.registry import init_default_scope from parameterized import parameterized from mmdet.registry import MODELS from mmdet.testing import demo_track...
100
3,513
mmdetection
tests/test_models/test_vis/test_mask2former.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import time import unittest from unittest import TestCase import torch from mmengine.logging import MessageHub from mmengine.registry import init_default_scope from parameterized import parameterized from mmdet.registry import MODELS from mmdet.testing import demo_track...
97
3,400
mmdetection
tests/test_models/test_seg_heads/test_heuristic_fusion_head.py
.py
import unittest import torch from mmengine.config import Config from mmengine.structures import InstanceData from mmengine.testing import assert_allclose from mmdet.evaluation import INSTANCE_OFFSET from mmdet.models.seg_heads.panoptic_fusion_heads import HeuristicFusionHead class TestHeuristicFusionHead(unittest.T...
60
2,440
mmdetection
tests/test_models/test_seg_heads/test_maskformer_fusion_head.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest import torch from mmengine.config import Config from mmdet.models.seg_heads.panoptic_fusion_heads import MaskFormerFusionHead from mmdet.structures import DetDataSample class TestMaskFormerFusionHead(unittest.TestCase): def test_loss(self): ...
109
3,827
mmdetection
tests/test_models/test_seg_heads/test_panoptic_fpn_head.py
.py
import unittest import torch from mmengine.structures import PixelData from mmengine.testing import assert_allclose from mmdet.models.seg_heads import PanopticFPNHead from mmdet.structures import DetDataSample class TestPanopticFPNHead(unittest.TestCase): def test_init_weights(self): head = PanopticFPN...
71
2,446
mmdetection
tests/test_models/test_layers/test_conv_upsample.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.layers import ConvUpsample @pytest.mark.parametrize('num_layers', [0, 1, 2]) def test_conv_upsample(num_layers): num_upsample = num_layers if num_layers > 0 else 0 num_layers = num_layers if num_layers > 0 else 1 ...
25
629
mmdetection
tests/test_models/test_layers/test_brick_wrappers.py
.py
from unittest.mock import patch import torch import torch.nn as nn import torch.nn.functional as F from mmdet.models.layers import AdaptiveAvgPool2d, adaptive_avg_pool2d if torch.__version__ != 'parrots': torch_version = '1.7' else: torch_version = 'parrots' @patch('torch.__version__', torch_version) def t...
94
2,932
mmdetection
tests/test_models/test_layers/test_position_encoding.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmdet.models.layers import (LearnedPositionalEncoding, SinePositionalEncoding) def test_sine_positional_encoding(num_feats=16, batch_size=2): # test invalid type of scale with pytest.raises(Assert...
40
1,439
mmdetection
tests/test_models/test_layers/test_se_layer.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch import torch.nn.functional as F from mmengine.model import constant_init from mmdet.models.layers import DyReLU, SELayer def test_se_layer(): with pytest.raises(AssertionError): # act_cfg sequence length must equal to 2 SE...
55
1,623
mmdetection
tests/test_models/test_layers/test_inverted_residual.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmcv.cnn import is_norm from torch.nn.modules import GroupNorm from mmdet.models.layers import InvertedResidual, SELayer def test_inverted_residual(): with pytest.raises(AssertionError): # stride must be in [1, 2] In...
77
2,636
mmdetection
tests/test_models/test_layers/test_transformer.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmengine.config import ConfigDict from mmdet.models.layers.transformer import (AdaptivePadding, DDQTransformerDecoder, DetrTransformerDecoder, ...
525
15,404
mmdetection
tests/test_models/test_layers/test_ema.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import itertools import math from unittest import TestCase import torch import torch.nn as nn from mmengine.testing import assert_allclose from mmdet.models.layers import ExpMomentumEMA class TestEMA(TestCase): def test_exp_momentum_ema(self): model = nn....
95
3,633
mmdetection
tests/test_models/test_layers/test_plugins.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import unittest import pytest import torch from mmengine.config import ConfigDict from mmdet.models.layers import DropBlock from mmdet.registry import MODELS from mmdet.utils import register_all_modules register_all_modules() def test_dropblock(): feat = torch.ra...
172
6,408
mmdetection
tests/test_models/test_losses/test_loss.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import json import pytest import torch import torch.nn.functional as F from mmengine.utils import digit_version from mmdet.models.losses import (BalancedL1Loss, CrossEntropyLoss, DDQAuxLoss, DiceLoss, DistributionFocalLoss, EQLV2Loss, ...
347
12,737
mmdetection
tests/test_models/test_losses/test_multi_pos_cross_entropy_loss.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase import torch from mmdet.models.losses import MultiPosCrossEntropyLoss class TestMultiPosCrossEntropyLoss(TestCase): def test_mpce_loss(self): costs = torch.tensor([[1, 0], [0, 1]]) labels = torch.tensor([[1, 1], [0, 0...
21
620
mmdetection
tests/test_models/test_losses/test_gaussian_focal_loss.py
.py
import unittest import torch from mmdet.models.losses import GaussianFocalLoss class TestGaussianFocalLoss(unittest.TestCase): def test_forward(self): pred = torch.rand((10, 4)) target = torch.rand((10, 4)) gaussian_focal_loss = GaussianFocalLoss() loss1 = gaussian_focal_loss(pr...
39
1,303
mmdetection
tests/test_models/test_losses/test_triplet_loss.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase import torch from mmdet.models import TripletLoss class TestTripletLoss(TestCase): def test_triplet_loss(self): feature = torch.Tensor([[1, 1], [1, 1], [0, 0], [0, 0]]) label = torch.Tensor([1, 1, 0, 0]) loss...
20
552