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
insightface
challenges/iccv19-lfr/gen_video_feature.py
.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os from datetime import datetime import os.path from easydict import EasyDict as edict import time import json import glob import sys import numpy as np import importlib import itertools import argparse...
216
7,154
insightface
examples/demo_analysis.py
.py
import argparse import cv2 import sys import numpy as np import insightface from insightface.app import FaceAnalysis from insightface.data import get_image as ins_get_image assert insightface.__version__>='0.3' parser = argparse.ArgumentParser(description='insightface app test') # general parser.add_argument('--ctx',...
35
985
insightface
examples/mask_renderer.py
.py
import os, sys, datetime import numpy as np import os.path as osp import cv2 import insightface from insightface.app import MaskRenderer from insightface.data import get_image as ins_get_image if __name__ == "__main__": #make sure that you have download correct insightface model pack. #make sure that BFM.mat ...
23
648
insightface
examples/mxnet_to_onnx.py
.py
import sys import os import argparse import onnx import json import mxnet as mx from onnx import helper from onnx import TensorProto from onnx import numpy_helper import onnxruntime import cv2 print('mxnet version:', mx.__version__) print('onnx version:', onnx.__version__) assert mx.__version__ >= '1.8', 'mxnet versi...
179
5,693
insightface
examples/face_recognition/insightface_app.py
.py
import cv2 import insightface import numpy as np from insightface.app import FaceAnalysis # Initialize face analysis model app = FaceAnalysis(name='buffalo_l', providers=['CPUExecutionProvider']) # Use 'CUDAExecutionProvider' for GPU app.prepare(ctx_id=-1) # ctx_id=-1 for CPU, 0 for GPU def get_face_embedding(image...
47
1,518
insightface
examples/person_detection/scrfd_person.py
.py
import datetime import numpy as np import os import os.path as osp import glob import cv2 import insightface assert insightface.__version__>='0.4' def detect_person(img, detector): bboxes, kpss = detector.detect(img) bboxes = np.round(bboxes[:,:4]).astype(np.int) kpss = np.round(kpss).astype(np.int) ...
49
1,681
insightface
examples/in_swapper/inswapper_main.py
.py
import datetime import numpy as np import os import os.path as osp import glob import cv2 import insightface from insightface.app import FaceAnalysis from insightface.data import get_image as ins_get_image assert insightface.__version__>='0.7' if __name__ == '__main__': app = FaceAnalysis(name='buffalo_l') a...
36
972
insightface
detection/retinaface_anticov/retinaface_cov.py
.py
from __future__ import print_function import sys import os import datetime import time import numpy as np import mxnet as mx from mxnet import ndarray as nd import cv2 #from rcnn import config #from rcnn.processing.bbox_transform import nonlinear_pred, clip_boxes, landmark_pred from rcnn.processing.bbox_transform impor...
753
31,010
insightface
detection/retinaface_anticov/test.py
.py
import cv2 import sys import numpy as np import datetime import os import glob from retinaface_cov import RetinaFaceCoV thresh = 0.8 mask_thresh = 0.2 scales = [640, 1080] count = 1 gpuid = 0 #detector = RetinaFaceCoV('./model/mnet_cov1', 0, gpuid, 'net3') detector = RetinaFaceCoV('./model/mnet_cov2', 0, gpuid, 'net...
67
1,856
insightface
detection/retinaface_anticov/rcnn/processing/generate_anchor.py
.py
""" Generate base anchors on index 0 """ from __future__ import print_function import sys from builtins import range import numpy as np from ..cython.anchors import anchors_cython #from ..config import config def anchors_plane(feat_h, feat_w, stride, base_anchor): return anchors_cython(feat_h, feat_w, stride, bas...
136
4,043
insightface
detection/retinaface_anticov/rcnn/processing/assign_levels.py
.py
from rcnn.config import config import numpy as np def compute_assign_targets(rois, threshold): rois_area = np.sqrt( (rois[:, 2] - rois[:, 0] + 1) * (rois[:, 3] - rois[:, 1] + 1)) num_rois = np.shape(rois)[0] assign_levels = np.zeros(num_rois, dtype=np.uint8) for i, stride in enumerate(config.R...
37
1,167
insightface
detection/retinaface_anticov/rcnn/processing/nms.py
.py
import numpy as np from ..cython.cpu_nms import cpu_nms try: from ..cython.gpu_nms import gpu_nms except ImportError: gpu_nms = None def py_nms_wrapper(thresh): def _nms(dets): return nms(dets, thresh) return _nms def cpu_nms_wrapper(thresh): def _nms(dets): return cpu_nms(dets,...
68
1,546
insightface
detection/retinaface_anticov/rcnn/processing/bbox_regression.py
.py
""" This file has functions about generating bounding box regression targets """ from ..pycocotools.mask import encode import numpy as np from ..logger import logger from .bbox_transform import bbox_overlaps, bbox_transform from rcnn.config import config import math import cv2 import PIL.Image as Image import threadi...
264
10,196
insightface
detection/retinaface_anticov/rcnn/processing/bbox_transform.py
.py
import numpy as np from ..cython.bbox import bbox_overlaps_cython #from rcnn.config import config def bbox_overlaps(boxes, query_boxes): return bbox_overlaps_cython(boxes, query_boxes) def bbox_overlaps_py(boxes, query_boxes): """ determine overlaps between boxes and query_boxes :param boxes: n * 4 ...
224
7,386
insightface
detection/blazeface_paddle/test_blazeface.py
.py
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
594
21,321
insightface
detection/scrfd/setup.py
.py
#!/usr/bin/env python import os from setuptools import find_packages, setup import torch from torch.utils.cpp_extension import (BuildExtension, CppExtension, CUDAExtension) def readme(): with open('README.md', encoding='utf-8') as f: content = f.read() return co...
162
5,864
insightface
detection/scrfd/demo/image_demo.py
.py
from argparse import ArgumentParser from mmdet.apis import inference_detector, init_detector, show_result_pyplot def main(): parser = ArgumentParser() parser.add_argument('img', help='Image file') parser.add_argument('config', help='Config file') parser.add_argument('checkpoint', help='Checkpoint fil...
27
906
insightface
detection/scrfd/demo/webcam_demo.py
.py
import argparse import cv2 import torch from mmdet.apis import inference_detector, init_detector def parse_args(): parser = argparse.ArgumentParser(description='MMDetection webcam demo') parser.add_argument('config', help='test config file path') parser.add_argument('checkpoint', help='checkpoint file')...
47
1,260
insightface
detection/scrfd/mmdet/__init__.py
.py
import mmcv from .version import __version__, short_version def digit_version(version_str): digit_version = [] for x in version_str.split('.'): if x.isdigit(): digit_version.append(int(x)) elif x.find('rc') != -1: patch_version = x.split('rc') digit_version...
30
859
insightface
detection/scrfd/mmdet/version.py
.py
# Copyright (c) Open-MMLab. All rights reserved. __version__ = '2.7.0' short_version = __version__ def parse_version_info(version_str): version_info = [] for x in version_str.split('.'): if x.isdigit(): version_info.append(int(x)) elif x.find('rc') != -1: patch_version...
20
529
insightface
detection/scrfd/mmdet/apis/inference.py
.py
import warnings import matplotlib.pyplot as plt import mmcv import numpy as np import torch from mmcv.ops import RoIPool from mmcv.parallel import collate, scatter from mmcv.runner import load_checkpoint from mmdet.core import get_classes from mmdet.datasets.pipelines import Compose from mmdet.models import build_det...
188
6,415
insightface
detection/scrfd/mmdet/apis/train.py
.py
import random import numpy as np import torch from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import (HOOKS, DistSamplerSeedHook, EpochBasedRunner, Fp16OptimizerHook, OptimizerHook, build_optimizer) from mmcv.utils import build_from_cfg from mmdet.core imp...
151
5,700
insightface
detection/scrfd/mmdet/apis/__init__.py
.py
from .inference import (async_inference_detector, inference_detector, init_detector, show_result_pyplot) from .test import multi_gpu_test, single_gpu_test from .train import get_root_logger, set_random_seed, train_detector __all__ = [ 'get_root_logger', 'set_random_seed', 'train_detector', ...
11
455
insightface
detection/scrfd/mmdet/apis/test.py
.py
import os.path as osp import pickle import shutil import tempfile import time import mmcv import torch import torch.distributed as dist from mmcv.image import tensor2imgs from mmcv.runner import get_dist_info from mmdet.core import encode_mask_results def single_gpu_test(model, data_loader, ...
191
6,826
insightface
detection/scrfd/mmdet/datasets/retinaface.py
.py
import itertools import logging import os.path as osp import tempfile from collections import OrderedDict import mmcv import numpy as np from mmcv.utils import print_log from terminaltables import AsciiTable from mmdet.core import eval_recalls from .builder import DATASETS from .custom import CustomDataset try: ...
170
5,818
insightface
detection/scrfd/mmdet/datasets/utils.py
.py
import copy import warnings def replace_ImageToTensor(pipelines): """Replace the ImageToTensor transform in a data pipeline to DefaultFormatBundle, which is normally useful in batch inference. Args: pipelines (list[dict]): Data pipeline configs. Returns: list: The new pipeline list w...
63
2,488
insightface
detection/scrfd/mmdet/datasets/builder.py
.py
import copy import platform import random from functools import partial import numpy as np from mmcv.parallel import collate from mmcv.runner import get_dist_info from mmcv.utils import Registry, build_from_cfg from torch.utils.data import DataLoader from .samplers import DistributedGroupSampler, DistributedSampler, ...
144
5,291
insightface
detection/scrfd/mmdet/datasets/deepfashion.py
.py
from .builder import DATASETS from .coco import CocoDataset @DATASETS.register_module() class DeepFashionDataset(CocoDataset): CLASSES = ('top', 'skirt', 'leggings', 'dress', 'outer', 'pants', 'bag', 'neckwear', 'headwear', 'eyeglass', 'belt', 'footwear', 'hair', 'skin', 'face')
11
317
insightface
detection/scrfd/mmdet/datasets/dataset_wrappers.py
.py
import bisect import math from collections import defaultdict import numpy as np from mmcv.utils import print_log from torch.utils.data.dataset import ConcatDataset as _ConcatDataset from .builder import DATASETS from .coco import CocoDataset @DATASETS.register_module() class ConcatDataset(_ConcatDataset): """A...
283
11,088
insightface
detection/scrfd/mmdet/datasets/custom.py
.py
import os.path as osp import warnings from collections import OrderedDict import mmcv import numpy as np from torch.utils.data import Dataset from mmdet.core import eval_map, eval_recalls from .builder import DATASETS from .pipelines import Compose @DATASETS.register_module() class CustomDataset(Dataset): """Cu...
364
12,932
insightface
detection/scrfd/mmdet/datasets/voc.py
.py
from collections import OrderedDict from mmdet.core import eval_map, eval_recalls from .builder import DATASETS from .xml_style import XMLDataset @DATASETS.register_module() class VOCDataset(XMLDataset): CLASSES = ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'c...
90
3,538
insightface
detection/scrfd/mmdet/datasets/__init__.py
.py
from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset from .cityscapes import CityscapesDataset from .coco import CocoDataset from .custom import CustomDataset from .retinaface import RetinaFaceDataset from .dataset_wrappers import (ClassBalancedDataset, ConcatDataset, ...
25
1,111
insightface
detection/scrfd/mmdet/datasets/cityscapes.py
.py
# Modified from https://github.com/facebookresearch/detectron2/blob/master/detectron2/data/datasets/cityscapes.py # noqa # and https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/evaluation/evalInstanceLevelSemanticLabeling.py # noqa import glob import os import os.path as osp import tempfile fr...
335
14,288
insightface
detection/scrfd/mmdet/datasets/xml_style.py
.py
import os.path as osp import xml.etree.ElementTree as ET import mmcv import numpy as np from PIL import Image from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class XMLDataset(CustomDataset): """XML dataset for detection. Args: min_size (int | float, optio...
170
5,753
insightface
detection/scrfd/mmdet/datasets/wider_face.py
.py
import os.path as osp import xml.etree.ElementTree as ET import mmcv from .builder import DATASETS from .xml_style import XMLDataset @DATASETS.register_module() class WIDERFaceDataset(XMLDataset): """Reader for the WIDER Face dataset in PASCAL VOC format. Conversion scripts can be found in https://gith...
52
1,501
insightface
detection/scrfd/mmdet/datasets/lvis.py
.py
import itertools import logging import os.path as osp import tempfile from collections import OrderedDict import numpy as np from mmcv.utils import print_log from terminaltables import AsciiTable from .builder import DATASETS from .coco import CocoDataset @DATASETS.register_module() class LVISV05Dataset(CocoDataset...
745
46,540
insightface
detection/scrfd/mmdet/datasets/coco.py
.py
import itertools import logging import os.path as osp import tempfile from collections import OrderedDict import mmcv import numpy as np from mmcv.utils import print_log from pycocotools.coco import COCO from pycocotools.cocoeval import COCOeval from terminaltables import AsciiTable from mmdet.core import eval_recall...
545
22,583
insightface
detection/scrfd/mmdet/datasets/pipelines/auto_augment.py
.py
import copy import cv2 import mmcv import numpy as np from ..builder import PIPELINES from .compose import Compose _MAX_LEVEL = 10 def level_to_value(level, max_value): """Map from level to values based on max_value.""" return (level / _MAX_LEVEL) * max_value def enhance_level_to_value(level, a=1.8, b=0....
891
36,390
insightface
detection/scrfd/mmdet/datasets/pipelines/compose.py
.py
import collections from mmcv.utils import build_from_cfg from ..builder import PIPELINES @PIPELINES.register_module() class Compose(object): """Compose multiple transforms sequentially. Args: transforms (Sequence[dict | callable]): Sequence of transform object or config dict to be compo...
52
1,464
insightface
detection/scrfd/mmdet/datasets/pipelines/loading.py
.py
import os.path as osp import mmcv import numpy as np import pycocotools.mask as maskUtils from mmdet.core import BitmapMasks, PolygonMasks from ..builder import PIPELINES @PIPELINES.register_module() class LoadImageFromFile(object): """Load an image from file. Required keys are "img_prefix" and "img_info" ...
481
16,712
insightface
detection/scrfd/mmdet/datasets/pipelines/__init__.py
.py
from .auto_augment import (AutoAugment, BrightnessTransform, ColorTransform, ContrastTransform, EqualizeTransform, Rotate, Shear, Translate) from .compose import Compose from .formating import (Collect, DefaultFormatBundle, ImageToTensor, ToD...
28
1,496
insightface
detection/scrfd/mmdet/datasets/pipelines/transforms.py
.py
import inspect import mmcv import numpy as np from numpy import random import cv2 from mmdet.core import PolygonMasks from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps from ..builder import PIPELINES try: from imagecorruptions import corrupt except ImportError: corrupt = None try: import alb...
2,038
80,945
insightface
detection/scrfd/mmdet/datasets/pipelines/instaboost.py
.py
import numpy as np from ..builder import PIPELINES @PIPELINES.register_module() class InstaBoost(object): r"""Data augmentation method in `InstaBoost: Boosting Instance Segmentation Via Probability Map Guided Copy-Pasting <https://arxiv.org/abs/1908.07801>`_. Refer to https://github.com/GothicAi/Ins...
99
3,494
insightface
detection/scrfd/mmdet/datasets/pipelines/test_time_aug.py
.py
import warnings import mmcv from ..builder import PIPELINES from .compose import Compose @PIPELINES.register_module() class MultiScaleFlipAug(object): """Test-time augmentation with multiple scales and flipping. An example configuration is as followed: .. code-block:: img_scale=[(1333, 400), ...
120
4,401
insightface
detection/scrfd/mmdet/datasets/pipelines/formating.py
.py
from collections.abc import Sequence import mmcv import numpy as np import torch from mmcv.parallel import DataContainer as DC from ..builder import PIPELINES def to_tensor(data): """Convert objects of various python types to :obj:`torch.Tensor`. Supported types are: :class:`numpy.ndarray`, :class:`torch.T...
365
12,054
insightface
detection/scrfd/mmdet/datasets/samplers/distributed_sampler.py
.py
import math import torch from torch.utils.data import DistributedSampler as _DistributedSampler class DistributedSampler(_DistributedSampler): def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): super().__init__(dataset, num_replicas=num_replicas, rank=rank) self.shuffle = s...
33
1,104
insightface
detection/scrfd/mmdet/datasets/samplers/group_sampler.py
.py
from __future__ import division import math import numpy as np import torch from mmcv.runner import get_dist_info from torch.utils.data import Sampler class GroupSampler(Sampler): def __init__(self, dataset, samples_per_gpu=1): assert hasattr(dataset, 'flag') self.dataset = dataset self....
144
5,073
insightface
detection/scrfd/mmdet/datasets/samplers/__init__.py
.py
from .distributed_sampler import DistributedSampler from .group_sampler import DistributedGroupSampler, GroupSampler __all__ = ['DistributedSampler', 'DistributedGroupSampler', 'GroupSampler']
5
194
insightface
detection/scrfd/mmdet/core/mask/utils.py
.py
import mmcv import numpy as np import pycocotools.mask as mask_util def split_combined_polys(polys, poly_lens, polys_per_mask): """Split the combined 1-D polys into masks. A mask is represented as a list of polys, and a poly is represented as a 1-D array. In dataset, all masks are concatenated into a sin...
64
2,291
insightface
detection/scrfd/mmdet/core/mask/__init__.py
.py
from .mask_target import mask_target from .structures import BaseInstanceMasks, BitmapMasks, PolygonMasks from .utils import encode_mask_results, split_combined_polys __all__ = [ 'split_combined_polys', 'mask_target', 'BaseInstanceMasks', 'BitmapMasks', 'PolygonMasks', 'encode_mask_results' ]
9
303
insightface
detection/scrfd/mmdet/core/mask/structures.py
.py
from abc import ABCMeta, abstractmethod import cv2 import mmcv import numpy as np import pycocotools.mask as maskUtils import torch from mmcv.ops.roi_align import roi_align class BaseInstanceMasks(metaclass=ABCMeta): """Base class for instance masks.""" @abstractmethod def rescale(self, scale, interpola...
828
30,134
insightface
detection/scrfd/mmdet/core/mask/mask_target.py
.py
import numpy as np import torch from torch.nn.modules.utils import _pair def mask_target(pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list, cfg): """Compute mask target for positive proposals in multiple images. Args: pos_proposals_list (list[Tensor]): Positive proposals in...
63
2,354
insightface
detection/scrfd/mmdet/core/fp16/deprecated_fp16_utils.py
.py
import warnings from mmcv.runner import (Fp16OptimizerHook, auto_fp16, force_fp32, wrap_fp16_model) class DeprecatedFp16OptimizerHook(Fp16OptimizerHook): """A wrapper class for the FP16 optimizer hook. This class wraps :class:`Fp16OptimizerHook` in `mmcv.runner` and shows a warning t...
48
1,600
insightface
detection/scrfd/mmdet/core/fp16/__init__.py
.py
from .deprecated_fp16_utils import \ DeprecatedFp16OptimizerHook as Fp16OptimizerHook from .deprecated_fp16_utils import deprecated_auto_fp16 as auto_fp16 from .deprecated_fp16_utils import deprecated_force_fp32 as force_fp32 from .deprecated_fp16_utils import \ deprecated_wrap_fp16_model as wrap_fp16_model __...
9
396
insightface
detection/scrfd/mmdet/core/export/__init__.py
.py
from .pytorch2onnx import (build_model_from_cfg, generate_inputs_and_wrap_model, preprocess_example_input) __all__ = [ 'build_model_from_cfg', 'generate_inputs_and_wrap_model', 'preprocess_example_input' ]
9
269
insightface
detection/scrfd/mmdet/core/export/pytorch2onnx.py
.py
from functools import partial import mmcv import numpy as np import torch from mmcv.runner import load_checkpoint def generate_inputs_and_wrap_model(config_path, checkpoint_path, input_config): """Prepare sample input and wrap model for ONNX export. The ONNX export API only accept args, and all inputs shoul...
144
5,329
insightface
detection/scrfd/mmdet/core/bbox/builder.py
.py
from mmcv.utils import Registry, build_from_cfg BBOX_ASSIGNERS = Registry('bbox_assigner') BBOX_SAMPLERS = Registry('bbox_sampler') BBOX_CODERS = Registry('bbox_coder') def build_assigner(cfg, **default_args): """Builder of box assigner.""" return build_from_cfg(cfg, BBOX_ASSIGNERS, default_args) def build...
21
580
insightface
detection/scrfd/mmdet/core/bbox/__init__.py
.py
from .assigners import (AssignResult, BaseAssigner, CenterRegionAssigner, MaxIoUAssigner) from .builder import build_assigner, build_bbox_coder, build_sampler from .coder import (BaseBBoxCoder, DeltaXYWHBBoxCoder, PseudoBBoxCoder, TBLRBBoxCoder) from .iou_calculators import B...
28
1,575
insightface
detection/scrfd/mmdet/core/bbox/transforms.py
.py
import numpy as np import torch def bbox_flip(bboxes, img_shape, direction='horizontal'): """Flip bboxes horizontally or vertically. Args: bboxes (Tensor): Shape (..., 4*k) img_shape (tuple): Image shape. direction (str): Flip direction, options are "horizontal", "vertical", ...
271
8,677
insightface
detection/scrfd/mmdet/core/bbox/demodata.py
.py
import numpy as np import torch def ensure_rng(rng=None): """Simple version of the ``kwarray.ensure_rng`` Args: rng (int | numpy.random.RandomState | None): if None, then defaults to the global rng. Otherwise this can be an integer or a RandomState class Returns: (...
64
1,748
insightface
detection/scrfd/mmdet/core/bbox/iou_calculators/builder.py
.py
from mmcv.utils import Registry, build_from_cfg IOU_CALCULATORS = Registry('IoU calculator') def build_iou_calculator(cfg, default_args=None): """Builder of IoU calculator.""" return build_from_cfg(cfg, IOU_CALCULATORS, default_args)
9
245
insightface
detection/scrfd/mmdet/core/bbox/iou_calculators/__init__.py
.py
from .builder import build_iou_calculator from .iou2d_calculator import BboxOverlaps2D, bbox_overlaps __all__ = ['build_iou_calculator', 'BboxOverlaps2D', 'bbox_overlaps']
5
173
insightface
detection/scrfd/mmdet/core/bbox/iou_calculators/iou2d_calculator.py
.py
import torch from .builder import IOU_CALCULATORS @IOU_CALCULATORS.register_module() class BboxOverlaps2D(object): """2D Overlaps (e.g. IoUs, GIoUs) Calculator.""" def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False): """Calculate IoU between 2D bboxes. Args: bboxe...
160
6,184
insightface
detection/scrfd/mmdet/core/bbox/assigners/atss_assigner.py
.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.register_module() class ATSSAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each bbox. ...
216
9,497
insightface
detection/scrfd/mmdet/core/bbox/assigners/grid_assigner.py
.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.register_module() class GridAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each bbox. ...
156
6,816
insightface
detection/scrfd/mmdet/core/bbox/assigners/hungarian_assigner.py
.py
import torch from scipy.optimize import linear_sum_assignment from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from ..transforms import bbox_cxcywh_to_xyxy, bbox_xyxy_to_cxcywh from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.regis...
159
7,173
insightface
detection/scrfd/mmdet/core/bbox/assigners/center_region_assigner.py
.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner def scale_boxes(bboxes, scale): """Expand an array of boxes by a given scale. Args: bboxes (Tensor): Shape (m, 4) ...
336
15,429
insightface
detection/scrfd/mmdet/core/bbox/assigners/__init__.py
.py
from .approx_max_iou_assigner import ApproxMaxIoUAssigner from .assign_result import AssignResult from .atss_assigner import ATSSAssigner from .base_assigner import BaseAssigner from .center_region_assigner import CenterRegionAssigner from .grid_assigner import GridAssigner from .hungarian_assigner import HungarianAssi...
16
606
insightface
detection/scrfd/mmdet/core/bbox/assigners/approx_max_iou_assigner.py
.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .max_iou_assigner import MaxIoUAssigner @BBOX_ASSIGNERS.register_module() class ApproxMaxIoUAssigner(MaxIoUAssigner): """Assign a corresponding gt bbox or background to each bbox. Each proposals will be...
146
6,649
insightface
detection/scrfd/mmdet/core/bbox/assigners/max_iou_assigner.py
.py
import torch from ..builder import BBOX_ASSIGNERS from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.register_module() class MaxIoUAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each bbox. ...
213
9,750
insightface
detection/scrfd/mmdet/core/bbox/assigners/point_assigner.py
.py
import torch from ..builder import BBOX_ASSIGNERS from .assign_result import AssignResult from .base_assigner import BaseAssigner @BBOX_ASSIGNERS.register_module() class PointAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each point. Each proposals will be assigned with `0`, or a...
134
5,947
insightface
detection/scrfd/mmdet/core/bbox/assigners/assign_result.py
.py
import torch from mmdet.utils import util_mixins class AssignResult(util_mixins.NiceRepr): """Stores assignments between predicted and truth boxes. Attributes: num_gts (int): the number of truth boxes considered when computing this assignment gt_inds (LongTensor): for each predi...
205
7,705
insightface
detection/scrfd/mmdet/core/bbox/assigners/base_assigner.py
.py
from abc import ABCMeta, abstractmethod class BaseAssigner(metaclass=ABCMeta): """Base assigner that assigns boxes to ground truth boxes.""" @abstractmethod def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): """Assign boxes to either a ground truth boxe or a negative boxe...
11
339
insightface
detection/scrfd/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py
.py
import numpy as np import torch from ..builder import BBOX_SAMPLERS from .random_sampler import RandomSampler @BBOX_SAMPLERS.register_module() class InstanceBalancedPosSampler(RandomSampler): """Instance balanced sampler that samples equal number of positive samples for each instance.""" def _sample_pos...
56
2,271
insightface
detection/scrfd/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py
.py
import numpy as np import torch from ..builder import BBOX_SAMPLERS from .random_sampler import RandomSampler @BBOX_SAMPLERS.register_module() class IoUBalancedNegSampler(RandomSampler): """IoU Balanced Sampling. arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019) Sampling proposals according to th...
158
6,696
insightface
detection/scrfd/mmdet/core/bbox/samplers/score_hlr_sampler.py
.py
import torch from mmcv.ops import nms_match from ..builder import BBOX_SAMPLERS from ..transforms import bbox2roi from .base_sampler import BaseSampler from .sampling_result import SamplingResult @BBOX_SAMPLERS.register_module() class ScoreHLRSampler(BaseSampler): r"""Importance-based Sample Reweighting (ISR_N),...
265
11,187
insightface
detection/scrfd/mmdet/core/bbox/samplers/__init__.py
.py
from .base_sampler import BaseSampler from .combined_sampler import CombinedSampler from .instance_balanced_pos_sampler import InstanceBalancedPosSampler from .iou_balanced_neg_sampler import IoUBalancedNegSampler from .ohem_sampler import OHEMSampler from .pseudo_sampler import PseudoSampler from .random_sampler impor...
16
628
insightface
detection/scrfd/mmdet/core/bbox/samplers/ohem_sampler.py
.py
import torch from ..builder import BBOX_SAMPLERS from ..transforms import bbox2roi from .base_sampler import BaseSampler @BBOX_SAMPLERS.register_module() class OHEMSampler(BaseSampler): r"""Online Hard Example Mining Sampler described in `Training Region-based Object Detectors with Online Hard Example Mining...
108
4,098
insightface
detection/scrfd/mmdet/core/bbox/samplers/random_sampler.py
.py
import torch from ..builder import BBOX_SAMPLERS from .base_sampler import BaseSampler @BBOX_SAMPLERS.register_module() class RandomSampler(BaseSampler): """Random sampler. Args: num (int): Number of samples pos_fraction (float): Fraction of positive samples neg_pos_up (int, optional...
79
2,817
insightface
detection/scrfd/mmdet/core/bbox/samplers/sampling_result.py
.py
import torch from mmdet.utils import util_mixins class SamplingResult(util_mixins.NiceRepr): """Bbox sampling result. Example: >>> # xdoctest: +IGNORE_WANT >>> from mmdet.core.bbox.samplers.sampling_result import * # NOQA >>> self = SamplingResult.random(rng=10) >>> print(f'...
153
5,334
insightface
detection/scrfd/mmdet/core/bbox/samplers/pseudo_sampler.py
.py
import torch from ..builder import BBOX_SAMPLERS from .base_sampler import BaseSampler from .sampling_result import SamplingResult @BBOX_SAMPLERS.register_module() class PseudoSampler(BaseSampler): """A pseudo sampler that does not do sampling actually.""" def __init__(self, **kwargs): pass def...
42
1,415
insightface
detection/scrfd/mmdet/core/bbox/samplers/base_sampler.py
.py
from abc import ABCMeta, abstractmethod import torch from .sampling_result import SamplingResult class BaseSampler(metaclass=ABCMeta): """Base class of samplers.""" def __init__(self, num, pos_fraction, neg_pos_ub=-1, add_gt_as_proposals=T...
102
3,872
insightface
detection/scrfd/mmdet/core/bbox/samplers/combined_sampler.py
.py
from ..builder import BBOX_SAMPLERS, build_sampler from .base_sampler import BaseSampler @BBOX_SAMPLERS.register_module() class CombinedSampler(BaseSampler): """A sampler that combines positive sampler and negative sampler.""" def __init__(self, pos_sampler, neg_sampler, **kwargs): super(CombinedSamp...
21
700
insightface
detection/scrfd/mmdet/core/bbox/coder/legacy_delta_xywh_bbox_coder.py
.py
import numpy as np import torch from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class LegacyDeltaXYWHBBoxCoder(BaseBBoxCoder): """Legacy Delta XYWH BBox coder used in MMDet V1.x. Following the practice in R-CNN [1]_, this coder encodes bbox (x1, y1...
213
8,147
insightface
detection/scrfd/mmdet/core/bbox/coder/delta_xywh_bbox_coder.py
.py
import numpy as np import torch from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class DeltaXYWHBBoxCoder(BaseBBoxCoder): """Delta XYWH BBox coder. Following the practice in `R-CNN <https://arxiv.org/abs/1311.2524>`_, this coder encodes bbox (x1...
205
7,756
insightface
detection/scrfd/mmdet/core/bbox/coder/yolo_bbox_coder.py
.py
import torch from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class YOLOBBoxCoder(BaseBBoxCoder): """YOLO BBox coder. Following `YOLO <https://arxiv.org/abs/1506.02640>`_, this coder divide image into grids, and encode bbox (x1, y1, x2, y2) into...
87
3,417
insightface
detection/scrfd/mmdet/core/bbox/coder/pseudo_bbox_coder.py
.py
from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class PseudoBBoxCoder(BaseBBoxCoder): """Pseudo bounding box coder.""" def __init__(self, **kwargs): super(BaseBBoxCoder, self).__init__(**kwargs) def encode(self, bboxes, gt_bboxes): ...
19
529
insightface
detection/scrfd/mmdet/core/bbox/coder/__init__.py
.py
from .base_bbox_coder import BaseBBoxCoder from .bucketing_bbox_coder import BucketingBBoxCoder from .delta_xywh_bbox_coder import DeltaXYWHBBoxCoder from .legacy_delta_xywh_bbox_coder import LegacyDeltaXYWHBBoxCoder from .pseudo_bbox_coder import PseudoBBoxCoder from .tblr_bbox_coder import TBLRBBoxCoder from .yolo_bb...
14
518
insightface
detection/scrfd/mmdet/core/bbox/coder/base_bbox_coder.py
.py
from abc import ABCMeta, abstractmethod class BaseBBoxCoder(metaclass=ABCMeta): """Base bounding box coder.""" def __init__(self, **kwargs): pass @abstractmethod def encode(self, bboxes, gt_bboxes): """Encode deltas between bboxes and ground truth boxes.""" pass @abstrac...
20
474
insightface
detection/scrfd/mmdet/core/bbox/coder/tblr_bbox_coder.py
.py
import torch from ..builder import BBOX_CODERS from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class TBLRBBoxCoder(BaseBBoxCoder): """TBLR BBox coder. Following the practice in `FSAF <https://arxiv.org/abs/1903.00621>`_, this coder encodes gt bboxes (x1, y1, x2, y2) into (top, ...
173
6,993
insightface
detection/scrfd/mmdet/core/bbox/coder/bucketing_bbox_coder.py
.py
import numpy as np import torch import torch.nn.functional as F from ..builder import BBOX_CODERS from ..transforms import bbox_rescale from .base_bbox_coder import BaseBBoxCoder @BBOX_CODERS.register_module() class BucketingBBoxCoder(BaseBBoxCoder): """Bucketing BBox Coder for Side-Aware Bounday Localization (S...
347
13,982
insightface
detection/scrfd/mmdet/core/anchor/utils.py
.py
import torch def images_to_levels(target, num_levels): """Convert targets by image to targets by feature level. [target_img0, target_img1] -> [target_level0, target_level1, ...] """ target = torch.stack(target, 0) level_targets = [] start = 0 for n in num_levels: end = start + n ...
72
2,497
insightface
detection/scrfd/mmdet/core/anchor/builder.py
.py
from mmcv.utils import Registry, build_from_cfg ANCHOR_GENERATORS = Registry('Anchor generator') def build_anchor_generator(cfg, default_args=None): return build_from_cfg(cfg, ANCHOR_GENERATORS, default_args)
8
216
insightface
detection/scrfd/mmdet/core/anchor/anchor_generator.py
.py
import mmcv import numpy as np import torch from torch.nn.modules.utils import _pair from .builder import ANCHOR_GENERATORS @ANCHOR_GENERATORS.register_module() class AnchorGenerator(object): """Standard anchor generator for 2D anchor-based detectors. Args: strides (list[int] | list[tuple[int, int]]...
729
31,168
insightface
detection/scrfd/mmdet/core/anchor/__init__.py
.py
from .anchor_generator import (AnchorGenerator, LegacyAnchorGenerator, YOLOAnchorGenerator) from .builder import ANCHOR_GENERATORS, build_anchor_generator from .point_generator import PointGenerator from .utils import anchor_inside_flags, calc_region, images_to_levels __all__ = [ 'An...
12
516
insightface
detection/scrfd/mmdet/core/anchor/point_generator.py
.py
import torch from .builder import ANCHOR_GENERATORS @ANCHOR_GENERATORS.register_module() class PointGenerator(object): def _meshgrid(self, x, y, row_major=True): xx = x.repeat(len(y)) yy = y.view(-1, 1).repeat(1, len(x)).view(-1) if row_major: return xx, yy else: ...
38
1,362
insightface
detection/scrfd/mmdet/core/post_processing/bbox_nms.py
.py
import torch from mmcv.ops.nms import batched_nms from mmdet.core.bbox.iou_calculators import bbox_overlaps def multiclass_nms(multi_bboxes, multi_scores, score_thr, nms_cfg, max_num=-1, score_factors=None, ...
150
5,446
insightface
detection/scrfd/mmdet/core/post_processing/merge_augs.py
.py
import numpy as np import torch from mmcv.ops import nms from ..bbox import bbox_mapping_back def merge_aug_proposals(aug_proposals, img_metas, rpn_test_cfg): """Merge augmented proposals (multiscale, flip, etc.) Args: aug_proposals (list[Tensor]): proposals from different testing scheme...
118
4,286
insightface
detection/scrfd/mmdet/core/post_processing/__init__.py
.py
from .bbox_nms import fast_nms, multiclass_nms from .merge_augs import (merge_aug_bboxes, merge_aug_masks, merge_aug_proposals, merge_aug_scores) __all__ = [ 'multiclass_nms', 'merge_aug_proposals', 'merge_aug_bboxes', 'merge_aug_scores', 'merge_aug_masks', 'fast_nms' ]
9
305
insightface
detection/scrfd/mmdet/core/evaluation/__init__.py
.py
from .class_names import (cityscapes_classes, coco_classes, dataset_aliases, get_classes, imagenet_det_classes, imagenet_vid_classes, voc_classes) from .eval_hooks import DistEvalHook, EvalHook from .mean_ap import average_precision, eval_map, print_map_summary from ....
18
860