id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
⌀
34,393
from typing import List import torch from torch import nn as nn from annotator.mmpkg.mmcv.runner import force_fp32 from .furthest_point_sample import (furthest_point_sample, furthest_point_sample_with_dist) The provided code snippet includes necessary dependencies for implementing t...
Calculating square distance between a and b. Args: point_feat_a (Tensor): (B, N, C) Feature vector of each point. point_feat_b (Tensor): (B, M, C) Feature vector of each point. norm (Bool, optional): Whether to normalize the distance. Default: True. Returns: Tensor: (B, N, M) Distance between each pair points.
34,394
from typing import List import torch from torch import nn as nn from annotator.mmpkg.mmcv.runner import force_fp32 from .furthest_point_sample import (furthest_point_sample, furthest_point_sample_with_dist) class DFPSSampler(nn.Module): """Using Euclidean distances of points for ...
Get the type and mode of points sampler. Args: sampler_type (str): The type of points sampler. The valid value are "D-FPS", "F-FPS", or "FS". Returns: class: Points sampler type.
34,396
import torch from torch.autograd import Function from torch.nn import functional as F from annotator.mmpkg.mmcv.utils import to_2tuple from ..utils import ext_loader class UpFirDn2d(Function): def forward(ctx, input, kernel, up, down, pad): up_x, up_y = up down_x, down_y = down pad_x0, pad_x...
UpFRIDn for 2d features. UpFIRDn is short for upsample, apply FIR filter and downsample. More details can be found in: https://www.mathworks.com/help/signal/ref/upfirdn.html Args: input (Tensor): Tensor with shape of (n, c, h, w). kernel (Tensor): Filter kernel. up (int | tuple[int], optional): Upsampling factor. If gi...
34,397
import os import numpy as np import torch from annotator.mmpkg.mmcv.utils import deprecated_api_warning from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['nms', 'softnms', 'nms_match', 'nms_rotated']) class NMSop(torch.autograd.Function): def forward(ctx, bboxes, scores, iou_threshold, o...
Dispatch to either CPU or GPU NMS implementations. The input can be either torch tensor or numpy array. GPU NMS will be used if the input is gpu tensor, otherwise CPU NMS will be used. The returned type will always be the same as inputs. Arguments: boxes (torch.Tensor or np.ndarray): boxes in shape (N, 4). scores (torc...
34,398
import os import numpy as np import torch from annotator.mmpkg.mmcv.utils import deprecated_api_warning from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['nms', 'softnms', 'nms_match', 'nms_rotated']) class SoftNMSop(torch.autograd.Function): def forward(ctx, boxes, scores, iou_threshold...
Dispatch to only CPU Soft NMS implementations. The input can be either a torch tensor or numpy array. The returned type will always be the same as inputs. Arguments: boxes (torch.Tensor or np.ndarray): boxes in shape (N, 4). scores (torch.Tensor or np.ndarray): scores in shape (N, ). iou_threshold (float): IoU threshol...
34,399
import os import numpy as np import torch from annotator.mmpkg.mmcv.utils import deprecated_api_warning from ..utils import ext_loader The provided code snippet includes necessary dependencies for implementing the `batched_nms` function. Write a Python function `def batched_nms(boxes, scores, idxs, nms_cfg, class_agno...
Performs non-maximum suppression in a batched fashion. Modified from https://github.com/pytorch/vision/blob /505cd6957711af790211896d32b40291bea1bc21/torchvision/ops/boxes.py#L39. In order to perform NMS independently per class, we add an offset to all the boxes. The offset is dependent only on the class idx, and is la...
34,400
import os import numpy as np import torch from annotator.mmpkg.mmcv.utils import deprecated_api_warning from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['nms', 'softnms', 'nms_match', 'nms_rotated']) The provided code snippet includes necessary dependencies for implementing the `nms_match`...
Matched dets into different groups by NMS. NMS match is Similar to NMS but when a bbox is suppressed, nms match will record the indice of suppressed bbox and form a group with the indice of kept bbox. In each group, indice is sorted as score order. Arguments: dets (torch.Tensor | np.ndarray): Det boxes with scores, sha...
34,401
import os import numpy as np import torch from annotator.mmpkg.mmcv.utils import deprecated_api_warning from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['nms', 'softnms', 'nms_match', 'nms_rotated']) The provided code snippet includes necessary dependencies for implementing the `nms_rotate...
Performs non-maximum suppression (NMS) on the rotated boxes according to their intersection-over-union (IoU). Rotated NMS iteratively removes lower scoring rotated boxes which have an IoU greater than iou_threshold with another (higher scoring) rotated box. Args: boxes (Tensor): Rotated boxes in shape (N, 5). They are ...
34,406
import math import warnings import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd.function import Function, once_differentiable from annotator.mmpkg.mmcv import deprecated_api_warning from annotator.mmpkg.mmcv.cnn import constant_init, xavier_init from annotator.mmpkg.mmcv.cnn.bricks.re...
CPU version of multi-scale deformable attention. Args: value (Tensor): The value has shape (bs, num_keys, mum_heads, embed_dims//num_heads) value_spatial_shapes (Tensor): Spatial shape of each feature map, has shape (num_levels, 2), last dimension 2 represent (h, w) sampling_locations (Tensor): The location of sampling...
34,409
from os import path as osp import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.utils import _pair from torch.onnx.operators import shape_as_tensor def bilinear_grid_sample(im, grid, align_corners=False): """Given an input and a flow-field grid, computes the output using input ...
A wrapper around :func:`grid_sample` to support 3D point_coords tensors Unlike :func:`torch.nn.functional.grid_sample` it assumes point_coords to lie inside ``[0, 1] x [0, 1]`` square. Args: input (Tensor): Feature map, shape (N, C, H, W). points (Tensor): Image based absolute point coordinates (normalized), range [0, ...
34,416
import os import os.path as osp import subprocess import tempfile from annotator.mmpkg.mmcv.utils import requires_executable def convert_video(in_file, out_file, print_cmd=False, pre_options='', **kwargs): """Convert a video with ffmpeg. Th...
Resize a video. Args: in_file (str): Input video filename. out_file (str): Output video filename. size (tuple): Expected size (w, h), eg, (320, 240) or (320, -1). ratio (tuple or float): Expected resize ratio, (2, 0.5) means (w*2, h*0.5). keep_ar (bool): Whether to keep original aspect ratio. log_level (str): Logging l...
34,417
import os import os.path as osp import subprocess import tempfile from annotator.mmpkg.mmcv.utils import requires_executable def convert_video(in_file, out_file, print_cmd=False, pre_options='', **kwargs): """Convert a video with ffmpeg. Th...
Cut a clip from a video. Args: in_file (str): Input video filename. out_file (str): Output video filename. start (None or float): Start time (in seconds). end (None or float): End time (in seconds). vcodec (None or str): Output video codec, None for unchanged. acodec (None or str): Output audio codec, None for unchange...
34,418
import os import os.path as osp import subprocess import tempfile from annotator.mmpkg.mmcv.utils import requires_executable def convert_video(in_file, out_file, print_cmd=False, pre_options='', **kwargs): """Convert a video with ffmpeg. Th...
Concatenate multiple videos into a single one. Args: video_list (list): A list of video filenames out_file (str): Output video filename vcodec (None or str): Output video codec, None for unchanged acodec (None or str): Output audio codec, None for unchanged log_level (str): Logging level of ffmpeg. print_cmd (bool): Wh...
34,419
import os.path as osp from collections import OrderedDict import cv2 from cv2 import (CAP_PROP_FOURCC, CAP_PROP_FPS, CAP_PROP_FRAME_COUNT, CAP_PROP_FRAME_HEIGHT, CAP_PROP_FRAME_WIDTH, CAP_PROP_POS_FRAMES, VideoWriter_fourcc) from annotator.mmpkg.mmcv.utils import (check_file_exist, mkd...
Read the frame images from a directory and join them as a video. Args: frame_dir (str): The directory containing video frames. video_file (str): Output filename. fps (float): FPS of the output video. fourcc (str): Fourcc of the output video, this should be compatible with the output file type. filename_tmpl (str): File...
34,420
import warnings import cv2 import numpy as np from annotator.mmpkg.mmcv.arraymisc import dequantize, quantize from annotator.mmpkg.mmcv.image import imread, imwrite from annotator.mmpkg.mmcv.utils import is_str def dequantize_flow(dx, dy, max_val=0.02, denorm=True): """Recover from quantized flow. Args: ...
Read an optical flow map. Args: flow_or_path (ndarray or str): A flow map or filepath. quantize (bool): whether to read quantized pair, if set to True, remaining args will be passed to :func:`dequantize_flow`. concat_axis (int): The axis that dx and dy are concatenated, can be either 0 or 1. Ignored if quantize is Fals...
34,421
import warnings import cv2 import numpy as np from annotator.mmpkg.mmcv.arraymisc import dequantize, quantize from annotator.mmpkg.mmcv.image import imread, imwrite from annotator.mmpkg.mmcv.utils import is_str def quantize_flow(flow, max_val=0.02, norm=True): """Quantize flow to [0, 255]. After this step, the ...
Write optical flow to file. If the flow is not quantized, it will be saved as a .flo file losslessly, otherwise a jpeg image which is lossy but of much smaller size. (dx and dy will be concatenated horizontally into a single image if quantize is True.) Args: flow (ndarray): (h, w, 2) array of optical flow. filename (st...
34,422
import warnings import cv2 import numpy as np from annotator.mmpkg.mmcv.arraymisc import dequantize, quantize from annotator.mmpkg.mmcv.image import imread, imwrite from annotator.mmpkg.mmcv.utils import is_str The provided code snippet includes necessary dependencies for implementing the `flow_warp` function. Write a...
Use flow to warp img. Args: img (ndarray, float or uint8): Image to be warped. flow (ndarray, float): Optical Flow. filling_value (int): The missing pixels will be set with filling_value. interpolate_mode (str): bilinear -> Bilinear Interpolation; nearest -> Nearest Neighbor. Returns: ndarray: Warped image with the sam...
34,423
import warnings import cv2 import numpy as np from annotator.mmpkg.mmcv.arraymisc import dequantize, quantize from annotator.mmpkg.mmcv.image import imread, imwrite from annotator.mmpkg.mmcv.utils import is_str The provided code snippet includes necessary dependencies for implementing the `flow_from_bytes` function. W...
Read dense optical flow from bytes. .. note:: This load optical flow function works for FlyingChairs, FlyingThings3D, Sintel, FlyingChairsOcc datasets, but cannot load the data from ChairsSDHom. Args: content (bytes): Optical flow bytes got from files or other streams. Returns: ndarray: Loaded optical flow with the sha...
34,424
import warnings import cv2 import numpy as np from annotator.mmpkg.mmcv.arraymisc import dequantize, quantize from annotator.mmpkg.mmcv.image import imread, imwrite from annotator.mmpkg.mmcv.utils import is_str The provided code snippet includes necessary dependencies for implementing the `sparse_flow_from_bytes` func...
Read the optical flow in KITTI datasets from bytes. This function is modified from RAFT load the `KITTI datasets <https://github.com/princeton-vl/RAFT/blob/224320502d66c356d88e6c712f38129e60661e80/core/utils/frame_utils.py#L102>`_. Args: content (bytes): Optical flow bytes got from files or other streams. Returns: Tupl...
34,425
import functools import warnings from collections import abc from inspect import getfullargspec import numpy as np import torch import torch.nn as nn from annotator.mmpkg.mmcv.utils import TORCH_VERSION, digit_version from .dist_utils import allreduce_grads as _allreduce_grads try: # If PyTorch version >= 1.6.0, to...
Decorator to enable fp16 training automatically. This decorator is useful when you write custom modules and want to support mixed precision training. If inputs arguments are fp32 tensors, they will be converted to fp16 automatically. Arguments other than fp32 tensors are ignored. If you are using PyTorch >= 1.6, torch....
34,426
import functools import warnings from collections import abc from inspect import getfullargspec import numpy as np import torch import torch.nn as nn from annotator.mmpkg.mmcv.utils import TORCH_VERSION, digit_version from .dist_utils import allreduce_grads as _allreduce_grads try: # If PyTorch version >= 1.6.0, to...
Decorator to convert input arguments to fp32 in force. This decorator is useful when you write custom modules and want to support mixed precision training. If there are some inputs that must be processed in fp32 mode, then this decorator can handle it. If inputs arguments are fp16 tensors, they will be converted to fp3...
34,427
import functools import warnings from collections import abc from inspect import getfullargspec import numpy as np import torch import torch.nn as nn from annotator.mmpkg.mmcv.utils import TORCH_VERSION, digit_version from .dist_utils import allreduce_grads as _allreduce_grads def allreduce_grads(params, coalesce=True...
null
34,428
import functools import warnings from collections import abc from inspect import getfullargspec import numpy as np import torch import torch.nn as nn from annotator.mmpkg.mmcv.utils import TORCH_VERSION, digit_version from .dist_utils import allreduce_grads as _allreduce_grads def patch_norm_fp32(module): """Recurs...
Wrap the FP32 model to FP16. If you are using PyTorch >= 1.6, torch.cuda.amp is used as the backend, otherwise, original mmcv implementation will be adopted. For PyTorch >= 1.6, this function will 1. Set fp16 flag inside the model to True. Otherwise: 1. Convert FP32 model to FP16. 2. Remain some necessary layers to be ...
34,430
import os import random import sys import time import warnings from getpass import getuser from socket import gethostname import numpy as np import torch import annotator.mmpkg.mmcv as mmcv The provided code snippet includes necessary dependencies for implementing the `get_host_info` function. Write a Python function ...
Get hostname and username. Return empty string if exception raised, e.g. ``getpass.getuser()`` will lead to error in docker container
34,431
import os import random import sys import time import warnings from getpass import getuser from socket import gethostname import numpy as np import torch import annotator.mmpkg.mmcv as mmcv def get_time_str(): return time.strftime('%Y%m%d_%H%M%S', time.localtime())
null
34,432
import os import random import sys import time import warnings from getpass import getuser from socket import gethostname import numpy as np import torch import annotator.mmpkg.mmcv as mmcv The provided code snippet includes necessary dependencies for implementing the `obj_from_dict` function. Write a Python function ...
Initialize an object from dict. The dict must contain the key "type", which indicates the object type, it can be either a string or type, such as "list" or ``list``. Remaining fields are treated as the arguments for constructing the object. Args: info (dict): Object types and arguments. parent (:class:`module`): Module...
34,433
import os import random import sys import time import warnings from getpass import getuser from socket import gethostname import numpy as np import torch import annotator.mmpkg.mmcv as mmcv The provided code snippet includes necessary dependencies for implementing the `set_random_seed` function. Write a Python functio...
Set random seed. Args: seed (int): Seed to be used. deterministic (bool): Whether to set the deterministic option for CUDNN backend, i.e., set `torch.backends.cudnn.deterministic` to True and `torch.backends.cudnn.benchmark` to False. Default: False. rank_shift (bool): Whether to add rank number to the random seed to h...
34,434
import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from torch.utils import model_zoo import annota...
load checkpoint by local file path. Args: filename (str): local checkpoint file path map_location (str, optional): Same as :func:`torch.load`. Returns: dict or OrderedDict: The loaded checkpoint.
34,435
import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from torch.utils import model_zoo import annota...
load checkpoint through the file path prefixed with pavi. In distributed setting, this function download ckpt at all ranks to different temporary directories. Args: filename (str): checkpoint file path with pavi prefix map_location (str, optional): Same as :func:`torch.load`. Default: None Returns: dict or OrderedDict:...
34,436
import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from torch.utils import model_zoo import annota...
load checkpoint through the file path prefixed with s3. In distributed setting, this function download ckpt at all ranks to different temporary directories. Args: filename (str): checkpoint file path with s3 prefix map_location (str, optional): Same as :func:`torch.load`. backend (str, optional): The storage backend ty...
34,437
import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from torch.utils import model_zoo import annota...
load checkpoint through the file path prefixed with modelzoo or torchvision. Args: filename (str): checkpoint file path with modelzoo or torchvision prefix map_location (str, optional): Same as :func:`torch.load`. Returns: dict or OrderedDict: The loaded checkpoint.
34,438
import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from torch.utils import model_zoo import annota...
load checkpoint through the file path prefixed with open-mmlab or openmmlab. Args: filename (str): checkpoint file path with open-mmlab or openmmlab prefix map_location (str, optional): Same as :func:`torch.load`. Default: None Returns: dict or OrderedDict: The loaded checkpoint.
34,439
import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from torch.utils import model_zoo import annota...
load checkpoint through the file path prefixed with mmcls. Args: filename (str): checkpoint file path with mmcls prefix map_location (str, optional): Same as :func:`torch.load`. Returns: dict or OrderedDict: The loaded checkpoint.
34,440
import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from torch.utils import model_zoo import annota...
Load partial pretrained model with specific prefix. Args: prefix (str): The prefix of sub-module. filename (str): Accept local filepath, URL, ``torchvision://xxx``, ``open-mmlab://xxx``. Please refer to ``docs/model_zoo.md`` for details. map_location (str | None): Same as :func:`torch.load`. Default: None. Returns: dic...
34,441
import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimizer from torch.utils import model_zoo import annota...
Save checkpoint to file. The checkpoint will have 3 fields: ``meta``, ``state_dict`` and ``optimizer``. By default ``meta`` will contain version and time info. Args: model (Module): Module whose params are to be saved. filename (str): Checkpoint filename. optimizer (:obj:`Optimizer`, optional): Optimizer to be saved. m...
34,443
import copy import inspect import torch from ...utils import Registry, build_from_cfg def build_optimizer_constructor(cfg): def build_optimizer(model, cfg): optimizer_cfg = copy.deepcopy(cfg) constructor_type = optimizer_cfg.pop('constructor', 'DefaultOptimizerConstruct...
null
34,444
import numbers from math import cos, pi import annotator.mmpkg.mmcv as mmcv from .hook import HOOKS, Hook The provided code snippet includes necessary dependencies for implementing the `get_position_from_periods` function. Write a Python function `def get_position_from_periods(iteration, cumulative_periods)` to solve ...
Get the position from a period list. It will return the index of the right-closest number in the period list. For example, the cumulative_periods = [100, 200, 300, 400], if iteration == 50, return 0; if iteration == 210, return 2; if iteration == 300, return 3. Args: iteration (int): Current iteration. cumulative_perio...
34,445
import numbers from math import cos, pi import annotator.mmpkg.mmcv as mmcv from .hook import HOOKS, Hook The provided code snippet includes necessary dependencies for implementing the `annealing_cos` function. Write a Python function `def annealing_cos(start, end, factor, weight=1)` to solve the following problem: Ca...
Calculate annealing cos learning rate. Cosine anneal from `weight * start + (1 - weight) * end` to `end` as percentage goes from 0.0 to 1.0. Args: start (float): The starting learning rate of the cosine annealing. end (float): The ending learing rate of the cosine annealing. factor (float): The coefficient of `pi` when...
34,446
import numbers from math import cos, pi import annotator.mmpkg.mmcv as mmcv from .hook import HOOKS, Hook The provided code snippet includes necessary dependencies for implementing the `annealing_linear` function. Write a Python function `def annealing_linear(start, end, factor)` to solve the following problem: Calcul...
Calculate annealing linear learning rate. Linear anneal from `start` to `end` as percentage goes from 0.0 to 1.0. Args: start (float): The starting learning rate of the linear annealing. end (float): The ending learing rate of the linear annealing. factor (float): The coefficient of `pi` when calculating the current pe...
34,447
import numbers from math import cos, pi import annotator.mmpkg.mmcv as mmcv from .hook import HOOKS, Hook def format_param(name, optim, param): if isinstance(param, numbers.Number): return [param] * len(optim.param_groups) elif isinstance(param, (list, tuple)): # multi param groups if len(para...
null
34,452
import copy from ..utils import Registry def build_runner_constructor(cfg): return RUNNER_BUILDERS.build(cfg) def build_runner(cfg, default_args=None): runner_cfg = copy.deepcopy(cfg) constructor_type = runner_cfg.pop('constructor', 'DefaultRunnerConstructor') runn...
null
34,454
import importlib import os import pkgutil import warnings from collections import namedtuple import torch if torch.__version__ != 'parrots': else: from parrots import extension from parrots.base import ParrotsException has_return_value_ops = [ 'nms', 'softnms', 'nms_match', '...
null
34,460
import os import os.path as osp from pathlib import Path from .misc import is_str def is_str(x): def is_filepath(x): return is_str(x) or isinstance(x, Path)
null
34,463
import os import os.path as osp from pathlib import Path from .misc import is_str import os os.environ['IGNORE_CMD_ARGS_ERRORS'] = 'True' def mkdir_or_exist(dir_name, mode=0o777): if dir_name == '': return dir_name = osp.expanduser(dir_name) os.makedirs(dir_name, mode=mode, exist_ok=True)
null
34,464
import os import os.path as osp from pathlib import Path from .misc import is_str import os os.environ['IGNORE_CMD_ARGS_ERRORS'] = 'True' def symlink(src, dst, overwrite=True, **kwargs): if os.path.lexists(dst) and overwrite: os.remove(dst) os.symlink(src, dst, **kwargs)
null
34,465
import os import os.path as osp from pathlib import Path from .misc import is_str import os os.environ['IGNORE_CMD_ARGS_ERRORS'] = 'True' The provided code snippet includes necessary dependencies for implementing the `scandir` function. Write a Python function `def scandir(dir_path, suffix=None, recursive=False, ...
Scan a directory to find the interested files. Args: dir_path (str | obj:`Path`): Path of the directory. suffix (str | tuple(str), optional): File suffix that we are interested in. Default: None. recursive (bool, optional): If set to True, recursively scan the directory. Default: False. case_sensitive (bool, optional) ...
34,467
import warnings import torch from annotator.mmpkg.mmcv.utils import digit_version try: import torch except ImportError: __all__ = [ 'Config', 'ConfigDict', 'DictAction', 'is_str', 'iter_cast', 'list_cast', 'tuple_cast', 'is_seq_of', 'is_list_of', 'is_tuple_of', 'slice_list', 'concat_lis...
null
34,469
import os.path as osp import subprocess import sys from collections import defaultdict import cv2 import torch import annotator.mmpkg.mmcv as mmcv from .parrots_wrapper import get_build_config try: import torch except ImportError: __all__ = [ 'Config', 'ConfigDict', 'DictAction', 'is_str', 'iter_cast',...
Collect the information of the running environments. Returns: dict: The environment information. The following fields are contained. - sys.platform: The variable of ``sys.platform``. - Python: Python version. - CUDA available: Bool, indicating if CUDA is available. - GPU devices: Device type of each GPU. - CUDA_HOME (o...
34,483
from time import time class Timer: """A flexible Timer class. :Example: >>> import time >>> import annotator.mmpkg.mmcv as mmcv >>> with mmcv.Timer(): >>> # simulate a code block that will run for 1s >>> time.sleep(1) 1.000 >>> with mmcv.Timer(print_tmpl='it takes {:.1f} seco...
Add check points in a single line. This method is suitable for running a task on a list of items. A timer will be registered when the method is called for the first time. :Example: >>> import time >>> import annotator.mmpkg.mmcv as mmcv >>> for i in range(1, 6): >>> # simulate a code block >>> time.sleep(i) >>> mmcv.ch...
34,494
import torch import torch.nn as nn import torch.nn.functional as F def norm_normalize(norm_out): min_kappa = 0.01 norm_x, norm_y, norm_z, kappa = torch.split(norm_out, 1, dim=1) norm = torch.sqrt(norm_x ** 2.0 + norm_y ** 2.0 + norm_z ** 2.0) + 1e-10 kappa = F.elu(kappa) + 1.0 + min_kappa final_out...
null
34,495
import torch import torch.nn as nn import torch.nn.functional as F def sample_points(init_normal, gt_norm_mask, sampling_ratio, beta): device = init_normal.device B, _, H, W = init_normal.shape N = int(sampling_ratio * H * W) beta = beta # uncertainty map uncertainty_map = -1 * init_normal[:, ...
null
34,496
import argparse import numpy as np from caffe2.python import core, workspace, model_helper from caffe2.proto import caffe2_pb2 from data import create_loader, resolve_data_config, Dataset from utils import AverageMeter import time def accuracy_np(output, target): max_indices = np.argsort(output, axis=1)[:, ::-1] ...
null
34,497
import os The provided code snippet includes necessary dependencies for implementing the `accuracy` function. Write a Python function `def accuracy(output, target, topk=(1,))` to solve the following problem: Computes the precision@k for the specified values of k Here is the function: def accuracy(output, target, top...
Computes the precision@k for the specified values of k
34,498
import os def get_outdir(path, *paths, inc=False): outdir = os.path.join(path, *paths) if not os.path.exists(outdir): os.makedirs(outdir) elif inc: count = 1 outdir_inc = outdir + '-' + str(count) while os.path.exists(outdir_inc): count = count + 1 ou...
null
34,499
import argparse import numpy as np import onnxruntime from data import create_loader, resolve_data_config, Dataset from utils import AverageMeter import time def accuracy_np(output, target): max_indices = np.argsort(output, axis=1)[:, ::-1] top5 = 100 * np.equal(max_indices[:, :5], target[:, np.newaxis]).sum(a...
null
34,500
import argparse import warnings import onnx from onnx import optimizer def traverse_graph(graph, prefix=''): content = [] indent = prefix + ' ' graphs = [] num_nodes = 0 for node in graph.node: pn, gs = onnx.helper.printable_node(node, indent, subgraphs=True) assert isinstance(gs, ...
null
34,501
from .config import set_layer_config from .helpers import load_checkpoint from .gen_efficientnet import * from .mobilenetv3 import * def load_checkpoint(model, checkpoint_path): if checkpoint_path and os.path.isfile(checkpoint_path): print("=> Loading checkpoint '{}'".format(checkpoint_path)) check...
null
34,502
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mnasnet_b1(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates ...
MNASNet B1, depth multiplier of 0.5.
34,503
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mnasnet_b1(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates ...
MNASNet B1, depth multiplier of 0.75.
34,504
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def mnasnet_100(pretrained=False, **kwargs): """ MNASNet B1, depth multiplier of 1.0. """ ...
MNASNet B1, depth multiplier of 1.0.
34,505
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mnasnet_b1(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates ...
MNASNet B1, depth multiplier of 1.4
34,506
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mnasnet_a1(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates ...
MNASNet A1 (w/ SE), depth multiplier of 0.5
34,507
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mnasnet_a1(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates ...
MNASNet A1 (w/ SE), depth multiplier of 0.75.
34,508
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def semnasnet_100(pretrained=False, **kwargs): """ MNASNet A1 (w/ SE), depth multiplier of 1....
MNASNet A1 (w/ SE), depth multiplier of 1.0.
34,509
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mnasnet_a1(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates ...
MNASNet A1 (w/ SE), depth multiplier of 1.4.
34,510
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mnasnet_small(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creat...
MNASNet Small, depth multiplier of 1.0.
34,511
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mobilenet_v2( variant, channel_multiplier=1.0, depth_multiplier=1.0, fix_stem_he...
MobileNet V2 w/ 1.0 channel multiplier
34,512
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mobilenet_v2( variant, channel_multiplier=1.0, depth_multiplier=1.0, fix_stem_he...
MobileNet V2 w/ 1.4 channel multiplier
34,513
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mobilenet_v2( variant, channel_multiplier=1.0, depth_multiplier=1.0, fix_stem_he...
MobileNet V2 w/ 1.1 channel, 1.2 depth multipliers
34,514
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_mobilenet_v2( variant, channel_multiplier=1.0, depth_multiplier=1.0, fix_stem_he...
MobileNet V2 w/ 1.2 channel, 1.4 depth multipliers
34,515
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_fbnetc(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """ FBNet-C ...
FBNet-C
34,516
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_spnasnet(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates th...
Single-Path NAS Pixel1
34,517
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B0
34,518
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B1
34,519
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B2
34,520
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B3
34,521
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B4
34,522
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B5
34,523
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B6
34,524
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B7
34,525
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B8
34,526
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-L2.
34,527
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_edge(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=Fals...
EfficientNet-Edge Small.
34,528
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_edge(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=Fals...
EfficientNet-Edge-Medium.
34,529
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_edge(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=Fals...
EfficientNet-Edge-Large.
34,530
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_condconv( variant, channel_multiplier=1.0, depth_multiplier=1.0, ex...
EfficientNet-CondConv-B0 w/ 8 Experts
34,531
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_condconv( variant, channel_multiplier=1.0, depth_multiplier=1.0, ex...
EfficientNet-CondConv-B0 w/ 8 Experts
34,532
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_condconv( variant, channel_multiplier=1.0, depth_multiplier=1.0, ex...
EfficientNet-CondConv-B1 w/ 8 Experts
34,533
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_lite(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=Fals...
EfficientNet-Lite0
34,534
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_lite(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=Fals...
EfficientNet-Lite1
34,535
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_lite(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=Fals...
EfficientNet-Lite2
34,536
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_lite(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=Fals...
EfficientNet-Lite3
34,537
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet_lite(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=Fals...
EfficientNet-Lite4
34,538
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B0 AutoAug. Tensorflow compatible variant
34,539
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B1 AutoAug. Tensorflow compatible variant
34,540
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B2 AutoAug. Tensorflow compatible variant
34,541
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B3 AutoAug. Tensorflow compatible variant
34,542
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B4 AutoAug. Tensorflow compatible variant
34,543
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B5 RandAug. Tensorflow compatible variant
34,544
import torch.nn as nn import torch.nn.functional as F from .config import layer_config_kwargs, is_scriptable from .conv2d_layers import select_conv2d from .helpers import load_pretrained from .efficientnet_builder import * def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **...
EfficientNet-B6 AutoAug. Tensorflow compatible variant