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 |
|---|---|---|---|---|---|---|
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/maskiou_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
import torch.nn as nn
from mmcv.cnn import Conv2d, Linear, MaxPool2d
from mmcv.runner import BaseModule, force_fp32
from torch.nn.modules.utils import _pair
from mmdet.models.builder import HEADS, build_loss
@HEADS.register_module()
clas... | 7,382 | 39.125 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/scnet_semantic_head.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmdet.models.builder import HEADS
from mmdet.models.utils import ResLayer, SimplifiedBasicBlock
from .fused_semantic_head import FusedSemanticHead
@HEADS.register_module()
class SCNetSemanticHead(FusedSemanticHead):
"""Mask head for `SCNet <https://arxiv.org/ab... | 998 | 33.448276 | 72 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/feature_relay_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.runner import BaseModule, auto_fp16
from mmdet.models.builder import HEADS
@HEADS.register_module()
class FeatureRelayHead(BaseModule):
"""Feature Relay Head used in `SCNet <https://arxiv.org/abs/2012.10150>`_.
Args:
in_... | 1,930 | 34.759259 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/global_context_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule, auto_fp16, force_fp32
from mmdet.models.builder import HEADS
from mmdet.models.utils import ResLayer, SimplifiedBasicBlock
@HEADS.register_module()
class GlobalContextHead(BaseMod... | 3,774 | 36.009804 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .coarse_mask_head import CoarseMaskHead
from .fcn_mask_head import FCNMaskHead
from .feature_relay_head import FeatureRelayHead
from .fused_semantic_head import FusedSemanticHead
from .global_context_head import GlobalContextHead
from .grid_head import GridHead
from ... | 747 | 38.368421 | 70 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/htc_mask_head.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmcv.cnn import ConvModule
from mmdet.models.builder import HEADS
from .fcn_mask_head import FCNMaskHead
@HEADS.register_module()
class HTCMaskHead(FCNMaskHead):
def __init__(self, with_conv_res=True, *args, **kwargs):
super(HTCMaskHead, self).__init_... | 1,282 | 31.075 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/fcn_mask_head.py | # Copyright (c) OpenMMLab. All rights reserved.
from warnings import warn
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, build_conv_layer, build_upsample_layer
from mmcv.ops.carafe import CARAFEPack
from mmcv.runner import BaseModule, ModuleList, ... | 17,394 | 41.118644 | 85 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/fused_semantic_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule, auto_fp16, force_fp32
from mmdet.models.builder import HEADS, build_loss
@HEADS.register_module()
class FusedSemanticHead(BaseModu... | 4,150 | 34.177966 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/mask_point_head.py | # Copyright (c) OpenMMLab. All rights reserved.
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmcv.ops import point_sample, rel_roi_point_to_rel_img_point
from mmcv.r... | 13,455 | 42.830619 | 126 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/roi_heads/mask_heads/scnet_mask_head.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmdet.models.builder import HEADS
from mmdet.models.utils import ResLayer, SimplifiedBasicBlock
from .fcn_mask_head import FCNMaskHead
@HEADS.register_module()
class SCNetMaskHead(FCNMaskHead):
"""Mask head for `SCNet <https://arxiv.org/abs/2012.10150>`_.
... | 979 | 32.793103 | 72 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/ghm_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weight_reduce_loss
def _expand_onehot_labels(labels, label_weights, label_channels):
bin_labels = labels.new_full((labels.size(0), label_channels), 0)... | 7,923 | 36.028037 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/mse_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weighted_loss
@weighted_loss
def mse_loss(pred, target):
"""Warpper of mse loss."""
return F.mse_loss(pred, target, reduction='none')
@LOSSES.register_module... | 1,905 | 31.862069 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/pisa_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch
from mmdet.core import bbox_overlaps
@mmcv.jit(derivate=True, coderize=True)
def isr_p(cls_score,
bbox_pred,
bbox_targets,
rois,
sampling_results,
loss_cls,
bbox_coder,
k=2,
... | 7,216 | 38.010811 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/balanced_l1_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import torch
import torch.nn as nn
from ..builder import LOSSES
from .utils import weighted_loss
@mmcv.jit(derivate=True, coderize=True)
@weighted_loss
def balanced_l1_loss(pred,
target,
beta=1.0,... | 4,252 | 33.024 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/iou_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import warnings
import mmcv
import torch
import torch.nn as nn
from mmdet.core import bbox_overlaps
from ..builder import LOSSES
from .utils import weighted_loss
@mmcv.jit(derivate=True, coderize=True)
@weighted_loss
def iou_loss(pred, target, linear=False... | 15,714 | 32.084211 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/smooth_l1_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch
import torch.nn as nn
from ..builder import LOSSES
from .utils import weighted_loss
@mmcv.jit(derivate=True, coderize=True)
@weighted_loss
def smooth_l1_loss(pred, target, beta=1.0):
"""Smooth L1 loss.
Args:
pred (torch.Tensor)... | 4,635 | 30.537415 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/gfocal_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weighted_loss
@mmcv.jit(derivate=True, coderize=True)
@weighted_loss
def quality_focal_loss(pred, target, beta=2.0):
r"""Quality Focal Loss (QFL) is fr... | 7,458 | 38.257895 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/varifocal_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weight_reduce_loss
@mmcv.jit(derivate=True, coderize=True)
def varifocal_loss(pred,
target,
weight=None,
... | 5,365 | 38.748148 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import functools
import mmcv
import torch.nn.functional as F
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
Return:
... | 3,103 | 29.431373 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/seesaw_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .accuracy import accuracy
from .cross_entropy_loss import cross_entropy
from .utils import weight_reduce_loss
def seesaw_ce_loss(cls_score,
labels,
... | 10,136 | 37.543726 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/ae_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
@mmcv.jit(derivate=True, coderize=True)
def ae_loss_per_image(tl_preds, br_preds, match):
"""Associative Embedding Loss in one image.
Associative Embedd... | 3,857 | 36.096154 | 143 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/accuracy.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch.nn as nn
@mmcv.jit(coderize=True)
def accuracy(pred, target, topk=1, thresh=None):
"""Calculate accuracy according to the prediction and target.
Args:
pred (torch.Tensor): The model prediction, shape (N, num_class)
targe... | 2,990 | 36.3875 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/focal_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.ops import sigmoid_focal_loss as _sigmoid_focal_loss
from ..builder import LOSSES
from .utils import weight_reduce_loss
import ipdb
# This method is only for debugging
def py_sigmoid_focal_loss... | 7,589 | 40.47541 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/cross_entropy_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weight_reduce_loss
def cross_entropy(pred,
label,
weight=None,
reduction='mean',
a... | 9,696 | 37.480159 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .accuracy import Accuracy, accuracy
from .ae_loss import AssociativeEmbeddingLoss
from .balanced_l1_loss import BalancedL1Loss, balanced_l1_loss
from .cross_entropy_loss import (CrossEntropyLoss, binary_cross_entropy,
cross_entropy, m... | 1,820 | 52.558824 | 77 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/gaussian_focal_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch.nn as nn
from ..builder import LOSSES
from .utils import weighted_loss
@mmcv.jit(derivate=True, coderize=True)
@weighted_loss
def gaussian_focal_loss(pred, gaussian_target, alpha=2.0, gamma=4.0):
"""`Focal Loss <https://arxiv.org/abs/1708.0... | 3,312 | 34.623656 | 108 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/semi_focal_loss.py | import mmcv
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmdet.core import reduce_mean
from ..builder import LOSSES
from .utils import weighted_loss, weight_reduce_loss
import ipdb
def diff_focal_loss(pred, target, weight=None, beta=2.0, hard_filter=False,
reduction='mean',... | 8,302 | 39.305825 | 97 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/losses/kd_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weighted_loss
import ipdb
@mmcv.jit(derivate=True, coderize=True)
@weighted_loss
def knowledge_distillation_kl_div_loss(pred,
... | 4,411 | 31.925373 | 89 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/hrnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch.nn as nn
from mmcv.cnn import build_conv_layer, build_norm_layer
from mmcv.runner import BaseModule, ModuleList, Sequential
from torch.nn.modules.batchnorm import _BatchNorm
from ..builder import BACKBONES
from .resnet import BasicBlock, Bot... | 23,106 | 38.164407 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/regnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import numpy as np
import torch.nn as nn
from mmcv.cnn import build_conv_layer, build_norm_layer
from ..builder import BACKBONES
from .resnet import ResNet
from .resnext import Bottleneck
@BACKBONES.register_module()
class RegNet(ResNet):
"""RegNet... | 13,605 | 37.112045 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/mobilenet_v2.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule
from torch.nn.modules.batchnorm import _BatchNorm
from ..builder import BACKBONES
from ..utils import InvertedResidual, make_divisible
@BACKBONES.register_module()... | 7,599 | 37.383838 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/swin.py | import warnings
from collections import OrderedDict
from copy import deepcopy
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as cp
from mmcv.cnn import build_norm_layer, constant_init, trunc_normal_init
from mmcv.cnn.bricks.transformer import FFN, build_dropout
from mm... | 30,173 | 38.443137 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/trident_resnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as cp
from mmcv.cnn import build_conv_layer, build_norm_layer
from mmcv.runner import BaseModule
from torch.nn.modules.utils import _pair
from mmdet.models.backbones.resnet i... | 11,129 | 36.22408 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/detectors_resnext.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
from mmcv.cnn import build_conv_layer, build_norm_layer
from ..builder import BACKBONES
from .detectors_resnet import Bottleneck as _Bottleneck
from .detectors_resnet import DetectoRS_ResNet
class Bottleneck(_Bottleneck):
expansion = 4
def __init_... | 3,920 | 30.620968 | 77 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/resnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch.nn as nn
import torch.utils.checkpoint as cp
from mmcv.cnn import build_conv_layer, build_norm_layer, build_plugin_layer
from mmcv.runner import BaseModule
from torch.nn.modules.batchnorm import _BatchNorm
from ..builder import BACKBONES
fro... | 23,838 | 34.421991 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/detectors_resnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
import torch.utils.checkpoint as cp
from mmcv.cnn import (build_conv_layer, build_norm_layer, constant_init,
kaiming_init)
from mmcv.runner import Sequential, load_checkpoint
from torch.nn.modules.batchnorm import _BatchNorm
fr... | 12,736 | 34.980226 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/ssd_vgg.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch.nn as nn
from mmcv.cnn import VGG
from mmcv.runner import BaseModule
from ..builder import BACKBONES
from ..necks import ssd_neck
@BACKBONES.register_module()
class SSDVGG(VGG, BaseModule):
"""VGG Backbone network for single-shot-detec... | 4,705 | 35.48062 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/resnext.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
from mmcv.cnn import build_conv_layer, build_norm_layer
from ..builder import BACKBONES
from ..utils import ResLayer
from .resnet import Bottleneck as _Bottleneck
from .resnet import ResNet
class Bottleneck(_Bottleneck):
expansion = 4
def __init__... | 5,712 | 35.858065 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/resnest.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as cp
from mmcv.cnn import build_conv_layer, build_norm_layer
from mmcv.runner import BaseModule
from ..builder import BACKBONES
from ..utils import ResLayer
fro... | 10,579 | 31.755418 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/csp_darknet.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from mmcv.runner import BaseModule
from torch.nn.modules.batchnorm import _BatchNorm
from ..builder import BACKBONES
from ..utils import CSPLayer
class Focus(n... | 10,544 | 36 | 77 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .csp_darknet import CSPDarknet
from .darknet import Darknet
from .detectors_resnet import DetectoRS_ResNet
from .detectors_resnext import DetectoRS_ResNeXt
from .hourglass import HourglassNet
from .hrnet import HRNet
from .mobilenet_v2 import MobileNetV2
from .regnet... | 812 | 32.875 | 77 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/hourglass.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule
from ..builder import BACKBONES
from ..utils import ResLayer
from .resnet import BasicBlock
class HourglassModule(BaseModule):
"""Hourglass Modu... | 7,494 | 32.609865 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/res2net.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.nn as nn
import torch.utils.checkpoint as cp
from mmcv.cnn import build_conv_layer, build_norm_layer
from mmcv.runner import Sequential
from ..builder import BACKBONES
from .resnet import Bottleneck as _Bottleneck
from .resnet impor... | 11,659 | 34.54878 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/models/backbones/darknet.py | # Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) 2019 Western Digital Corporation or its affiliates.
import warnings
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule
from torch.nn.modules.batchnorm import _BatchNorm
from ..builder import BACKBONES
class ResBlo... | 8,233 | 37.476636 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/custom.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import warnings
from collections import OrderedDict
import mmcv
import numpy as np
from mmcv.utils import print_log
from terminaltables import AsciiTable
from torch.utils.data import Dataset
from mmdet.core import eval_map, eval_recalls
from .build... | 13,457 | 35.570652 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/deepfashion.py | # Copyright (c) OpenMMLab. All rights reserved.
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', 'footw... | 365 | 29.5 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/voc.py | # Copyright (c) OpenMMLab. All rights reserved.
from collections import OrderedDict
from mmcv.utils import print_log
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', 'b... | 4,297 | 39.54717 | 90 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/cityscapes.py | # Copyright (c) OpenMMLab. All rights reserved.
# 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
im... | 14,336 | 41.669643 | 135 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import warnings
from mmcv.cnn import VGG
from mmcv.runner.hooks import HOOKS, Hook
from mmdet.datasets.builder import PIPELINES
from mmdet.datasets.pipelines import LoadAnnotations, LoadImageFromFile
from mmdet.models.dense_heads import GARPNHead, RPNHead
fr... | 6,533 | 38.6 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/dataset_wrappers.py | # Copyright (c) OpenMMLab. All rights reserved.
import bisect
import collections
import copy
import math
from collections import defaultdict
import numpy as np
from mmcv.utils import build_from_cfg, print_log
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset
from .builder import DATASETS, PIPELINES... | 15,324 | 37.602015 | 167 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/xml_style.py | # Copyright (c) OpenMMLab. All rights reserved.
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.... | 6,243 | 33.882682 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset
from .cityscapes import CityscapesDataset
from .coco import CocoDataset
from .coco_panoptic import CocoPanopticDataset
from .custom import CustomDataset
from .dataset_wrappers import (ClassBalancedD... | 1,320 | 47.925926 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/lvis.py | # Copyright (c) OpenMMLab. All rights reserved.
import itertools
import logging
import os.path as osp
import tempfile
import warnings
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 CocoDatase... | 46,184 | 61.496617 | 157 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/builder.py | # Copyright (c) OpenMMLab. All rights reserved.
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 impo... | 5,629 | 36.284768 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/coco_panoptic.py | # Copyright (c) OpenMMLab. All rights reserved.
import itertools
import os
from collections import defaultdict
import mmcv
import numpy as np
from mmcv.utils import print_log
from terminaltables import AsciiTable
from .api_wrappers import COCO
from .builder import DATASETS
from .coco import CocoDataset
try:
impo... | 21,817 | 39.033028 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/coco.py | # Copyright (c) OpenMMLab. All rights reserved.
import itertools
import logging
import os.path as osp
import tempfile
import warnings
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 .api_... | 23,532 | 40.948307 | 124 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/wider_face.py | # Copyright (c) OpenMMLab. All rights reserved.
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.
Con... | 1,549 | 28.245283 | 68 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/api_wrappers/coco_api.py | # Copyright (c) OpenMMLab. All rights reserved.
# This file add snake case alias for coco api
import warnings
import pycocotools
from pycocotools.coco import COCO as _COCO
from pycocotools.cocoeval import COCOeval as _COCOeval
# for analysis use
# import thirdparty.pycocotools as pycocotools
# from thirdparty.pycoco... | 1,697 | 31.037736 | 126 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/api_wrappers/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .coco_api import COCO, COCOeval
__all__ = ['COCO', 'COCOeval']
| 117 | 22.6 | 47 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/samplers/group_sampler.py | # Copyright (c) OpenMMLab. All rights reserved.
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 = datas... | 5,384 | 35.14094 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/samplers/distributed_sampler.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
from torch.utils.data import DistributedSampler as _DistributedSampler
class DistributedSampler(_DistributedSampler):
def __init__(self,
dataset,
num_replicas=None,
rank=None,
... | 1,358 | 32.146341 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/samplers/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .distributed_sampler import DistributedSampler
from .group_sampler import DistributedGroupSampler, GroupSampler
__all__ = ['DistributedSampler', 'DistributedGroupSampler', 'GroupSampler']
| 242 | 39.5 | 75 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/pipelines/loading.py | # Copyright (c) OpenMMLab. All rights reserved.
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
try:
from panopticapi.utils import rgb2id
except ImportError:
rgb2id = None
@PIPELINES.r... | 19,800 | 33.922399 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/pipelines/instaboost.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
from ..builder import PIPELINES
@PIPELINES.register_module()
class InstaBoost:
r"""Data augmentation method in `InstaBoost: Boosting Instance
Segmentation Via Probability Map Guided Copy-Pasting
<https://arxiv.org/abs/1908.07801>`_.
... | 4,510 | 36.907563 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/pipelines/compose.py | # Copyright (c) OpenMMLab. All rights reserved.
import collections
from mmcv.utils import build_from_cfg
from ..builder import PIPELINES
import ipdb
@PIPELINES.register_module()
class Compose:
"""Compose multiple transforms sequentially.
Args:
transforms (Sequence[dict | callable]): Sequence of tran... | 1,528 | 28.403846 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/pipelines/auto_augment.py | # Copyright (c) OpenMMLab. All rights reserved.
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... | 36,375 | 39.780269 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/pipelines/formating.py | # Copyright (c) OpenMMLab. All rights reserved.
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 ty... | 12,044 | 31.909836 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/pipelines/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .auto_augment import (AutoAugment, BrightnessTransform, ColorTransform,
ContrastTransform, EqualizeTransform, Rotate, Shear,
Translate)
from .compose import Compose
from .formating import (Collect, DefaultFormatBu... | 1,598 | 54.137931 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/pipelines/transforms.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import inspect
import math
import cv2
import mmcv
import numpy as np
from numpy import random
from mmdet.core import PolygonMasks
from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps
from ..builder import PIPELINES
try:
from imagecorruptions im... | 103,716 | 38.632021 | 86 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/datasets/pipelines/test_time_aug.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import mmcv
from ..builder import PIPELINES
from .compose import Compose
@PIPELINES.register_module()
class MultiScaleFlipAug:
"""Test-time augmentation with multiple scales and flipping.
An example configuration is as followed:
.. code-b... | 4,469 | 35.639344 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/utils/contextmanagers.py | # Copyright (c) OpenMMLab. All rights reserved.
import asyncio
import contextlib
import logging
import os
import time
from typing import List
import torch
logger = logging.getLogger(__name__)
DEBUG_COMPLETED_TIME = bool(os.environ.get('DEBUG_COMPLETED_TIME', False))
@contextlib.asynccontextmanager
async def comple... | 4,125 | 32.544715 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/utils/util_mixins.py | # Copyright (c) OpenMMLab. All rights reserved.
"""This module defines the :class:`NiceRepr` mixin class, which defines a
``__repr__`` and ``__str__`` method that only depend on a custom ``__nice__``
method, which you must define. This means you only have to overload one
function instead of two. Furthermore, if the ob... | 3,712 | 34.028302 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/utils/profiling.py | # Copyright (c) OpenMMLab. All rights reserved.
import contextlib
import sys
import time
import torch
if sys.version_info >= (3, 7):
@contextlib.contextmanager
def profile_time(trace_name,
name,
enabled=True,
stream=None,
end... | 1,336 | 31.609756 | 73 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/utils/util_random.py | # Copyright (c) OpenMMLab. All rights reserved.
"""Helpers for random number generators."""
import numpy as np
def ensure_rng(rng=None):
"""Coerces input into a random number generator.
If the input is None, then a global random state is returned.
If the input is a numeric value, then that is used as a ... | 1,025 | 28.314286 | 119 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/utils/logger.py | # Copyright (c) OpenMMLab. All rights reserved.
import logging
from mmcv.utils import get_logger
def get_root_logger(log_file=None, log_level=logging.INFO):
"""Get root logger.
Args:
log_file (str, optional): File path of log. Defaults to None.
log_level (int, optional): The level of logger.... | 529 | 24.238095 | 77 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/utils/collect_env.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmcv.utils import collect_env as collect_base_env
from mmcv.utils import get_git_hash
import mmdet
def collect_env():
"""Collect the information of the running environments."""
env_info = collect_base_env()
env_info['MMDetection'] = mmdet.__version__ +... | 471 | 25.222222 | 74 | py |
PseCo | PseCo-master/thirdparty/mmdetection/mmdet/utils/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .collect_env import collect_env
from .logger import get_root_logger
__all__ = ['get_root_logger', 'collect_env']
| 167 | 27 | 47 | py |
PseCo | PseCo-master/scripts/check_ceph.py | from petrel_client.client import Client
import os
import ipdb
petrel_conf = "~/petreloss.conf"
client = Client(petrel_conf)
filename = "1984:s3://openmmlab/datasets/detection/coco/val2017/000000252219.jpg"
bytes = client.Get(filename) | 236 | 28.625 | 81 | py |
PseCo | PseCo-master/scripts/convert_json.py | import json
import ipdb
val_anno = "../data/annotations/instances_val2017.json"
new_anno = "../data/annotations/val_mini.json"
new_anno_dict = {}
with open(val_anno, "r") as f:
annos = json.load(f)
new_anno_dict["info"] = annos["info"]
new_anno_dict["licenses"] = annos["licenses"]
new_anno_dict... | 539 | 26 | 55 | py |
PseCo | PseCo-master/demo/image_demo.py | # Copyright (c) OpenMMLab. All rights reserved.
# Modified from thirdparty/mmdetection/demo/image_demo.py
import asyncio
import glob
import os
from argparse import ArgumentParser
from mmcv import Config
from mmdet.apis import async_inference_detector, inference_detector, show_result_pyplot
from ssod.apis.inference im... | 3,063 | 33.044444 | 87 | py |
PseCo | PseCo-master/configs/supervised_baseline/base.py | mmdet_base = "../../thirdparty/mmdetection/configs/_base_"
_base_ = [
f"{mmdet_base}/models/faster_rcnn_r50_fpn.py",
f"{mmdet_base}/datasets/coco_detection.py",
f"{mmdet_base}/schedules/schedule_1x.py",
f"{mmdet_base}/default_runtime.py",
]
model = dict(
backbone=dict(
norm_cfg=dict(require... | 3,220 | 26.767241 | 96 | py |
PseCo | PseCo-master/configs/supervised_baseline/faster_rcnn_r50_caffe_fpn_coco_full_180k_p3p7.py | _base_ = "base.py"
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(
ann_file="data/annotations/instances_train2017.json",
img_prefix="data/train2017/",
),
)
model = dict(
neck=dict(
start_level=1,
add_extra_convs='on_input'
),
rpn_head=dict(
... | 888 | 23.027027 | 77 | py |
PseCo | PseCo-master/configs/supervised_baseline/faster_rcnn_r50_caffe_fpn_coco_partial_180k.py | _base_ = "base.py"
fold = 1
percent = 1
data = dict(
samples_per_gpu=1,
workers_per_gpu=1,
train=dict(
ann_file="../data/annotations/semi_supervised/instances_train2017.${fold}@${percent}.json",
img_prefix="../data/train2017/",
),
)
log_config = dict(
interval=50,
hooks=[
... | 360 | 18 | 99 | py |
PseCo | PseCo-master/configs/supervised_baseline/faster_rcnn_r50_caffe_fpn_coco_full_720k.py | _base_ = "base.py"
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(
ann_file="data/annotations/instances_train2017.json",
img_prefix="data/train2017/",
),
)
optimizer = dict(lr=0.02)
lr_config = dict(step=[120000 * 4, 160000 * 4])
runner = dict(_delete_=True, type="IterBa... | 354 | 22.666667 | 74 | py |
PseCo | PseCo-master/configs/PseCo/base.py | mmdet_base = "../../thirdparty/mmdetection/configs/_base_"
_base_ = [
f"{mmdet_base}/models/faster_rcnn_r50_fpn.py",
f"{mmdet_base}/datasets/coco_detection.py",
f"{mmdet_base}/schedules/schedule_1x.py",
f"{mmdet_base}/default_runtime.py",
]
model = dict(
backbone=dict(
norm_cfg=dict(require... | 7,897 | 28.580524 | 96 | py |
PseCo | PseCo-master/configs/PseCo/PseCo_faster_rcnn_celoss_r50_caffe_fpn_coco_180k.py | _base_ = "base.py"
model = dict(
neck=dict(
num_outs=6,
add_extra_convs='on_input'
),
rpn_head=dict(
anchor_generator=dict(
type='AnchorGenerator',
scales=[4],
ratios=[0.5, 1.0, 2.0],
strides=[8, 16, 32, 64, 128]),
),
roi_head=... | 5,732 | 27.241379 | 113 | py |
PseCo | PseCo-master/configs/PseCo/PseCo_faster_rcnn_r50_caffe_fpn_coco_180k.py | _base_ = "base.py"
model = dict(
neck=dict(
num_outs=6,
add_extra_convs='on_input'
),
rpn_head=dict(
anchor_generator=dict(
type='AnchorGenerator',
scales=[4],
ratios=[0.5, 1.0, 2.0],
strides=[8, 16, 32, 64, 128]),
),
roi_head=... | 6,089 | 27.325581 | 113 | py |
pybo | pybo-master/setup.py | """
Setup script for pybo.
"""
import os
import setuptools
def read(fname):
"""Construct the name and descriptions from README.md."""
text = open(os.path.join(os.path.dirname(__file__), fname)).read()
text = text.split('\n\n')
name = text[0].lstrip('#').strip()
description = text[1].strip('.')
... | 947 | 24.621622 | 70 | py |
pybo | pybo-master/pybo/bayesopt.py | """
Solver method for GP-based optimization which uses an inner-loop optimizer to
maximize some acquisition function, generally given as a simple function of the
posterior sufficient statistics.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import num... | 9,562 | 32.204861 | 79 | py |
pybo | pybo-master/pybo/utils.py | """
Various utility functions.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
import re
import subprocess
__all__ = ['rstate', 'SubprocessQuery', 'InteractiveQuery']
def rstate(rng=None):
"""
Return a RandomState object. T... | 1,897 | 31.169492 | 81 | py |
pybo | pybo-master/pybo/__init__.py | """
Objects which global optimization solvers.
"""
# pylint: disable=wildcard-import
from .bayesopt import *
from . import bayesopt
__all__ = []
__all__ += bayesopt.__all__
| 176 | 13.75 | 42 | py |
pybo | pybo-master/pybo/recommenders.py | """
Recommendations.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
from . import solvers
__all__ = ['best_latent', 'best_incumbent']
def best_latent(model, bounds, X):
"""
Given a model return the best recommendation, corresponding to the p... | 841 | 22.388889 | 77 | py |
pybo | pybo-master/pybo/policies/simple.py | """
Acquisition functions based on the probability or expected value of
improvement.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
__all__ = ['EI', 'PI', 'UCB', 'Thompson']
def EI(model, _, X, xi=0.0):
"""
Expected impro... | 1,803 | 23.053333 | 78 | py |
pybo | pybo-master/pybo/policies/__init__.py | """
Acquisition functions.
"""
# pylint: disable=wildcard-import
from .simple import *
from . import simple
__all__ = []
__all__ += simple.__all__
| 150 | 11.583333 | 33 | py |
pybo | pybo-master/pybo/inits/sobol.py | import math
from numpy import *
def i4_bit_hi1 ( n ):
#*****************************************************************************80
#
## I4_BIT_HI1 returns the position of the high 1 bit base 2 in an integer.
#
# Example:
#
# N Binary BIT
# ---- -------- ----
# 0 0 0
# ... | 237,450 | 16.005729 | 93 | py |
pybo | pybo-master/pybo/inits/methods.py | """
Implementation of methods for sampling initial points.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
from ..utils import rstate
from .sobol import i4_sobol_generate
__all__ = ['init_middle', 'init_uniform', 'init_latin', 'init... | 2,057 | 25.384615 | 78 | py |
pybo | pybo-master/pybo/inits/__init__.py | """
Initialization methods.
"""
# pylint: disable=wildcard-import
from .methods import *
from . import methods
__all__ = []
__all__ += methods.__all__
| 154 | 11.916667 | 33 | py |
pybo | pybo-master/pybo/solvers/lbfgs.py | """
Local gradient-based solver using multiple restarts.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
import scipy.optimize
from ..inits import init_uniform
__all__ = ['solve_lbfgs']
def solve_lbfgs(f,
bounds,
... | 2,178 | 30.57971 | 79 | py |
pybo | pybo-master/pybo/solvers/direct.py | """
Interface to the nlopt DIRECT implementation.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# by default export nothing.
__all__ = []
try:
# try and import nlopt, and if not this package will not define or export
# anythi... | 1,224 | 24.520833 | 77 | py |
pybo | pybo-master/pybo/solvers/__init__.py | """
Objects which global optimization solvers.
"""
# pylint: disable=wildcard-import
from .lbfgs import *
from .direct import *
from . import lbfgs
from . import direct
__all__ = []
__all__ += lbfgs.__all__
__all__ += direct.__all__
| 236 | 14.8 | 42 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.