repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/centripetal_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, normal_init
from mmcv.ops import DeformConv2d
from mmdet.core import multi_apply
from ..builder import HEADS, build_loss
from .corner_head import CornerHead
@HEADS.register_module()
class CentripetalHead(CornerHead):
"""Head of CentripetalNet: Pursuing High-... | 19,469 | 45.137441 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/paa_head.py | import numpy as np
import torch
from mmcv.runner import force_fp32
from mmdet.core import multi_apply, multiclass_nms
from mmdet.core.bbox.iou_calculators import bbox_overlaps
from mmdet.models import HEADS
from mmdet.models.dense_heads import ATSSHead
EPS = 1e-12
try:
import sklearn.mixture as skm
except ImportE... | 28,818 | 43.065749 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/retina_sepbn_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from ..builder import HEADS
from .anchor_head import AnchorHead
@HEADS.register_module()
class RetinaSepBNHead(AnchorHead):
""""RetinaHead with separate BN.
In RetinaHead, conv/norm layers are shared across different FPN... | 4,288 | 36.622807 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/anchor_free_head.py | from abc import abstractmethod
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from mmcv.runner import force_fp32
from mmdet.core import multi_apply
from ..builder import HEADS, build_loss
from .base_dense_head import BaseDenseHead
from .dense_test_mixins import BB... | 13,494 | 38.57478 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/pisa_ssd_head.py | import torch
from mmdet.core import multi_apply
from ..builder import HEADS
from ..losses import CrossEntropyLoss, SmoothL1Loss, carl_loss, isr_p
from .ssd_head import SSDHead
# TODO: add loss evaluator for SSD
@HEADS.register_module()
class PISASSDHead(SSDHead):
def loss(self,
cls_scores,
... | 5,551 | 38.657143 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/pisa_retinanet_head.py | import torch
from mmcv.runner import force_fp32
from mmdet.core import images_to_levels
from ..builder import HEADS
from ..losses import carl_loss, isr_p
from .retina_head import RetinaHead
@HEADS.register_module()
class PISARetinaHead(RetinaHead):
"""PISA Retinanet Head.
The head owns the same structure wi... | 6,220 | 39.135484 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/gfl_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, Scale, bias_init_with_prob, normal_init
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, bbox2distance, bbox_overlaps,
build_assigner, build_sampler, distance2bbox,... | 27,254 | 42.125 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/corner_head.py | from math import ceil, log
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, bias_init_with_prob
from mmcv.ops import CornerPool, batched_nms
from mmdet.core import multi_apply
from ..builder import HEADS, build_loss
from ..utils import gaussian_radius, gen_gaussian_t... | 46,260 | 42.437559 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/yolact_head.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, xavier_init
from mmcv.runner import force_fp32
from mmdet.core import build_sampler, fast_nms, images_to_levels, multi_apply
from ..builder import HEADS, build_loss
from .anchor_head import AnchorHead... | 39,435 | 40.953191 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/base_dense_head.py | from abc import ABCMeta, abstractmethod
import torch.nn as nn
class BaseDenseHead(nn.Module, metaclass=ABCMeta):
"""Base class for DenseHeads."""
def __init__(self):
super(BaseDenseHead, self).__init__()
@abstractmethod
def loss(self, **kwargs):
"""Compute losses of the head."""
... | 2,051 | 33.2 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/free_anchor_retina_head.py | import torch
import torch.nn.functional as F
from mmdet.core import bbox_overlaps
from ..builder import HEADS
from .retina_head import RetinaHead
EPS = 1e-12
@HEADS.register_module()
class FreeAnchorRetinaHead(RetinaHead):
"""FreeAnchor RetinaHead used in https://arxiv.org/abs/1909.02466.
Args:
num... | 11,148 | 40.140221 | 94 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/guided_anchor_head.py | import torch
import torch.nn as nn
from mmcv.cnn import bias_init_with_prob, normal_init
from mmcv.ops import DeformConv2d, MaskedConv2d
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, build_anchor_generator,
build_assigner, build_bbox_coder, build_sampler,
... | 36,268 | 41.370327 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/sabl_retina_head.py | import numpy as np
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
from mmcv.runner import force_fp32
from mmdet.core import (build_anchor_generator, build_assigner,
build_bbox_coder, build_sampler, images_to_levels,
m... | 26,915 | 42.483037 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/fovea_head.py | import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, normal_init
from mmcv.ops import DeformConv2d
from mmdet.core import multi_apply, multiclass_nms
from ..builder import HEADS
from .anchor_free_head import AnchorFreeHead
INF = 1e8
class FeatureAlign(nn.Module):
def __init__(self,
... | 14,405 | 41.122807 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/dense_heads/dense_test_mixins.py | from inspect import signature
import torch
from mmdet.core import bbox2result, bbox_mapping_back, multiclass_nms
class BBoxTestMixin(object):
"""Mixin class for test time augmentation of bboxes."""
def merge_aug_bboxes(self, aug_bboxes, aug_scores, img_metas):
"""Merge augmented detection bboxes an... | 3,983 | 39.653061 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/utils/gaussian_target.py | from math import sqrt
import torch
def gaussian2D(radius, sigma=1, dtype=torch.float32, device='cpu'):
"""Generate 2D gaussian kernel.
Args:
radius (int): Radius of gaussian kernel.
sigma (int): Sigma of gaussian function. Default: 1.
dtype (torch.dtype): Dtype of gaussian tensor. De... | 5,784 | 30.102151 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/utils/res_layer.py | from mmcv.cnn import build_conv_layer, build_norm_layer
from torch import nn as nn
class ResLayer(nn.Sequential):
"""ResLayer to build ResNet style backbone.
Args:
block (nn.Module): block used to build ResLayer.
inplanes (int): inplanes of block.
planes (int): planes of block.
... | 3,655 | 34.495146 | 77 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/standard_roi_head.py | import torch
from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler
from ..builder import HEADS, build_head, build_roi_extractor
from .base_roi_head import BaseRoIHead
from .test_mixins import BBoxTestMixin, MaskTestMixin
@HEADS.register_module()
class StandardRoIHead(BaseRoIHead, BBoxTestMixin,... | 12,006 | 40.690972 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/grid_roi_head.py | import torch
from mmdet.core import bbox2result, bbox2roi
from ..builder import HEADS, build_head, build_roi_extractor
from .standard_roi_head import StandardRoIHead
@HEADS.register_module()
class GridRoIHead(StandardRoIHead):
"""Grid roi head for Grid R-CNN.
https://arxiv.org/abs/1811.12030
"""
de... | 7,100 | 39.118644 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/cascade_roi_head.py | import torch
import torch.nn as nn
from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, build_assigner,
build_sampler, merge_aug_bboxes, merge_aug_masks,
multiclass_nms)
from ..builder import HEADS, build_head, build_roi_extractor
from .base_roi_head import BaseR... | 21,967 | 42.50099 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/dynamic_roi_head.py | import numpy as np
import torch
from mmdet.core import bbox2roi
from mmdet.models.losses import SmoothL1Loss
from ..builder import HEADS
from .standard_roi_head import StandardRoIHead
@HEADS.register_module()
class DynamicRoIHead(StandardRoIHead):
"""RoI head for `Dynamic R-CNN <https://arxiv.org/abs/2004.06002>... | 6,415 | 42.060403 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/point_rend_roi_head.py | # Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend # noqa
import torch
import torch.nn.functional as F
from mmcv.ops import point_sample, rel_roi_point_to_rel_img_point
from mmdet.core import bbox2roi, bbox_mapping, merge_aug_masks
from .. import builder
from ..builder impo... | 10,311 | 46.086758 | 101 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/base_roi_head.py | from abc import ABCMeta, abstractmethod
import torch.nn as nn
from ..builder import build_shared_head
class BaseRoIHead(nn.Module, metaclass=ABCMeta):
"""Base class for RoIHeads."""
def __init__(self,
bbox_roi_extractor=None,
bbox_head=None,
mask_roi_extra... | 3,060 | 27.607477 | 78 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/mask_scoring_roi_head.py | import torch
from mmdet.core import bbox2roi
from ..builder import HEADS, build_head
from .standard_roi_head import StandardRoIHead
@HEADS.register_module()
class MaskScoringRoIHead(StandardRoIHead):
"""Mask Scoring RoIHead for Mask Scoring RCNN.
https://arxiv.org/abs/1903.00241
"""
def __init__(se... | 5,503 | 43.747967 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/htc_roi_head.py | import torch
import torch.nn.functional as F
from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, merge_aug_bboxes,
merge_aug_masks, multiclass_nms)
from ..builder import HEADS, build_head, build_roi_extractor
from .cascade_roi_head import CascadeRoIHead
@HEADS.register_module()
class... | 25,919 | 42.932203 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/test_mixins.py | import logging
import sys
import torch
from mmdet.core import (bbox2roi, bbox_mapping, merge_aug_bboxes,
merge_aug_masks, multiclass_nms)
logger = logging.getLogger(__name__)
if sys.version_info >= (3, 7):
from mmdet.utils.contextmanagers import completed
class BBoxTestMixin(object):
... | 10,852 | 41.897233 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/roi_extractors/base_roi_extractor.py | from abc import ABCMeta, abstractmethod
import torch
import torch.nn as nn
from mmcv import ops
class BaseRoIExtractor(nn.Module, metaclass=ABCMeta):
"""Base class for RoI extractor.
Args:
roi_layer (dict): Specify RoI layer type and arguments.
out_channels (int): Output channels of RoI laye... | 2,760 | 31.869048 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/roi_extractors/single_level_roi_extractor.py | import torch
from mmcv.runner import force_fp32
from mmdet.models.builder import ROI_EXTRACTORS
from .base_roi_extractor import BaseRoIExtractor
@ROI_EXTRACTORS.register_module()
class SingleRoIExtractor(BaseRoIExtractor):
"""Extract RoI features from a single level feature map.
If there are multiple input ... | 3,114 | 36.53012 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/bbox_heads/bbox_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.runner import auto_fp16, force_fp32
from torch.nn.modules.utils import _pair
from mmdet.core import build_bbox_coder, multi_apply, multiclass_nms
from mmdet.models.builder import HEADS, build_loss
from mmdet.models.losses import accuracy
@H... | 13,645 | 39.734328 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/bbox_heads/sabl_head.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, kaiming_init, normal_init, xavier_init
from mmcv.runner import force_fp32
from mmdet.core import build_bbox_coder, multi_apply, multiclass_nms
from mmdet.models.builder import HEADS, build_loss
from m... | 24,585 | 41.907504 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule
from mmdet.models.builder import HEADS
from .bbox_head import BBoxHead
@HEADS.register_module()
class ConvFCBBoxHead(BBoxHead):
r"""More general bbox head, with shared conv and fc layers and two optional
separated branches.
.. code-block:: none
... | 7,436 | 35.101942 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/bbox_heads/double_bbox_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, normal_init, xavier_init
from mmdet.models.backbones.resnet import Bottleneck
from mmdet.models.builder import HEADS
from .bbox_head import BBoxHead
class BasicResBlock(nn.Module):
"""Basic residual block.
This block is a little different from the block... | 5,380 | 30.104046 | 78 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/shared_heads/res_layer.py | import torch.nn as nn
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import auto_fp16, load_checkpoint
from mmdet.models.backbones import ResNet
from mmdet.models.builder import SHARED_HEADS
from mmdet.models.utils import ResLayer as _ResLayer
from mmdet.utils import get_root_logger
@SHARED_HEADS.... | 2,454 | 30.474359 | 74 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/mask_heads/grid_head.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, kaiming_init, normal_init
from mmdet.models.builder import HEADS, build_loss
@HEADS.register_module()
class GridHead(nn.Module):
def __init__(self,
grid_points=9,
... | 15,432 | 41.869444 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/mask_heads/coarse_mask_head.py | import torch.nn as nn
from mmcv.cnn import ConvModule, Linear, constant_init, xavier_init
from mmcv.runner import auto_fp16
from mmdet.models.builder import HEADS
from .fcn_mask_head import FCNMaskHead
@HEADS.register_module()
class CoarseMaskHead(FCNMaskHead):
"""Coarse mask head used in PointRend.
Compare... | 3,233 | 34.152174 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/mask_heads/maskiou_head.py | import numpy as np
import torch
import torch.nn as nn
from mmcv.cnn import Conv2d, Linear, MaxPool2d, kaiming_init, normal_init
from mmcv.runner import force_fp32
from torch.nn.modules.utils import _pair
from mmdet.models.builder import HEADS, build_loss
@HEADS.register_module()
class MaskIoUHead(nn.Module):
"""... | 7,332 | 38.213904 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/mask_heads/fcn_mask_head.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import Conv2d, ConvModule, build_upsample_layer
from mmcv.ops.carafe import CARAFEPack
from mmcv.runner import auto_fp16, force_fp32
from torch.nn.modules.utils import _pair
from mmdet.core import mask_target
from mmdet... | 12,399 | 38.240506 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/mask_heads/fused_semantic_head.py | import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, kaiming_init
from mmcv.runner import auto_fp16, force_fp32
from mmdet.models.builder import HEADS
@HEADS.register_module()
class FusedSemanticHead(nn.Module):
r"""Multi-level fused semantic segmentation head.
.. code-bloc... | 3,610 | 32.435185 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/roi_heads/mask_heads/mask_point_head.py | # 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, normal_init
from mmcv.ops import point_sample, rel_roi_point_to_rel_img_point
from mmdet.models.builder import HEADS, build... | 13,190 | 42.82392 | 126 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/ghm_loss.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
def _expand_onehot_labels(labels, label_weights, label_channels):
bin_labels = labels.new_full((labels.size(0), label_channels), 0)
inds = torch.nonzero(
(labels >= 0) & (labels < label_channels), as_tuple... | 6,365 | 35.797688 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/mse_loss.py | 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()
class MSELoss(nn.Module):
"""MSELoss.
... | 1,463 | 28.28 | 78 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/pisa_loss.py | import torch
from mmdet.core import bbox_overlaps
def isr_p(cls_score,
bbox_pred,
bbox_targets,
rois,
sampling_results,
loss_cls,
bbox_coder,
k=2,
bias=0,
num_class=80):
"""Importance-based Sample Reweighting (ISR_P), posit... | 7,076 | 38.099448 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/balanced_l1_loss.py | import numpy as np
import torch
import torch.nn as nn
from ..builder import LOSSES
from .utils import weighted_loss
@weighted_loss
def balanced_l1_loss(pred,
target,
beta=1.0,
alpha=0.5,
gamma=1.5,
reduction='mea... | 4,116 | 33.596639 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/iou_loss.py | import math
import torch
import torch.nn as nn
from mmdet.core import bbox_overlaps
from ..builder import LOSSES
from .utils import weighted_loss
@weighted_loss
def iou_loss(pred, target, eps=1e-6):
"""IoU loss.
Computing the IoU loss between a set of predicted bboxes and target bboxes.
The loss is cal... | 13,454 | 31.188995 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/smooth_l1_loss.py | import torch
import torch.nn as nn
from ..builder import LOSSES
from .utils import weighted_loss
@weighted_loss
def smooth_l1_loss(pred, target, beta=1.0):
"""Smooth L1 loss.
Args:
pred (torch.Tensor): The prediction.
target (torch.Tensor): The learning target of the prediction.
beta... | 4,423 | 31.291971 | 78 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/gfocal_loss.py | import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weighted_loss
@weighted_loss
def quality_focal_loss(pred, target, beta=2.0, use_sigmoid=True):
r"""Quality Focal Loss (QFL) is from `Generalized Focal Loss: Learning
Qualified and Distributed Bounding Boxes ... | 7,336 | 38.446237 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/varifocal_loss.py | import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weight_reduce_loss
def varifocal_loss(pred,
target,
weight=None,
alpha=0.75,
gamma=2.0,
iou_weighted=True,
... | 5,265 | 38.893939 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/utils.py | import functools
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:
Tensor: Reduced loss tensor.
"""
reduction_enum = ... | 3,003 | 29.343434 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/ae_loss.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
def ae_loss_per_image(tl_preds, br_preds, match):
"""Associative Embedding Loss in one image.
Associative Embedding Loss including two parts: pull loss and push loss.
Pull loss makes embedding vectors from sa... | 3,757 | 36.207921 | 143 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/accuracy.py | import torch.nn as nn
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)
target (torch.Tensor): The target of each prediction, shape (N, )
topk (int | tupl... | 2,905 | 36.74026 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/focal_loss.py | 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
# This method is only for debugging
def py_sigmoid_focal_loss(pred,
target,
weigh... | 6,417 | 39.620253 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/cross_entropy_loss.py | 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',
avg_factor=None,
class_weight=N... | 7,352 | 35.58209 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/losses/gaussian_focal_loss.py | import torch.nn as nn
from ..builder import LOSSES
from .utils import weighted_loss
@weighted_loss
def gaussian_focal_loss(pred, gaussian_target, alpha=2.0, gamma=4.0):
"""`Focal Loss <https://arxiv.org/abs/1708.02002>`_ for targets in gaussian
distribution.
Args:
pred (torch.Tensor): The predic... | 3,211 | 34.688889 | 108 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/hrnet.py | import torch.nn as nn
from mmcv.cnn import (build_conv_layer, build_norm_layer, constant_init,
kaiming_init)
from mmcv.runner import load_checkpoint
from torch.nn.modules.batchnorm import _BatchNorm
from mmdet.utils import get_root_logger
from ..builder import BACKBONES
from .resnet import BasicB... | 20,359 | 36.843866 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/regnet.py | 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 backbone.
More details can be found in `paper <https://arxi... | 12,269 | 36.638037 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/detectors_resnext.py | 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__(self,
inplanes,
... | 3,872 | 30.487805 | 77 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/resnet.py | import torch.nn as nn
import torch.utils.checkpoint as cp
from mmcv.cnn import (build_conv_layer, build_norm_layer, build_plugin_layer,
constant_init, kaiming_init)
from mmcv.runner import load_checkpoint
from torch.nn.modules.batchnorm import _BatchNorm
from mmdet.utils import get_root_logger
fr... | 23,378 | 34.156391 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/detectors_resnet.py | import torch.nn as nn
import torch.utils.checkpoint as cp
from mmcv.cnn import build_conv_layer, build_norm_layer, constant_init
from ..builder import BACKBONES
from .resnet import Bottleneck as _Bottleneck
from .resnet import ResNet
class Bottleneck(_Bottleneck):
r"""Bottleneck for the ResNet backbone in `Detec... | 10,517 | 33.372549 | 78 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/ssd_vgg.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import VGG, constant_init, kaiming_init, normal_init, xavier_init
from mmcv.runner import load_checkpoint
from mmdet.utils import get_root_logger
from ..builder import BACKBONES
@BACKBONES.register_module()
class SSDVGG(VGG):
"""VGG... | 5,882 | 33.605882 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/resnext.py | 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__(self,
inplanes,
... | 4,731 | 34.578947 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/hourglass.py | import torch.nn as nn
from mmcv.cnn import ConvModule
from ..builder import BACKBONES
from ..utils import ResLayer
from .resnet import BasicBlock
class HourglassModule(nn.Module):
"""Hourglass Module for HourglassNet backbone.
Generate module recursively and use BasicBlock as the base unit.
Args:
... | 6,452 | 31.427136 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/res2net.py | 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, constant_init,
kaiming_init)
from mmcv.runner import load_checkpoint
from torch.nn.modules.batchnorm import _BatchNorm
from mmdet.utils import get_root_log... | 12,675 | 35.011364 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/models/backbones/darknet.py | # Copyright (c) 2019 Western Digital Corporation or its affiliates.
import logging
import torch.nn as nn
from mmcv.cnn import ConvModule, constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from torch.nn.modules.batchnorm import _BatchNorm
from ..builder import BACKBONES
class ResBlock(nn.Module):
... | 7,574 | 36.875 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/datasets/custom.py | import os.path as osp
import warnings
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):
"""Custom dataset for detection.
The... | 11,329 | 34.29595 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/datasets/dataset_wrappers.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... | 11,088 | 38.183746 | 167 | py |
GFocalV2 | GFocalV2-master/mmdet/datasets/builder.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, ... | 5,291 | 35.75 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/datasets/samplers/group_sampler.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.... | 4,898 | 33.744681 | 78 | py |
GFocalV2 | GFocalV2-master/mmdet/datasets/samplers/distributed_sampler.py | 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 = shuffle
d... | 978 | 32.758621 | 77 | py |
GFocalV2 | GFocalV2-master/mmdet/datasets/pipelines/formating.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... | 12,033 | 31.969863 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/utils/contextmanagers.py | 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 completed(trace_name='',
name='',
... | 4,077 | 32.42623 | 79 | py |
GFocalV2 | GFocalV2-master/mmdet/utils/profiling.py | 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_stream=None):
"""Print time spent by CP... | 1,288 | 31.225 | 73 | py |
qml | qml-master/docs/source/conf.py | # -*- coding: utf-8 -*-
#
# QML documentation build configuration file, created by
# sphinx-quickstart on Sun Jun 4 14:41:04 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All c... | 4,965 | 30.0375 | 100 | py |
GBM-perf | GBM-perf-master/v1-keep-old-before_docker/run/2a-xgboost-gpu.py |
import xgboost as xgb
import pandas as pd
from sklearn import metrics
import time
dtrain = xgb.DMatrix('train-10m.libsvm')
dtest = xgb.DMatrix('test-10m.libsvm')
#params = {'max_depth':10, 'eta':0.1, 'objective':'binary:logistic'}
#params = {'max_depth':10, 'eta':0.1, 'objective':'binary:logistic', 'updater':'grow_c... | 955 | 27.969697 | 101 | py |
GBM-perf | GBM-perf-master/analysis/dask/xgb-dask.py | import pandas as pd
from sklearn import metrics
from dask.distributed import Client, LocalCluster
import dask.dataframe as dd
import xgboost as xgb
cluster = LocalCluster(n_workers=16, threads_per_worker=1)
client = Client(cluster)
d_train = pd.read_csv("https://raw.githubusercontent.com/szilard/benchm-ml--data/ma... | 1,319 | 29 | 117 | py |
GBM-perf | GBM-perf-master/analysis/dask/xgb.py | import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
import xgboost as xgb
d_train = pd.read_csv("https://raw.githubusercontent.com/szilard/benchm-ml--data/master/int_enc/train-1m-intenc.csv")
d_test = pd.read_csv("https://raw.githubusercontent.com/szilard/benchm-ml--... | 858 | 28.62069 | 117 | py |
GBM-perf | GBM-perf-master/analysis/dask/old_encoding/xgb-intenc.py | import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
import xgboost as xgb
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.csv")
d_all = pd.concat([d_train,d_test])
v... | 1,248 | 28.738095 | 101 | py |
GBM-perf | GBM-perf-master/analysis/dask/old_encoding/xgb-dask.py | import pandas as pd
from sklearn import metrics
from dask.distributed import Client, LocalCluster
import dask.dataframe as dd
import dask.array as da
from dask_ml import preprocessing
import xgboost as xgb
cluster = LocalCluster(n_workers=16, threads_per_worker=1)
client = Client(cluster)
d_train = pd.read_csv("ht... | 1,692 | 28.189655 | 101 | py |
GBM-perf | GBM-perf-master/analysis/dask/old_encoding/xgb-dask-deprecated.py | import pandas as pd
from sklearn import metrics
from dask.distributed import Client, LocalCluster
import dask.dataframe as dd
import dask.array as da
from dask_ml import preprocessing
import dask_xgboost as dxgb
cluster = LocalCluster(n_workers=16, threads_per_worker=1)
client = Client(cluster)
d_train = pd.read_c... | 1,581 | 28.849057 | 101 | py |
GBM-perf | GBM-perf-master/analysis/intenc/xgboost.py | import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
import xgboost as xgb
d_train = pd.read_csv("https://raw.githubusercontent.com/szilard/benchm-ml--data/master/int_enc/train-1m-intenc.csv")
d_test = pd.read_csv("https://raw.githubusercontent.com/szilard/benchm-ml--... | 926 | 27.96875 | 117 | py |
GBM-perf | GBM-perf-master/analysis/random_forest/xgboost.py |
import pandas as pd
import numpy as np
from sklearn import preprocessing
from scipy import sparse
from sklearn import metrics
import xgboost as xgb
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.csv")
d_all = pd.c... | 1,634 | 29.277778 | 101 | py |
GBM-perf | GBM-perf-master/analysis/rapids-ai/xgb-ohe.py | import cudf
import xgboost as xgb
import pandas as pd
import numpy as np
from scipy import sparse
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.csv")
d_... | 3,112 | 28.932692 | 121 | py |
GBM-perf | GBM-perf-master/analysis/rapids-ai/xgb-intenc.py | import cudf
import xgboost as xgb
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.csv")
d_all = pd.concat([d_train,... | 2,532 | 24.585859 | 105 | py |
GBM-perf | GBM-perf-master/analysis/tensorflow-df/tfdf.py | import tensorflow_decision_forests as tfdf
import numpy as np
import pandas as pd
import tensorflow as tf
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.csv")
d_train["dep_delayed_15min"]... | 836 | 28.892857 | 85 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/tabnet-base.py | from pytorch_tabnet.tab_model import TabNetClassifier
import torch
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.... | 1,659 | 28.642857 | 80 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/tabnet.py | from pytorch_tabnet.tab_model import TabNetClassifier
import torch
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.... | 1,658 | 29.163636 | 80 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/tabnet-20best.py | from pytorch_tabnet.tab_model import TabNetClassifier
import torch
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.... | 2,019 | 32.114754 | 86 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/tabnet-best-evil.py | from pytorch_tabnet.tab_model import TabNetClassifier
import torch
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.... | 1,776 | 30.175439 | 80 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/old-keep/tabnet-estop.py | from pytorch_tabnet.tab_model import TabNetClassifier
import torch
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.... | 2,176 | 32.492308 | 93 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/old-keep/tabnet-min.py | from pytorch_tabnet.tab_model import TabNetClassifier
import torch
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.... | 1,330 | 26.163265 | 80 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/old-keep/tabnet-1cLR.py | from pytorch_tabnet.tab_model import TabNetClassifier
import torch
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.... | 1,973 | 31.360656 | 88 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/old-keep/tabnet-epoch10.py | from pytorch_tabnet.tab_model import TabNetClassifier
import torch
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.... | 1,897 | 30.633333 | 93 | py |
GBM-perf | GBM-perf-master/analysis/tabnet/xgb/xgb.py | import xgboost as xgb
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn import metrics
d_train = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
d_test = pd.read_csv("https://s3.amazonaws.com/benchm-ml--main/test.csv")
d_all = pd.concat([d_train,d_test])
... | 1,156 | 27.925 | 101 | py |
GBM-perf | GBM-perf-master/analysis/h2o4gpu/xgboost.py |
import pandas as pd
import numpy as np
from sklearn import preprocessing
from scipy import sparse
from sklearn import metrics
import xgboost as xgb
import time
d_train = pd.read_csv("train.csv")
d_test = pd.read_csv("test.csv")
d = pd.concat([d_train, d_test])
vars_cat = ["Month","DayofMonth","DayOfWeek","UniqueC... | 1,234 | 23.215686 | 83 | py |
TempoQR | TempoQR-main/qa_datasets.py | from pathlib import Path
import pkg_resources
import pickle
from collections import defaultdict
from typing import Dict, Tuple, List
import json
import numpy as np
import torch
# from qa_models import QA_model
import utils
from tqdm import tqdm
from transformers import RobertaTokenizer
from transformers import DistilB... | 27,598 | 38.825397 | 153 | py |
TempoQR | TempoQR-main/utils.py | import pickle
import random
import torch
import numpy as np
from tcomplex import TComplEx
from tqdm import tqdm
def loadTkbcModel(tkbc_model_file):
print('Loading tkbc model from', tkbc_model_file)
x = torch.load(tkbc_model_file,map_location=torch.device("cpu"))
num_ent = x['embeddings.0.weight'].shape[0]... | 7,990 | 35.824885 | 130 | py |
TempoQR | TempoQR-main/qa_baselines.py | import math
import torch
from torch import nn
import numpy as np
from tcomplex import TComplEx
from transformers import RobertaModel
from transformers import BertModel
from transformers import DistilBertModel
import pdb
# training data: questions
# model:
# 1. tkbc model embeddings (may or may not be frozen)
# 2. que... | 9,331 | 38.542373 | 136 | py |
TempoQR | TempoQR-main/train_qa_model.py | import argparse
from typing import Dict
import logging
import torch
from torch import optim
import pickle
import numpy as np
from qa_baselines import QA_baseline, QA_lm, QA_embedkgqa, QA_cronkgqa
from qa_tempoqr import QA_TempoQR
from qa_datasets import QA_Dataset, QA_Dataset_TempoQR, QA_Dataset_Baseline
from torch.ut... | 13,849 | 33.798995 | 138 | py |
TempoQR | TempoQR-main/qa_tempoqr.py | import math
import torch
from torch import nn
import numpy as np
from tcomplex import TComplEx
from transformers import DistilBertModel
from torch.nn import LayerNorm
import pdb
# training data: questions
# model:
# 1. tkbc model embeddings (may or may not be frozen)
# 2. question sentence embeddings (may or may not b... | 11,619 | 39.347222 | 147 | py |
TempoQR | TempoQR-main/tcomplex.py | # Copyright (c) Facebook, Inc. and its affiliates.
from abc import ABC, abstractmethod
from typing import Tuple, List, Dict
import math
import torch
from torch import nn
import numpy as np
class TKBCModel(nn.Module, ABC):
@abstractmethod
def get_rhs(self, chunk_begin: int, chunk_size: int):
pass
... | 18,136 | 38.004301 | 115 | py |
bonito | bonito-master/setup.py | import os
import re
from setuptools import setup, find_packages
from setuptools.command.install import install
__pkg_name__ = 'bonito'
require_file = 'requirements.txt'
package_name = "ont-%s" % __pkg_name__
verstrline = open(os.path.join(__pkg_name__, '__init__.py'), 'r').read()
vsre = r"^__version__ = ['\"]([^'\"]... | 1,270 | 26.042553 | 97 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.