repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
DDOD
DDOD-main/coco_cfg/ddod_r50_1x_fcos.py
fp16 = dict(loss_scale=512.) model = dict( type='ATSS', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, style='pytorch', init_cfg...
4,374
30.028369
99
py
DDOD
DDOD-main/tools/test.py
import argparse import os import os.path as osp import time import warnings import mmcv import torch from mmcv import Config, DictAction from mmcv.cnn import fuse_conv_bn from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import (get_dist_info, init_dist, load_checkpoint, ...
9,315
38.142857
79
py
DDOD
DDOD-main/tools/train.py
import argparse import copy import os import os.path as osp import time import warnings import mmcv import torch from mmcv import Config, DictAction from mmcv.runner import get_dist_info, init_dist from mmcv.utils import get_git_hash from mmdet import __version__ from mmdet.apis import set_random_seed, train_detector...
6,914
35.587302
79
py
DDOD
DDOD-main/tools/deployment/mmdet2torchserve.py
from argparse import ArgumentParser, Namespace from pathlib import Path from tempfile import TemporaryDirectory import mmcv try: from model_archiver.model_packaging import package_model from model_archiver.model_packaging_utils import ModelExportUtils except ImportError: package_model = None def mmdet2t...
3,645
32.145455
78
py
DDOD
DDOD-main/tools/deployment/test.py
import argparse import mmcv from mmcv import Config, DictAction from mmcv.parallel import MMDataParallel from mmdet.apis import single_gpu_test from mmdet.datasets import (build_dataloader, build_dataset, replace_ImageToTensor) def parse_args(): parser = argparse.ArgumentParser( ...
5,433
37
78
py
DDOD
DDOD-main/tools/deployment/onnx2tensorrt.py
import argparse import os import os.path as osp import warnings import numpy as np import onnx import torch from mmcv import Config from mmcv.tensorrt import is_tensorrt_plugin_loaded, onnx2trt, save_trt_engine from mmdet.core.export import preprocess_example_input from mmdet.core.export.model_wrappers import (ONNXRu...
8,467
32.338583
78
py
DDOD
DDOD-main/tools/deployment/mmdet_handler.py
import base64 import os import mmcv import torch from ts.torch_handler.base_handler import BaseHandler from mmdet.apis import inference_detector, init_detector class MMdetHandler(BaseHandler): threshold = 0.5 def initialize(self, context): properties = context.system_properties self.map_loc...
2,462
34.185714
79
py
DDOD
DDOD-main/tools/deployment/pytorch2onnx.py
import argparse import os.path as osp import warnings from functools import partial import numpy as np import onnx import torch from mmcv import Config, DictAction from mmdet.core.export import build_model_from_cfg, preprocess_example_input from mmdet.core.export.model_wrappers import ONNXRuntimeDetector def pytorc...
10,374
32.905229
79
py
DDOD
DDOD-main/tools/misc/print_config.py
import argparse import warnings from mmcv import Config, DictAction def parse_args(): parser = argparse.ArgumentParser(description='Print the whole config') parser.add_argument('config', help='config file path') parser.add_argument( '--options', nargs='+', action=DictAction, ...
1,848
32.618182
78
py
DDOD
DDOD-main/tools/misc/browse_dataset.py
import argparse import os from pathlib import Path import mmcv from mmcv import Config, DictAction from mmdet.core.utils import mask2ndarray from mmdet.core.visualization import imshow_det_bboxes from mmdet.datasets.builder import build_dataset def parse_args(): parser = argparse.ArgumentParser(description='Bro...
3,031
30.257732
78
py
DDOD
DDOD-main/tools/model_converters/selfsup2mmdet.py
import argparse from collections import OrderedDict import torch def moco_convert(src, dst): """Convert keys in pycls pretrained moco models to mmdet style.""" # load caffe model moco_model = torch.load(src) blobs = moco_model['state_dict'] # convert to pytorch style state_dict = OrderedDict(...
1,195
27.47619
74
py
DDOD
DDOD-main/tools/model_converters/publish_model.py
import argparse import subprocess import torch def parse_args(): parser = argparse.ArgumentParser( description='Process a checkpoint to be published') parser.add_argument('in_file', help='input checkpoint filename') parser.add_argument('out_file', help='output checkpoint filename') args = par...
1,253
28.162791
78
py
DDOD
DDOD-main/tools/model_converters/regnet2mmdet.py
import argparse from collections import OrderedDict import torch def convert_stem(model_key, model_weight, state_dict, converted_names): new_key = model_key.replace('stem.conv', 'conv1') new_key = new_key.replace('stem.bn', 'bn1') state_dict[new_key] = model_weight converted_names.add(model_key) ...
3,015
32.511111
77
py
DDOD
DDOD-main/tools/model_converters/upgrade_model_version.py
import argparse import re import tempfile from collections import OrderedDict import torch from mmcv import Config def is_head(key): valid_head_list = [ 'bbox_head', 'mask_head', 'semantic_head', 'grid_head', 'mask_iou_head' ] return any(key.startswith(h) for h in valid_head_list) def parse_co...
6,800
31.385714
79
py
DDOD
DDOD-main/tools/model_converters/upgrade_ssd_version.py
import argparse import tempfile from collections import OrderedDict import torch from mmcv import Config def parse_config(config_strings): temp_file = tempfile.NamedTemporaryFile() config_path = f'{temp_file.name}.py' with open(config_path, 'w') as f: f.write(config_strings) config = Config....
1,741
29.034483
78
py
DDOD
DDOD-main/tools/model_converters/detectron2pytorch.py
import argparse from collections import OrderedDict import mmcv import torch arch_settings = {50: (3, 4, 6, 3), 101: (3, 4, 23, 3)} def convert_bn(blobs, state_dict, caffe_name, torch_name, converted_names): # detectron replace bn with affine channel layer state_dict[torch_name + '.bias'] = torch.from_numpy...
3,530
41.542169
78
py
DDOD
DDOD-main/tools/dataset_converters/cityscapes.py
import argparse import glob import os.path as osp import cityscapesscripts.helpers.labels as CSLabels import mmcv import numpy as np import pycocotools.mask as maskUtils def collect_files(img_dir, gt_dir): suffix = 'leftImg8bit.png' files = [] for img_file in glob.glob(osp.join(img_dir, '**/*.png')): ...
5,124
32.717105
75
py
DDOD
DDOD-main/tools/dataset_converters/pascal_voc.py
import argparse import os.path as osp import xml.etree.ElementTree as ET import mmcv import numpy as np from mmdet.core import voc_classes label_ids = {name: i for i, name in enumerate(voc_classes())} def parse_xml(args): xml_path, img_path = args tree = ET.parse(xml_path) root = tree.getroot() siz...
7,793
31.886076
79
py
DDOD
DDOD-main/tools/analysis_tools/analyze_results.py
import argparse import os.path as osp import mmcv import numpy as np from mmcv import Config, DictAction from mmdet.core.evaluation import eval_map from mmdet.core.visualization import imshow_gt_det_bboxes from mmdet.datasets import build_dataset, get_loading_pipeline def bbox_map_eval(det_result, annotation): ...
7,048
33.724138
78
py
DDOD
DDOD-main/tools/analysis_tools/eval_metric.py
import argparse import mmcv from mmcv import Config, DictAction from mmdet.datasets import build_dataset def parse_args(): parser = argparse.ArgumentParser(description='Evaluate metric of the ' 'results saved in pkl format') parser.add_argument('config', help='Config of ...
3,070
35.559524
79
py
DDOD
DDOD-main/tools/analysis_tools/benchmark.py
import argparse import os import time import torch from mmcv import Config, DictAction from mmcv.cnn import fuse_conv_bn from mmcv.parallel import MMDistributedDataParallel from mmcv.runner import init_dist, load_checkpoint, wrap_fp16_model from mmdet.datasets import (build_dataloader, build_dataset, ...
4,795
32.538462
78
py
DDOD
DDOD-main/tools/analysis_tools/get_flops.py
import argparse import torch from mmcv import Config, DictAction from mmdet.models import build_detector try: from mmcv.cnn import get_model_complexity_info except ImportError: raise ImportError('Please upgrade mmcv to >0.6.2') def parse_args(): parser = argparse.ArgumentParser(description='Train a det...
2,566
30.304878
79
py
DDOD
DDOD-main/tools/analysis_tools/analyze_logs.py
import argparse import json from collections import defaultdict import matplotlib.pyplot as plt import numpy as np import seaborn as sns def cal_train_time(log_dicts, args): for i, log_dict in enumerate(log_dicts): print(f'{"-" * 5}Analyze train time of {args.json_logs[i]}{"-" * 5}') all_times = ...
6,252
33.738889
79
py
DDOD
DDOD-main/tools/analysis_tools/test_robustness.py
import argparse import copy import os import os.path as osp import mmcv import torch from mmcv import DictAction from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import (get_dist_info, init_dist, load_checkpoint, wrap_fp16_model) from pycocotools.coco import...
15,373
38.319693
79
py
DDOD
DDOD-main/tools/analysis_tools/coco_error_analysis.py
import copy import os from argparse import ArgumentParser from multiprocessing import Pool import matplotlib.pyplot as plt import numpy as np from pycocotools.coco import COCO from pycocotools.cocoeval import COCOeval def makeplot(rs, ps, outDir, class_name, iou_type): cs = np.vstack([ np.ones((2, 3)), ...
12,341
35.40708
79
py
DDOD
DDOD-main/tools/analysis_tools/robustness_eval.py
import os.path as osp from argparse import ArgumentParser import mmcv import numpy as np def print_coco_results(results): def _print(result, ap=1, iouThr=None, areaRng='all', maxDets=100): titleStr = 'Average Precision' if ap == 1 else 'Average Recall' typeStr = '(AP)' if ap == 1 else '(AR)' ...
8,064
31.131474
79
py
DDOD
DDOD-main/crowd_code/check_anno.py
import mmcv data_path = '/mnt/cache/chenzehui/code/DDOD/data/crowdhuman/annotations/val.json' data = mmcv.load(data_path) print(data['annotations'][0]) print(data['images'][0]) print(data['categories'])
204
24.625
81
py
DDOD
DDOD-main/crowd_code/create_crowd_anno.py
import argparse import os import pickle as pkl import numpy as np import random from PIL import Image import concurrent.futures import json import mmcv def parse_args(): parser = argparse.ArgumentParser(description='Generate MMDetection Annotations for Crowdhuman-like dataset') parser.add_argument('--dataset',...
3,013
30.726316
112
py
DDOD
DDOD-main/crowd_code/eval_crowd_metric.py
import mmcv import numpy as np from pycocotools.coco import COCO from evaluate import compute_JI, compute_APMR import json from utils import misc_utils anno_path = './data/crowdhuman/annotations/annotation_val.json' pred_path = './work_dirs/results.pkl' anno_data = COCO(anno_path) pred_data = mmcv.load(pred_path) im...
2,244
33.538462
115
py
DDOD
DDOD-main/crowd_code/evaluate/compute_APMR.py
import argparse from .APMRToolkits import * dbName = 'human' def compute_APMR(dt_path, gt_path, target_key=None, mode=0): database = Database(gt_path, dt_path, target_key, None, mode) database.compare() mAP,_ = database.eval_AP() mMR,_ = database.eval_MR() line = 'AP:{:.4f}, MR:{:.4f}.'.format(mAP,...
712
36.526316
93
py
DDOD
DDOD-main/crowd_code/evaluate/compute_JI.py
import os import sys import math import argparse from multiprocessing import Queue, Process from tqdm import tqdm import numpy as np from .JIToolkits.JI_tools import compute_matching, get_ignores sys.path.insert(0, '../') import utils.misc_utils as misc_utils gtfile = '/data/annotation_val.odgt' nr_procs = 10 def e...
5,048
37.838462
126
py
DDOD
DDOD-main/crowd_code/evaluate/__init__.py
0
0
0
py
DDOD
DDOD-main/crowd_code/evaluate/APMRToolkits/image.py
import numpy as np class Image(object): def __init__(self, mode): self.ID = None self._width = None self._height = None self.dtboxes = None self.gtboxes = None self.eval_mode = mode self._ignNum = None self._gtNum = None self._dtNum = None ...
12,322
41.05802
121
py
DDOD
DDOD-main/crowd_code/evaluate/APMRToolkits/database.py
import os import json import numpy as np from .image import * PERSON_CLASSES = ['background', 'person'] # DBBase class Database(object): def __init__(self, gtpath=None, dtpath=None, body_key=None, head_key=None, mode=0): """ mode=0: only body; mode=1: only head """ self.images = dic...
4,972
33.776224
97
py
DDOD
DDOD-main/crowd_code/evaluate/APMRToolkits/__init__.py
# -*- coding:utf8 -*- __author__ = 'jyn' __email__ = '[email protected]' from .image import * from .database import *
116
15.714286
28
py
DDOD
DDOD-main/crowd_code/evaluate/JIToolkits/matching.py
"""Weighted maximum matching in general graphs. The algorithm is taken from "Efficient Algorithms for Finding Maximum Matching in Graphs" by Zvi Galil, ACM Computing Surveys, 1986. It is based on the "blossom" method for finding augmenting paths and the "primal-dual" method for finding a matching of maximum weight, bo...
35,792
40.523202
150
py
DDOD
DDOD-main/crowd_code/evaluate/JIToolkits/JI_tools.py
#coding:utf-8 import numpy as np from .matching import maxWeightMatching def compute_matching(dt_boxes, gt_boxes, bm_thr): assert dt_boxes.shape[-1] > 3 and gt_boxes.shape[-1] > 3 if dt_boxes.shape[0] < 1 or gt_boxes.shape[0] < 1: return list() N, K = dt_boxes.shape[0], gt_boxes.shape[0] ious =...
5,635
41.37594
108
py
DDOD
DDOD-main/crowd_code/utils/misc_utils.py
import os import json import numpy as np def load_img(image_path): import cv2 img = cv2.imread(image_path, cv2.IMREAD_COLOR) return img def load_json_lines(fpath): assert os.path.exists(fpath) with open(fpath,'r') as fid: lines = fid.readlines() records = [json.loads(line.strip('\n')) ...
3,810
30.495868
117
py
DDOD
DDOD-main/crowd_code/utils/SGD_bias.py
import torch from torch.optim.optimizer import Optimizer, required class SGD(Optimizer): """Implements stochastic gradient descent (optionally with momentum). Args: params (iterable): iterable of parameters to optimize or dicts defining parameter groups lr (float): learning rate ...
2,777
39.26087
88
py
DDOD
DDOD-main/crowd_code/utils/nms_utils.py
import numpy as np import pdb def set_cpu_nms(dets, thresh): """Pure Python NMS baseline.""" def _overlap(det_boxes, basement, others): eps = 1e-8 x1_basement, y1_basement, x2_basement, y2_basement \ = det_boxes[basement, 0], det_boxes[basement, 1], \ det_boxes...
3,035
32.362637
82
py
DDOD
DDOD-main/crowd_code/utils/visual_utils.py
import os import json import numpy as np import cv2 color = {'green':(0,255,0), 'blue':(255,165,0), 'dark red':(0,0,139), 'red':(0, 0, 255), 'dark slate blue':(139,61,72), 'aqua':(255,255,0), 'brown':(42,42,165), 'deep pink':(147,20,255), 'fuchisia':(255,...
1,161
32.2
101
py
DDOD
DDOD-main/.dev_scripts/convert_train_benchmark_script.py
import argparse import os import os.path as osp def parse_args(): parser = argparse.ArgumentParser( description='Convert benchmark model json to script') parser.add_argument( 'txt_path', type=str, help='txt path output by benchmark_filter') parser.add_argument( '--partition', ...
3,259
31.929293
74
py
DDOD
DDOD-main/.dev_scripts/gather_test_benchmark_metric.py
import argparse import glob import os.path as osp import mmcv from mmcv import Config def parse_args(): parser = argparse.ArgumentParser( description='Gather benchmarked models metric') parser.add_argument('config', help='test config file path') parser.add_argument( 'root', type=s...
3,868
39.302083
79
py
DDOD
DDOD-main/.dev_scripts/benchmark_filter.py
import argparse import os import os.path as osp def parse_args(): parser = argparse.ArgumentParser(description='Filter configs to train') parser.add_argument( '--basic-arch', action='store_true', help='to train models in basic arch') parser.add_argument( '--datasets', actio...
7,048
41.209581
92
py
DDOD
DDOD-main/.dev_scripts/gather_models.py
import argparse import glob import json import os.path as osp import shutil import subprocess from collections import OrderedDict import mmcv import torch import yaml def ordered_yaml_dump(data, stream=None, Dumper=yaml.SafeDumper, **kwds): class OrderedDumper(Dumper): pass def _dict_representer(du...
9,240
34.817829
79
py
DDOD
DDOD-main/.dev_scripts/benchmark_inference_fps.py
import argparse import os import os.path as osp import mmcv from mmcv import Config, DictAction from mmcv.runner import init_dist from tools.analysis_tools.benchmark import measure_inferense_speed def parse_args(): parser = argparse.ArgumentParser( description='MMDet benchmark a model of FPS') parser...
3,578
37.074468
79
py
DDOD
DDOD-main/.dev_scripts/gather_train_benchmark_metric.py
import argparse import glob import os.path as osp import mmcv from gather_models import get_final_results try: import xlrd except ImportError: xlrd = None try: import xlutils from xlutils.copy import copy except ImportError: xlutils = None def parse_args(): parser = argparse.ArgumentParser( ...
5,795
37.64
79
py
DDOD
DDOD-main/.dev_scripts/batch_test_list.py
# yapf: disable atss = dict( config='configs/atss/atss_r50_fpn_1x_coco.py', checkpoint='atss_r50_fpn_1x_coco_20200209-985f7bd0.pth', eval='bbox', metric=dict(bbox_mAP=39.4), ) autoassign = dict( config='configs/autoassign/autoassign_r50_fpn_8x2_1x_coco.py', checkpoint='auto_assign_r50_fpn_1x_coc...
12,184
34.318841
117
py
DDOD
DDOD-main/.dev_scripts/benchmark_test_image.py
import logging import os.path as osp from argparse import ArgumentParser from mmcv import Config from mmdet.apis import inference_detector, init_detector, show_result_pyplot from mmdet.utils import get_root_logger def parse_args(): parser = ArgumentParser() parser.add_argument('config', help='test config fi...
3,626
34.558824
77
py
DDOD
DDOD-main/.dev_scripts/convert_test_benchmark_script.py
import argparse import os import os.path as osp from mmcv import Config def parse_args(): parser = argparse.ArgumentParser( description='Convert benchmark model list to script') parser.add_argument('config', help='test config file path') parser.add_argument('--port', type=int, default=29666, help...
3,556
28.890756
79
py
DDOD
DDOD-main/tests/test_runtime/async_benchmark.py
import asyncio import os import shutil import urllib import mmcv import torch from mmdet.apis import (async_inference_detector, inference_detector, init_detector) from mmdet.utils.contextmanagers import concurrent from mmdet.utils.profiling import profile_time async def main(): """Benchm...
3,167
30.058824
77
py
DDOD
DDOD-main/tests/test_runtime/test_async.py
"""Tests for async interface.""" import asyncio import os import sys import asynctest import mmcv import torch from mmdet.apis import async_inference_detector, init_detector if sys.version_info >= (3, 7): from mmdet.utils.contextmanagers import concurrent class AsyncTestCase(asynctest.TestCase): use_defau...
2,560
29.855422
75
py
DDOD
DDOD-main/tests/test_runtime/test_config.py
from os.path import dirname, exists, join, relpath from unittest.mock import Mock import pytest import torch from mmcv.runner import build_optimizer from mmdet.core import BitmapMasks, PolygonMasks from mmdet.datasets.builder import DATASETS from mmdet.datasets.utils import NumClassCheckHook def _get_config_directo...
17,127
39.112412
79
py
DDOD
DDOD-main/tests/test_runtime/test_eval_hook.py
import os.path as osp import tempfile import unittest.mock as mock from collections import OrderedDict from unittest.mock import MagicMock, patch import pytest import torch import torch.nn as nn from mmcv.runner import EpochBasedRunner, build_optimizer from mmcv.utils import get_logger from torch.utils.data import Dat...
8,542
32.900794
79
py
DDOD
DDOD-main/tests/test_runtime/test_fp16.py
import numpy as np import pytest import torch import torch.nn as nn from mmcv.runner import auto_fp16, force_fp32 from mmcv.runner.fp16_utils import cast_tensor_type def test_cast_tensor_type(): inputs = torch.FloatTensor([5.]) src_type = torch.float32 dst_type = torch.int32 outputs = cast_tensor_type...
9,698
31.222591
75
py
DDOD
DDOD-main/tests/test_models/test_loss.py
import pytest import torch from mmdet.models.losses import (BalancedL1Loss, BoundedIoULoss, CIoULoss, CrossEntropyLoss, DIoULoss, DistributionFocalLoss, FocalLoss, GaussianFocalLoss, GIoULoss, IoULoss, L1Loss, ...
3,668
34.970588
79
py
DDOD
DDOD-main/tests/test_models/test_forward.py
"""pytest tests/test_forward.py.""" import copy from os.path import dirname, exists, join import numpy as np import pytest import torch def _get_config_directory(): """Find the predefined detector config directory.""" try: # Assume we are running in the source mmdetection repo repo_dpath = di...
19,749
30.701445
110
py
DDOD
DDOD-main/tests/test_models/test_necks.py
import pytest import torch from torch.nn.modules.batchnorm import _BatchNorm from mmdet.models.necks import (FPN, ChannelMapper, CTResNetNeck, DilatedEncoder, SSDNeck, YOLOV3Neck) def test_fpn(): """Tests fpn.""" s = 64 in_channels = [8, 16, 32, 64] feat_sizes = [s // ...
12,179
31.393617
79
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_hourglass.py
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.raises(AssertionError): # len(stage_channels...
1,301
27.933333
65
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_res2net.py
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', 'caffe'] Bottle2neck(64, 64, base_width=26, s...
1,961
30.142857
72
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_resnet.py
import pytest import torch from mmcv import assert_params_all_zeros 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, Bottle...
23,501
34.235382
78
py
DDOD
DDOD-main/tests/test_models/test_backbones/utils.py
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 BottleneckX from mmdet.models.utils import Simplified...
978
29.59375
77
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_mobilenet_v2.py
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(): with pytest.raises(ValueError): # frozen_...
6,748
35.879781
77
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_renext.py
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 ['pytorch', 'caffe'] BottleneckX(64, 64, grou...
3,513
32.150943
73
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_trident_resnet.py
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 trident_build_config = (trident_dilations, test_...
6,353
34.104972
79
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_resnest.py
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'] BottleneckS(64, 64, radix=2, reduction_factor=4, st...
1,420
31.295455
76
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_regnet.py
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.28, group_w=16, depth=16, bot_mul=1.0),...
2,168
35.762712
73
py
DDOD
DDOD-main/tests/test_models/test_backbones/__init__.py
from .utils import check_norm_state, is_block, is_norm __all__ = ['is_block', 'is_norm', 'check_norm_state']
110
26.75
54
py
DDOD
DDOD-main/tests/test_models/test_backbones/test_detectors_resnet.py
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', requires_grad=True), norm_eval=True, ...
1,561
32.234043
77
py
DDOD
DDOD-main/tests/test_models/test_utils/test_position_encoding.py
import pytest import torch from mmdet.models.utils import (LearnedPositionalEncoding, SinePositionalEncoding) def test_sine_positional_encoding(num_feats=16, batch_size=2): # test invalid type of scale with pytest.raises(AssertionError): module = SinePositionalEncoding...
1,389
34.641026
79
py
DDOD
DDOD-main/tests/test_models/test_utils/test_se_layer.py
import pytest import torch from mmdet.models.utils import SELayer def test_se_layer(): with pytest.raises(AssertionError): # act_cfg sequence length must equal to 2 SELayer(channels=32, act_cfg=(dict(type='ReLU'), )) with pytest.raises(AssertionError): # act_cfg sequence must be a tu...
626
25.125
76
py
DDOD
DDOD-main/tests/test_models/test_utils/test_inverted_residual.py
import pytest import torch from mmcv.cnn import is_norm from torch.nn.modules import GroupNorm from mmdet.models.utils import InvertedResidual, SELayer def test_inverted_residual(): with pytest.raises(AssertionError): # stride must be in [1, 2] InvertedResidual(16, 16, 32, stride=3) with py...
2,587
33.052632
71
py
DDOD
DDOD-main/tests/test_models/test_utils/test_transformer.py
import pytest from mmcv.utils import ConfigDict from mmdet.models.utils.transformer import (DetrTransformerDecoder, DetrTransformerEncoder, Transformer) def test_detr_transformer_dencoder_encoder_layer(): config = ConfigDict(...
4,037
35.378378
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_anchor_head.py
import mmcv import torch from mmdet.models.dense_heads import AnchorHead def test_anchor_head_loss(): """Tests anchor head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] cfg = mmcv.Con...
2,500
34.728571
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_centernet_head.py
import numpy as np import torch from mmcv import ConfigDict from mmdet.models.dense_heads import CenterNetHead def test_center_head_loss(): """Tests center head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape'...
4,337
39.542056
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_dense_heads_attr.py
import warnings from terminaltables import AsciiTable from mmdet.models import dense_heads from mmdet.models.dense_heads import * # noqa: F401,F403 def test_dense_heads_test_attr(): """Tests inference methods such as simple_test and aug_test.""" # make list of dense heads exceptions = ['FeatureAdaption...
1,654
36.613636
77
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_ga_anchor_head.py
import mmcv import torch from mmdet.models.dense_heads import GuidedAnchorHead def test_ga_anchor_head_loss(): """Tests anchor head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] cfg =...
3,362
35.956044
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_yolof_head.py
import mmcv import torch from mmdet.models.dense_heads import YOLOFHead def test_yolof_head_loss(): """Tests yolof head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] train_cfg = mmcv.C...
2,668
34.118421
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_vfnet_head.py
import mmcv import torch from mmdet.models.dense_heads import VFNetHead def test_vfnet_head_loss(): """Tests vfnet head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] train_cfg = mmcv.C...
2,513
38.904762
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_pisa_head.py
import mmcv import torch from mmdet.models.dense_heads import PISARetinaHead, PISASSDHead from mmdet.models.roi_heads import PISARoIHead def test_pisa_retinanet_head_loss(): """Tests pisa retinanet head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), ...
8,757
34.746939
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_corner_head.py
import torch from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps from mmdet.models.dense_heads import CornerHead def test_corner_head_loss(): """Tests corner head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, ...
6,708
39.173653
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_fsaf_head.py
import mmcv import torch from mmdet.models.dense_heads import FSAFHead def test_fsaf_head_loss(): """Tests anchor head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] cfg = dict( ...
3,049
36.195122
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_autoassign_head.py
import mmcv import torch from mmdet.models.dense_heads.autoassign_head import AutoAssignHead from mmdet.models.dense_heads.paa_head import levels_to_images def test_autoassign_head_loss(): """Tests autoassign head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s,...
3,430
36.293478
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_ld_head.py
import mmcv import torch from mmdet.models.dense_heads import GFLHead, LDHead def test_ld_head_loss(): """Tests vfnet head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] train_cfg = mmc...
4,557
36.669421
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_paa_head.py
import mmcv import numpy as np import torch from mmdet.models.dense_heads import PAAHead, paa_head from mmdet.models.dense_heads.paa_head import levels_to_images def test_paa_head_loss(): """Tests paa head loss when truth is empty and non-empty.""" class mock_skm: def GaussianMixture(self, *args, *...
4,193
33.097561
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_detr_head.py
import torch from mmcv import ConfigDict from mmdet.models.dense_heads import DETRHead def test_detr_head_loss(): """Tests transformer head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3), ...
4,082
38.259615
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_fcos_head.py
import mmcv import torch from mmdet.models.dense_heads import FCOSHead def test_fcos_head_loss(): """Tests fcos head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] train_cfg = mmcv.Conf...
2,358
35.859375
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_yolact_head.py
import mmcv import torch from mmdet.models.dense_heads import YOLACTHead, YOLACTProtonet, YOLACTSegmHead def test_yolact_head_loss(): """Tests yolact head losses when truth is empty and non-empty.""" s = 550 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s...
5,199
36.956204
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_sabl_retina_head.py
import mmcv import torch from mmdet.models.dense_heads import SABLRetinaHead def test_sabl_retina_head_loss(): """Tests anchor head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] cfg =...
3,032
38.907895
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_atss_head.py
import mmcv import torch from mmdet.models.dense_heads import ATSSHead def test_atss_head_loss(): """Tests atss head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] train_cfg = mmcv.Conf...
2,901
36.688312
79
py
DDOD
DDOD-main/tests/test_models/test_dense_heads/test_gfl_head.py
import mmcv import torch from mmdet.models.dense_heads import GFLHead def test_gfl_head_loss(): """Tests gfl head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape': (s, s, 3) }] train_cfg = mmcv.Config(...
2,738
36.013514
79
py
DDOD
DDOD-main/tests/test_models/test_roi_heads/test_roi_extractor.py
import pytest import torch from mmdet.models.roi_heads.roi_extractors import GenericRoIExtractor def test_groie(): # test with pre/post cfg = dict( roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=2), out_channels=256, featmap_strides=[4, 8, 16, 32], pre_cfg=dict(...
3,209
27.157895
77
py
DDOD
DDOD-main/tests/test_models/test_roi_heads/utils.py
import torch from mmdet.core import build_assigner, build_sampler def _dummy_bbox_sampling(proposal_list, gt_bboxes, gt_labels): """Create sample results that can be passed to BBoxHead.get_targets.""" num_imgs = 1 feat = torch.rand(1, 1, 3, 3) assign_config = dict( type='MaxIoUAssigner', ...
1,201
30.631579
79
py
DDOD
DDOD-main/tests/test_models/test_roi_heads/test_mask_head.py
import mmcv import torch from mmdet.models.roi_heads.mask_heads import FCNMaskHead, MaskIoUHead from .utils import _dummy_bbox_sampling def test_mask_head_loss(): """Test mask head loss when mask target is empty.""" self = FCNMaskHead( num_convs=1, roi_feat_size=6, in_channels=8, ...
2,440
33.871429
79
py
DDOD
DDOD-main/tests/test_models/test_roi_heads/__init__.py
from .utils import _dummy_bbox_sampling __all__ = ['_dummy_bbox_sampling']
76
18.25
39
py
DDOD
DDOD-main/tests/test_models/test_roi_heads/test_sabl_bbox_head.py
import mmcv import torch from mmdet.core import bbox2roi from mmdet.models.roi_heads.bbox_heads import SABLHead from .utils import _dummy_bbox_sampling def test_sabl_bbox_head_loss(): """Tests bbox head loss when truth is empty and non-empty.""" self = SABLHead( num_classes=4, cls_in_channels...
2,931
37.077922
75
py
DDOD
DDOD-main/tests/test_models/test_roi_heads/test_bbox_head.py
import mmcv import numpy as np import pytest import torch from mmdet.core import bbox2roi from mmdet.models.roi_heads.bbox_heads import BBoxHead from .utils import _dummy_bbox_sampling def test_bbox_head_loss(): """Tests bbox head loss when truth is empty and non-empty.""" self = BBoxHead(in_channels=8, roi_...
7,901
30.482072
78
py
DDOD
DDOD-main/tests/test_onnx/utils.py
import os import os.path as osp import warnings import numpy as np import onnx import onnxruntime as ort import torch import torch.nn as nn ort_custom_op_path = '' try: from mmcv.ops import get_onnxruntime_op_path ort_custom_op_path = get_onnxruntime_op_path() except (ImportError, ModuleNotFoundError): wa...
4,093
28.883212
79
py
DDOD
DDOD-main/tests/test_onnx/test_neck.py
import os.path as osp import mmcv import pytest import torch from mmdet import digit_version from mmdet.models.necks import FPN, YOLOV3Neck from .utils import ort_validate if digit_version(torch.__version__) <= digit_version('1.5.0'): pytest.skip( 'ort backend does not support version below 1.5.0', ...
4,760
28.208589
77
py
DDOD
DDOD-main/tests/test_onnx/__init__.py
from .utils import ort_validate __all__ = ['ort_validate']
60
14.25
31
py