id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
9,949
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.structures.bounding_box import BoxList import json import numpy as np import os.path as osp import os from prettytable import PrettyTable import xml.etree.ElementTree as ET from collections import defaultdict from pathlib import P...
Parses the xml files in the Flickr30K Entities dataset input: filename - full file path to the annotations file to parse output: dictionary with the following fields: scene - list of identifiers which were annotated as pertaining to the whole scene nobox - list of identifiers which were annotated as not being visible i...
9,950
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.structures.bounding_box import BoxList import json import numpy as np import os.path as osp import os from prettytable import PrettyTable import xml.etree.ElementTree as ET from collections import defaultdict from pathlib import P...
Return intersection-over-union (Jaccard index) of boxes. Both sets of boxes are expected to be in ``(x1, y1, x2, y2)`` format with ``0 <= x1 < x2`` and ``0 <= y1 < y2``. Args: boxes1 (Tensor[N, 4]) boxes2 (Tensor[M, 4]) Returns: iou (Tensor[N, M]): the NxM matrix containing the pairwise IoU values for every element in ...
9,951
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.structures.bounding_box import BoxList import json import numpy as np import os.path as osp import os from prettytable import PrettyTable import xml.etree.ElementTree as ET from collections import defaultdict from pathlib import P...
Return the boxes corresponding to the smallest enclosing box containing all the provided boxes The boxes are expected in [x1, y1, x2, y2] format
9,952
import logging import tempfile import os import torch import numpy as np import json from collections import OrderedDict from tqdm import tqdm from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.bo...
null
9,953
import logging import tempfile import os import torch import numpy as np import json from collections import OrderedDict from tqdm import tqdm from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.bo...
null
9,954
import copy import datetime import json import os from collections import OrderedDict, defaultdict import numpy as np import pycocotools.mask as mask_util import torch import torch._six import maskrcnn_benchmark.utils.mdetr_dist as dist from maskrcnn_benchmark.utils.mdetr_dist import all_gather from .lvis import LVIS ...
null
9,955
import copy import datetime import json import os from collections import OrderedDict, defaultdict import numpy as np import pycocotools.mask as mask_util import torch import torch._six import maskrcnn_benchmark.utils.mdetr_dist as dist from maskrcnn_benchmark.utils.mdetr_dist import all_gather from .lvis import LVIS ...
null
9,956
import copy import datetime import json import os from collections import OrderedDict, defaultdict import numpy as np import pycocotools.mask as mask_util import torch import torch._six import maskrcnn_benchmark.utils.mdetr_dist as dist from maskrcnn_benchmark.utils.mdetr_dist import all_gather from .lvis import LVIS ...
null
9,957
import copy import datetime import json import os from collections import OrderedDict, defaultdict import numpy as np import pycocotools.mask as mask_util import torch import torch._six import maskrcnn_benchmark.utils.mdetr_dist as dist from maskrcnn_benchmark.utils.mdetr_dist import all_gather from .lvis import LVIS ...
null
9,958
import json import os import time from collections import defaultdict import pycocotools.mask as mask_utils import torchvision from PIL import Image def _isArrayLike(obj): return hasattr(obj, "__iter__") and hasattr(obj, "__len__")
null
9,959
from __future__ import division import os from collections import OrderedDict import numpy as np import torch from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou, getUnionBBox def evaluate_box_proposals( predictions, dataset, thresholds=No...
null
9,960
from __future__ import division import os from collections import OrderedDict import numpy as np import torch from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou, getUnionBBox The provided code snippet includes necessary dependencies for impl...
Calculate average precisions based on evaluation code of PASCAL VOC. This function calculates average precisions from given precisions and recalls. The code is based on the evaluation code used in PASCAL VOC Challenge. Args: prec (list of numpy.array): A list of arrays. :obj:`prec[l]` indicates precision for class :mat...
9,961
import torch import numpy as np from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.data import transforms as T from maskrcnn_benchmark.structures.image_list import to_image_list from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlis...
null
9,962
import collections import json import os.path as op import numpy as np import torch from .tsv import TSVYamlDataset, find_file_path_in_yaml from .box_label_loader import BoxLabelLoader from maskrcnn_benchmark.data.datasets.coco_dt import CocoDetectionTSV def sort_key_by_val(dic): sorted_dic = sorted(dic.items(), k...
null
9,963
import collections import json import os.path as op import numpy as np import torch from .tsv import TSVYamlDataset, find_file_path_in_yaml from .box_label_loader import BoxLabelLoader from maskrcnn_benchmark.data.datasets.coco_dt import CocoDetectionTSV def bbox_overlaps(anchors, gt_boxes): """ anchors: (N, 4)...
Only include boxes that overlap as possible relations. If no overlapping boxes, use all of them.
9,964
import bisect import copy import logging import os import torch.utils.data import torch.distributed as dist from maskrcnn_benchmark.utils.comm import get_world_size from maskrcnn_benchmark.utils.imports import import_file from . import datasets as D from . import samplers from .collate_batch import BatchCollator, BBoxA...
null
9,965
import torch def cat(tensors, dim=0): def permute_and_flatten(layer, N, A, C, H, W): def concat_box_prediction_layers(box_regression, box_cls=None, token_logits=None): box_regression_flattened = [] box_cls_flattened = [] token_logit_flattened = [] # for each feature level, permute the outputs to make ...
null
9,966
import torch def round_channels(channels, divisor=8): rounded_channels = max(int(channels + divisor / 2.0) // divisor * divisor, divisor) if float(rounded_channels) < 0.9 * channels: rounded_channels += divisor return rounded_channels
null
9,967
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms class Conv2dStaticSamePadding(nn.Module): """ created by Zylo117 The real keras/tensorflow conv2d with sam...
Chooses static padding if you have specified an image size, and dynamic padding otherwise. Static padding is necessary for ONNX exporting of models.
9,968
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms The provided code snippet includes necessary dependencies for implementing the `round_filters` function. Write a Pyth...
Calculate and round number of filters based on depth multiplier.
9,969
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms The provided code snippet includes necessary dependencies for implementing the `round_repeats` function. Write a Pyth...
Round number of filters based on depth multiplier.
9,970
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms The provided code snippet includes necessary dependencies for implementing the `drop_connect` function. Write a Pytho...
Drop connect.
9,971
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms def efficientnet(width_coefficient=None, depth_coefficient=None, dropout_rate=0.2, drop_connect_rate=...
Get the block args and global params for a given model
9,972
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms url_map = { 'efficientnet-b0': 'https://publicmodels.blob.core.windows.net/container/aa/efficientnet-b0-355c32eb.p...
Loads pretrained weights, and downloads if loading for the first time.
9,973
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms def init_weights(model): for name, module in model.named_modules(): is_conv_layer = isinstance(module, nn...
null
9,974
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms def calc_iou(a, b): # a(anchor) [boxes, (y1, x1, y2, x2)] # b(gt, coco-style) [boxes, (x1, y1, x2, y2)] ...
null
9,975
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms def postprocess2(x, anchors, regression, classification, transformed_anchors, threshold, iou_thresho...
null
9,976
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms def postprocess(x, anchors, regression, classification, regressBoxes, clipBoxes, threshold, iou_threshold): ancho...
null
9,977
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms def display(preds, imgs, obj_list, imshow=True, imwrite=False): for i in range(len(imgs)): if len(preds[i...
null
9,978
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms sigmoid_focal_loss_cuda = _SigmoidFocalLoss.apply def calculate_focal_loss2(classification, target_list, alpha, gamm...
null
9,979
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms def calculate_focal_loss(classification, targets, alpha, gamma): classification = classification.sigmoid() de...
null
9,980
import torch import re import numpy as np import torch.nn as nn import torch.nn.functional as F import logging import cv2 import math import itertools import collections from torchvision.ops import nms def calculate_giou(pred, gt): ax1, ay1, ax2, ay2 = pred[:, 0], pred[:, 1], pred[:, 2], pred[:, 3] bx1, by1, b...
null
9,981
from __future__ import absolute_import, division, print_function, unicode_literals import copy import logging import math from collections import OrderedDict import torch import torch.nn as nn from torch.nn import BatchNorm2d, SyncBatchNorm from maskrcnn_benchmark.layers import Conv2d, interpolate from maskrcnn_benchma...
null
9,982
from __future__ import absolute_import, division, print_function, unicode_literals import copy import logging import math from collections import OrderedDict import torch import torch.nn as nn from torch.nn import BatchNorm2d, SyncBatchNorm from maskrcnn_benchmark.layers import Conv2d, interpolate from maskrcnn_benchma...
null
9,983
import os import math import torch import torch.nn as nn import torch.nn.functional as F from maskrcnn_benchmark.layers import SEBlock, swish The provided code snippet includes necessary dependencies for implementing the `calc_tf_padding` function. Write a Python function `def calc_tf_padding(x, ke...
Calculate TF-same like padding size. Parameters: ---------- x : tensor Input tensor. kernel_size : int Convolution window size. stride : int, default 1 Strides of the convolution. dilation : int, default 1 Dilation value for convolution layer. Returns ------- tuple of 4 int The size of the padding.
9,984
import os import math import torch import torch.nn as nn import torch.nn.functional as F from maskrcnn_benchmark.layers import SEBlock, swish class ConvBlock(nn.Module): """ Standard convolution block with Batch normalization and activation. Parameters: ---------- in_channels : int Number of...
1x1 version of the standard convolution block. Parameters: ---------- in_channels : int Number of input channels. out_channels : int Number of output channels. stride : int or tuple/list of 2 int, default 1 Strides of the convolution. padding : int, or tuple/list of 2 int, or tuple/list of 4 int, default 0 Padding valu...
9,985
import os import math import torch import torch.nn as nn import torch.nn.functional as F from maskrcnn_benchmark.layers import SEBlock, swish class ConvBlock(nn.Module): """ Standard convolution block with Batch normalization and activation. Parameters: ---------- in_channels : int Number of...
3x3 version of the standard convolution block. Parameters: ---------- in_channels : int Number of input channels. out_channels : int Number of output channels. stride : int or tuple/list of 2 int, default 1 Strides of the convolution. padding : int, or tuple/list of 2 int, or tuple/list of 4 int, default 1 Padding valu...
9,986
import os import math import torch import torch.nn as nn import torch.nn.functional as F from maskrcnn_benchmark.layers import SEBlock, swish class ConvBlock(nn.Module): """ Standard convolution block with Batch normalization and activation. Parameters: ---------- in_channels : int Number of...
3x3 depthwise version of the standard convolution block. Parameters: ---------- in_channels : int Number of input channels. out_channels : int Number of output channels. stride : int or tuple/list of 2 int, default 1 Strides of the convolution. padding : int, or tuple/list of 2 int, or tuple/list of 4 int, default 1 Pa...
9,987
import os import math import torch import torch.nn as nn import torch.nn.functional as F from maskrcnn_benchmark.layers import SEBlock, swish class ConvBlock(nn.Module): """ Standard convolution block with Batch normalization and activation. Parameters: ---------- in_channels : int Number of...
5x5 depthwise version of the standard convolution block. Parameters: ---------- in_channels : int Number of input channels. out_channels : int Number of output channels. stride : int or tuple/list of 2 int, default 1 Strides of the convolution. padding : int, or tuple/list of 2 int, or tuple/list of 4 int, default 2 Pa...
9,988
import os import math import torch import torch.nn as nn import torch.nn.functional as F from maskrcnn_benchmark.layers import SEBlock, swish def round_channels(channels, divisor=8): """ Round weighted channel number (make divisible operation). Parameters: ---------- channels : in...
null
9,989
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from timm.models.layers import DropPath, to_2tuple, trunc_normal_ The provided code snippet includes necessary dependencies for implementing the `window_partition` function. Write a Python ...
Args: x: (B, H, W, C) window_size (int): window size Returns: windows: (num_windows*B, window_size, window_size, C)
9,990
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from timm.models.layers import DropPath, to_2tuple, trunc_normal_ The provided code snippet includes necessary dependencies for implementing the `window_reverse` function. Write a Python fu...
Args: windows: (num_windows*B, window_size, window_size, C) window_size (int): Window size H (int): Height of image W (int): Width of image Returns: x: (B, H, W, C)
9,991
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from timm.models.layers import DropPath, to_2tuple, trunc_normal_ class SwinTransformer(nn.Module): """ Swin Transformer backbone. A PyTorch impl of : `Swin Transformer: Hierarch...
Create a SwinT instance from config. Returns: VoVNet: a :class:`VoVNet` instance.
9,992
import math import torch import torch.nn as nn import torch.nn.functional as F The provided code snippet includes necessary dependencies for implementing the `conv7x7` function. Write a Python function `def conv7x7(in_planes, out_planes, stride=1, groups=1, dilation=1)` to solve the following problem: 7x7 convolution ...
7x7 convolution with padding
9,993
import math import torch import torch.nn as nn import torch.nn.functional as F The provided code snippet includes necessary dependencies for implementing the `conv5x5` function. Write a Python function `def conv5x5(in_planes, out_planes, stride=1, groups=1, dilation=1)` to solve the following problem: 5x5 convolution ...
5x5 convolution with padding
9,994
import math import torch import torch.nn as nn import torch.nn.functional as F The provided code snippet includes necessary dependencies for implementing the `conv3x3` function. Write a Python function `def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1)` to solve the following problem: 3x3 convolution ...
3x3 convolution with padding
9,995
import math import torch import torch.nn as nn import torch.nn.functional as F The provided code snippet includes necessary dependencies for implementing the `conv1x1` function. Write a Python function `def conv1x1(in_planes, out_planes, stride=1)` to solve the following problem: 1x1 convolution Here is the function:...
1x1 convolution
9,996
import math import torch import torch.nn as nn import torch.nn.functional as F def maxpool(**kwargs): return nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
null
9,997
import math import torch import torch.nn as nn import torch.nn.functional as F def avgpool(**kwargs): return nn.AvgPool2d(kernel_size=3, stride=2, padding=1)
null
9,998
import math import torch import torch.nn as nn import torch.nn.functional as F def dropout(prob): return nn.Dropout(prob)
null
9,999
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from einops import rearrange from timm.models.layers import DropPath, to_2tuple, trunc_normal_ The provided code snippet includes necessary dependencies for implementing the `window_partiti...
Args: x: (B, H, W, C) window_size (int): window size Returns: windows: (num_windows*B, window_size, window_size, C)
10,000
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from einops import rearrange from timm.models.layers import DropPath, to_2tuple, trunc_normal_ The provided code snippet includes necessary dependencies for implementing the `window_reverse...
Args: windows: (num_windows*B, window_size, window_size, C) window_size (int): Window size H (int): Height of image W (int): Width of image Returns: x: (B, H, W, C)
10,001
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from einops import rearrange from timm.models.layers import DropPath, to_2tuple, trunc_normal_ class SwinTransformer(nn.Module): """ Swin Transformer backbone. A PyTorch impl of ...
Create a SwinT instance from config. Returns: VoVNet: a :class:`VoVNet` instance.
10,002
import torch.nn as nn from .ops import * import torch import torch.nn as nn import torch.nn.functional as F def channel_shuffle(x, groups): batchsize, num_channels, height, width = x.data.size() channels_per_group = num_channels // groups # reshape x = x.view(batchsize, groups, channels_per_group, hei...
null
10,003
from collections import namedtuple import torch import torch.nn.functional as F from torch import nn from torch.nn import BatchNorm2d, SyncBatchNorm from maskrcnn_benchmark.layers import FrozenBatchNorm2d, NaiveSyncBatchNorm2d from maskrcnn_benchmark.layers import Conv2d, DFConv2d, SELayer from maskrcnn_benchmark.model...
null
10,006
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from einops import rearrange from timm.models.layers import DropPath, to_2tuple, trunc_normal_ class SwinTransformer(nn.Module): """ Swin Transformer backbone. A PyTorch impl of ...
Create a SwinT instance from config. Returns: VoVNet: a :class:`VoVNet` instance.
10,009
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from timm.models.layers import DropPath, to_2tuple, trunc_normal_ class SwinTransformer(nn.Module): """ Swin Transformer backbone. A PyTorch impl of : `Swin Transformer: Hierarch...
Create a SwinT instance from config. Returns: VoVNet: a :class:`VoVNet` instance.
10,010
import torch from torch import nn from torch.nn import functional as F from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.layers import Conv2d, DYReLU from maskrcnn_benchmark.modeling.poolers import Pooler def group_norm(out_channels, affine=True, divisor=1): out_channels = out_channels // divisor ...
null
10,011
import torch from torch import nn from torch.nn import functional as F from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.layers import Conv2d, DYReLU from maskrcnn_benchmark.modeling.poolers import Pooler def group_norm(out_channels, affine=True, divisor=1): out_channels = out_channels // divisor ...
Caffe2 implementation uses XavierFill, which in fact corresponds to kaiming_uniform_ in PyTorch
10,012
import torch from torch import nn from torch.nn import functional as F from maskrcnn_benchmark.config import cfg from maskrcnn_benchmark.layers import Conv2d, DYReLU from maskrcnn_benchmark.modeling.poolers import Pooler def group_norm(out_channels, affine=True, divisor=1): out_channels = out_channels // divisor ...
null
10,013
import torch import torch.nn.functional as F from torch import nn, Tensor import copy from typing import Optional, List def _get_clones(module, N): return nn.ModuleList([copy.deepcopy(module) for i in range(N)])
null
10,014
import torch import torch.nn.functional as F from torch import nn, Tensor import copy from typing import Optional, List The provided code snippet includes necessary dependencies for implementing the `_get_activation_fn` function. Write a Python function `def _get_activation_fn(activation)` to solve the following probl...
Return an activation function given a string
10,015
import logging import torch from maskrcnn_benchmark.modeling.box_coder import BoxCoder from maskrcnn_benchmark.structures.bounding_box import BoxList, _onnx_clip_boxes_to_image from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms from maskrc...
null
10,016
import logging import torch from maskrcnn_benchmark.modeling.box_coder import BoxCoder from maskrcnn_benchmark.structures.bounding_box import BoxList, _onnx_clip_boxes_to_image from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms from maskrc...
null
10,017
import logging import torch from maskrcnn_benchmark.modeling.box_coder import BoxCoder from maskrcnn_benchmark.structures.bounding_box import BoxList, _onnx_clip_boxes_to_image from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms from maskrc...
null
10,018
import logging import torch from maskrcnn_benchmark.modeling.box_coder import BoxCoder from maskrcnn_benchmark.structures.bounding_box import BoxList, _onnx_clip_boxes_to_image from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms from maskrc...
null
10,019
import logging import torch from maskrcnn_benchmark.modeling.box_coder import BoxCoder from maskrcnn_benchmark.structures.bounding_box import BoxList, _onnx_clip_boxes_to_image from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms from maskrc...
null
10,020
import logging import torch from maskrcnn_benchmark.modeling.box_coder import BoxCoder from maskrcnn_benchmark.structures.bounding_box import BoxList, _onnx_clip_boxes_to_image from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms from maskrc...
null
10,021
import math import numpy as np import torch from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.image_list import ImageList from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist class AnchorGenerator(nn.Module): """ For a set of imag...
null
10,022
import math import numpy as np import torch from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.image_list import ImageList from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist class AnchorGenerator(nn.Module): """ For a set of imag...
null
10,023
import math import numpy as np import torch from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.image_list import ImageList from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist class CenterAnchorGenerator(nn.Module): """ For a set o...
null
10,024
import math import numpy as np import torch from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.image_list import ImageList from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist def _generate_anchors(base_size, scales, aspect_ratios): ""...
Generates a matrix of anchor boxes in (x1, y1, x2, y2) format. Anchors are centered on stride / 2, have (approximate) sqrt areas of the specified sizes, and aspect ratios as given.
10,025
import torch from torch import nn from torch.nn import functional as F from ..balanced_positive_negative_sampler import BalancedPositiveNegativeSampler from ..utils import cat, concat_box_prediction_layers from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.matcher import Matcher from ...
null
10,026
import torch from torch import nn from torch.nn import functional as F from ..balanced_positive_negative_sampler import BalancedPositiveNegativeSampler from ..utils import cat, concat_box_prediction_layers from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.matcher import Matcher from ...
null
10,027
import torch from torch import nn from torch.nn import functional as F from ..balanced_positive_negative_sampler import BalancedPositiveNegativeSampler from ..utils import cat, concat_box_prediction_layers from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.matcher import Matcher from ...
null
10,028
import torch from torch import nn from torch.nn import functional as F from ..balanced_positive_negative_sampler import BalancedPositiveNegativeSampler from ..utils import cat, concat_box_prediction_layers from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.matcher import Matcher from ...
null
10,029
import math import os import warnings from dataclasses import dataclass from typing import Optional, Tuple import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from transformers.activations import ACT2FN import pdb from transformers.modeling_u...
null
10,030
import torch from torch import nn from torch.nn import functional as F from maskrcnn_benchmark.modeling import registry from maskrcnn_benchmark.modeling.backbone import resnet from maskrcnn_benchmark.modeling.poolers import Pooler from maskrcnn_benchmark.modeling.make_layers import group_norm from maskrcnn_benchmark.mo...
null
10,031
import torch import torch.nn.functional as F from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist from maskrcnn_benchmark.modeling.box_coder import BoxCoder ...
null
10,032
import torch from torch.nn import functional as F from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.box_coder import BoxCoder from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.modeling.bal...
null
10,033
from torch import nn _ROI_BOX_PREDICTOR = { "FastRCNNPredictor": FastRCNNPredictor, "FPNPredictor": FPNPredictor, } def make_roi_box_predictor(cfg): func = _ROI_BOX_PREDICTOR[cfg.MODEL.ROI_BOX_HEAD.PREDICTOR] return func(cfg)
null
10,034
import torch from torch import nn from .roi_box_feature_extractors import make_roi_box_feature_extractor from .roi_box_predictors import make_roi_box_predictor from .inference import make_roi_box_post_processor from .loss import make_roi_box_loss_evaluator from maskrcnn_benchmark.utils.amp import custom_fwd, custom_bwd...
Constructs a new box head. By default, uses ROIBoxHead, but if it turns out not to be enough, just register a new class and make it a parameter in the config
10,035
import numpy as np import torch from torch import nn import torch.nn.functional as F from maskrcnn_benchmark.structures.bounding_box import BoxList def convert_mask_grounding_to_od_logits(logits, positive_map_label_to_token, num_classes): od_logits = torch.zeros(logits.shape[0], num_classes + 1, logits.shape[2], l...
null
10,036
import numpy as np import torch from torch import nn import torch.nn.functional as F from maskrcnn_benchmark.structures.bounding_box import BoxList def expand_boxes(boxes, scale): w_half = (boxes[:, 2] - boxes[:, 0]) * .5 h_half = (boxes[:, 3] - boxes[:, 1]) * .5 x_c = (boxes[:, 2] + boxes[:, 0]) * .5 y...
null
10,037
import numpy as np import torch from torch import nn import torch.nn.functional as F from maskrcnn_benchmark.structures.bounding_box import BoxList class MaskPostProcessor(nn.Module): """ From the results of the CNN, post process the masks by taking the mask corresponding to the class with max probabili...
null
10,038
import torch from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from .roi_mask_feature_extractors import make_roi_mask_feature_extractor from .roi_mask_predictors import make_roi_mask_predictor from .inference import make_roi_mask_post_processor from .loss import make_roi_mask_loss_eval...
Given a set of BoxList containing the `labels` field, return a set of BoxList for which `labels > 0`. Arguments: boxes (list of BoxList)
10,039
import torch from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from .roi_mask_feature_extractors import make_roi_mask_feature_extractor from .roi_mask_predictors import make_roi_mask_predictor from .inference import make_roi_mask_post_processor from .loss import make_roi_mask_loss_eval...
null
10,040
import torch from torch.nn import functional as F from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.modeling.utils import cat The provided code snippet includes necessary...
Given segmentation masks and the bounding boxes corresponding to the location of the masks in the image, this function crops and resizes the masks in the position defined by the boxes. This prepares the masks for them to be fed to the loss computation as the targets. Arguments: segmentation_masks: an instance of Segmen...
10,041
import torch from torch.nn import functional as F from maskrcnn_benchmark.layers import smooth_l1_loss from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.modeling.utils import cat class MaskRCNNLossComputation(object): de...
null
10,042
import torch from torch import nn from torch.nn import functional as F from maskrcnn_benchmark.layers import Conv2d, _NewEmptyTensorOp from maskrcnn_benchmark.layers import ConvTranspose2d from ...utils import permute_and_flatten _ROI_MASK_PREDICTOR = {"MaskRCNNC4Predictor": MaskRCNNC4Predictor, ...
null
10,043
from torch import nn from torch.nn import functional as F from .hourglass import Hourglass from ..box_head.roi_box_feature_extractors import ResNet50Conv5ROIFeatureExtractor from maskrcnn_benchmark.modeling.poolers import Pooler from maskrcnn_benchmark.layers import Conv2d from maskrcnn_benchmark.modeling.make_layers i...
null
10,044
import torch from .roi_keypoint_feature_extractors import make_roi_keypoint_feature_extractor from .roi_keypoint_predictors import make_roi_keypoint_predictor from .inference import make_roi_keypoint_post_processor from .loss import make_roi_keypoint_loss_evaluator class ROIKeypointHead(torch.nn.Module): def __init...
null
10,045
import cv2 import numpy as np import torch from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.keypoint import PersonKeypoints The provided code snippet includes necessary dependencies for implementing the `heatmaps_to_keypoints` function. Write a Pyth...
Extract predicted keypoint locations from heatmaps. Output has shape (#rois, 4, #keypoints) with the 4 rows corresponding to (x, y, logit, prob) for each keypoint.
10,046
import cv2 import numpy as np import torch from torch import nn from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.keypoint import PersonKeypoints class KeypointPostProcessor(nn.Module): def __init__(self, keypointer=None): super(KeypointPostProcessor, self).__...
null
10,047
from torch import nn from torch.nn import functional as F from maskrcnn_benchmark.modeling.poolers import Pooler from maskrcnn_benchmark.layers import Conv2d from maskrcnn_benchmark.layers import ConvTranspose2d _ROI_KEYPOINT_FEATURE_EXTRACTORS = { "KeypointRCNNFeatureExtractor": KeypointRCNNFeatureExtractor, "...
null
10,048
from torch import nn from torch.nn import functional as F from maskrcnn_benchmark import layers _ROI_KEYPOINT_PREDICTOR = {"KeypointRCNNPredictor": KeypointRCNNPredictor} def make_roi_keypoint_predictor(cfg): func = _ROI_KEYPOINT_PREDICTOR[cfg.MODEL.ROI_KEYPOINT_HEAD.PREDICTOR] return func(cfg)
null
10,049
import torch from torch.nn import functional as F from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.modeling.balanced_positive_negative_sampler import ( BalancedPositiveNegativeSampler, ) from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.modeling...
null
10,050
import torch from torch.nn import functional as F from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.modeling.balanced_positive_negative_sampler import ( BalancedPositiveNegativeSampler, ) from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.modeling...
null
10,051
import torch from torch.nn import functional as F from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.modeling.balanced_positive_negative_sampler import ( BalancedPositiveNegativeSampler, ) from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.modeling...
Validate which keypoints are contained inside a given box. points: NxKx2 boxes: Nx4 output: NxK
10,052
import torch from torch.nn import functional as F from maskrcnn_benchmark.modeling.matcher import Matcher from maskrcnn_benchmark.modeling.balanced_positive_negative_sampler import ( BalancedPositiveNegativeSampler, ) from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.modeling...
null