id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
141,526 | import copy
import torch
import torch.nn.functional as F
from torch import nn
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 problem:
Return an activation function given a ... | Return an activation function given a string |
141,527 | import torch
import torch.nn as nn
from ltr.models.transformer.position_encoding import PositionEmbeddingSine
def MLP(channels, do_bn=True):
n = len(channels)
layers = []
for i in range(1, n):
layers.append(
nn.Conv1d(channels[i - 1], channels[i], kernel_size=1, bias=True))
if i... | null |
141,528 | import torch
import torch.nn as nn
import torchvision.ops as ops
from collections import OrderedDict
import ltr.models.layers.filter as filter_layer
def conv_layer(inplanes, outplanes, kernel_size=3, stride=1, padding=1, dilation=1):
layers = [
nn.Conv2d(inplanes, outplanes, kernel_size=kernel_size, stride... | null |
141,529 | import os
import sys
import argparse
from pytracking.evaluation import Tracker
The provided code snippet includes necessary dependencies for implementing the `run_webcam` function. Write a Python function `def run_webcam(tracker_name, tracker_param, debug=None, visdom_info=None)` to solve the following problem:
Run th... | Run the tracker on your webcam. args: tracker_name: Name of tracking method. tracker_param: Name of parameter file. debug: Debug level. visdom_info: Dict optionally containing 'use_visdom', 'server' and 'port' for Visdom visualization. |
141,530 | import torch
import torch.nn.functional as F
from pytracking.libs.tensorlist import tensor_operation, TensorList
def conv2d(input: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor = None, stride=1, padding=0, dilation=1, groups=1, mode=None):
"""Standard conv2d. Returns the input if weight=None."""
if wei... | Do a convolution with a 1x1 kernel weights. Implemented with matmul, which can be faster than using conv. |
141,531 | import torch
import torch.nn.functional as F
from pytracking import complex, TensorList
from pytracking.libs.tensorlist import tensor_operation
def rfftshift2(a: torch.Tensor):
h = a.shape[2] + 2
return torch.cat((a[:,:,(h-1)//2:,...], a[:,:,:h//2,...]), 2)
The provided code snippet includes necessary dependen... | Do FFT and center the low frequency component. Always produces odd (full) output sizes. |
141,532 | import torch
import torch.nn.functional as F
from pytracking import complex, TensorList
from pytracking.libs.tensorlist import tensor_operation
def cifft2(a, signal_sizes=None):
"""Do inverse FFT corresponding to cfft2."""
return torch.irfft(irfftshift2(a), 2, signal_sizes=signal_sizes)
The provided code snipp... | Samples the Fourier series. |
141,533 | import torch
import torch.nn.functional as F
from pytracking import complex, TensorList
from pytracking.libs.tensorlist import tensor_operation
def get_frequency_coord(sz, add_complex_dim = False, device='cpu'):
"""Frequency coordinates."""
ky = torch.arange(-int((sz[0]-1)/2), int(sz[0]/2+1), dtype=torch.float3... | Shift a sample a in the Fourier domain. Params: a : The fourier coefficiens of the sample. shift : The shift to be performed normalized to the range [-pi, pi]. |
141,534 | import torch
import torch.nn.functional as F
from pytracking import complex, TensorList
from pytracking.libs.tensorlist import tensor_operation
The provided code snippet includes necessary dependencies for implementing the `sum_fs` function. Write a Python function `def sum_fs(a: TensorList) -> torch.Tensor` to solve ... | Sum a list of Fourier series expansions. |
141,535 | import torch
import torch.nn.functional as F
from pytracking import complex, TensorList
from pytracking.libs.tensorlist import tensor_operation
The provided code snippet includes necessary dependencies for implementing the `sum_fs12` function. Write a Python function `def sum_fs12(a: TensorList) -> torch.Tensor` to so... | Sum a list of Fourier series expansions. |
141,536 | import torch
import torch.nn.functional as F
from pytracking import complex, TensorList
from pytracking.libs.tensorlist import tensor_operation
def inner_prod_fs(a: torch.Tensor, b: torch.Tensor):
if complex.is_complex(a) and complex.is_complex(b):
return 2 * (a.reshape(-1) @ b.reshape(-1)) - a[:, :, :, 0,... | null |
141,537 | import functools
import torch
import copy
class TensorList(list):
def __init__(self, list_of_tensors = None):
def __deepcopy__(self, memodict={}):
def __getitem__(self, item):
def __add__(self, other):
def __radd__(self, other):
def __iadd__(self, other):
def __sub__(self, other):
... | null |
141,538 | import torch
from pytracking.libs.tensorlist import tensor_operation
def is_real(a: torch.Tensor) -> bool:
return not is_complex(a)
def mult_real_cplx(a: torch.Tensor, b: torch.Tensor):
"""Pointwise complex multiplication of real tensor a with complex tensor b."""
if is_real(b):
raise ValueError('La... | Pointwise complex multiplication of complex tensors. |
141,539 | import torch
from pytracking.libs.tensorlist import tensor_operation
def is_real(a: torch.Tensor) -> bool:
return not is_complex(a)
def mult_conj(a: torch.Tensor, b: torch.Tensor):
"""Pointwise complex multiplication of complex tensors, with conjugate on b: a*conj(b)."""
if is_real(a):
if a.dim() >=... | Pointwise complex division of complex tensors. |
141,540 | import torch
from pytracking.libs.tensorlist import tensor_operation
def is_real(a: torch.Tensor) -> bool:
return not is_complex(a)
def abs_sqr(a: torch.Tensor):
"""Squared absolute value."""
if is_real(a):
raise ValueError('Last dimension must have length 2.')
return torch.sum(a*a, -1)
The pro... | Absolute value. |
141,541 | import torch
from pytracking.libs.tensorlist import tensor_operation
def is_real(a: torch.Tensor) -> bool:
return not is_complex(a)
The provided code snippet includes necessary dependencies for implementing the `real` function. Write a Python function `def real(a: torch.Tensor)` to solve the following problem:
Rea... | Real part. |
141,542 | import torch
from pytracking.libs.tensorlist import tensor_operation
def is_real(a: torch.Tensor) -> bool:
return not is_complex(a)
The provided code snippet includes necessary dependencies for implementing the `imag` function. Write a Python function `def imag(a: torch.Tensor)` to solve the following problem:
Ima... | Imaginary part. |
141,543 | import torch
from pytracking.libs.tensorlist import tensor_operation
def is_real(a: torch.Tensor) -> bool:
return not is_complex(a)
def complex(a: torch.Tensor, b: torch.Tensor = None):
"""Create complex tensor from real and imaginary part."""
if b is None:
b = a.new_zeros(a.shape)
elif a is Non... | Complex matrix multiplication of complex tensors. The dimensions (-3, -2) are matrix multiplied. -1 is the complex dimension. |
141,544 | import torch
from pytracking.libs.tensorlist import tensor_operation
The provided code snippet includes necessary dependencies for implementing the `exp_imag` function. Write a Python function `def exp_imag(a: torch.Tensor)` to solve the following problem:
Complex exponential with imaginary input: e^(i*a)
Here is the... | Complex exponential with imaginary input: e^(i*a) |
141,545 | import torch
import math
from pytracking import fourier
from pytracking import complex
import torch.nn.functional as F
def hann1d(sz: int, centered = True) -> torch.Tensor:
"""1D cosine window."""
if centered:
return 0.5 * (1 - torch.cos((2 * math.pi / (sz + 1)) * torch.arange(1, sz + 1).float()))
w... | 2D cosine window. |
141,546 | import torch
import math
from pytracking import fourier
from pytracking import complex
import torch.nn.functional as F
def hann1d(sz: int, centered = True) -> torch.Tensor:
"""1D cosine window."""
if centered:
return 0.5 * (1 - torch.cos((2 * math.pi / (sz + 1)) * torch.arange(1, sz + 1).float()))
w... | 1D clipped cosine window. |
141,547 | import torch
import math
from pytracking import fourier
from pytracking import complex
import torch.nn.functional as F
def gauss_fourier(sz: int, sigma: float, half: bool = False) -> torch.Tensor:
if half:
k = torch.arange(0, int(sz/2+1))
else:
k = torch.arange(-int((sz-1)/2), int(sz/2+1))
r... | null |
141,548 | import torch
import math
from pytracking import fourier
from pytracking import complex
import torch.nn.functional as F
def gauss_spatial(sz, sigma, center=0, end_pad=0):
k = torch.arange(-(sz-1)/2, (sz+1)/2+end_pad)
return torch.exp(-1.0/(2*sigma**2) * (k - center)**2)
The provided code snippet includes necess... | The origin is in the middle of the image. |
141,549 | import torch
import math
from pytracking import fourier
from pytracking import complex
import torch.nn.functional as F
def cubic_spline_fourier(f, a):
"""The continuous Fourier transform of a cubic spline kernel."""
bf = (6*(1 - torch.cos(2 * math.pi * f)) + 3*a*(1 - torch.cos(4 * math.pi * f))
- (6 ... | null |
141,550 | import torch
import math
from pytracking import fourier
from pytracking import complex
import torch.nn.functional as F
def interpolate_dft(a: torch.Tensor, interp_fs) -> torch.Tensor:
if isinstance(interp_fs, torch.Tensor):
return complex.mult(a, interp_fs)
if isinstance(interp_fs, (tuple, list)):
... | null |
141,551 | import torch
import math
from pytracking import fourier
from pytracking import complex
import torch.nn.functional as F
The provided code snippet includes necessary dependencies for implementing the `get_reg_filter` function. Write a Python function `def get_reg_filter(sz: torch.Tensor, target_sz: torch.Tensor, params)... | Computes regularization filter in CCOT and ECO. |
141,552 | import torch
import math
from pytracking import fourier
from pytracking import complex
import torch.nn.functional as F
The provided code snippet includes necessary dependencies for implementing the `max2d` function. Write a Python function `def max2d(a: torch.Tensor) -> (torch.Tensor, torch.Tensor)` to solve the follo... | Computes maximum and argmax in the last two dimensions. |
141,553 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,554 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,555 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,556 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,557 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,558 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,559 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,560 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
def __init__(self, net_path, use_gpu=True, initialize=False, image_format='rgb',
mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), **kwargs):
de... | null |
141,561 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,562 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,563 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
def __init__(self, net_path, use_gpu=True, initialize=False, image_format='rgb',
mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), **kwargs):
de... | null |
141,564 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,565 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone, NetWrapper
class NetWrapper:
"""Used for wrapping networks in pytracking.
Network modules and functions can be accessed directly as if they were members of this class."""
_rec_iter=0
def __init__(se... | null |
141,566 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone, NetWrapper
class NetWrapper:
"""Used for wrapping networks in pytracking.
Network modules and functions can be accessed directly as if they were members of this class."""
_rec_iter=0
def __init__(se... | null |
141,567 | from pytracking.utils import TrackerParams, FeatureParams, Choice
from pytracking.features.extractor import MultiResolutionExtractor
from pytracking.features import deep
import torch
class MultiResolutionExtractor(ExtractorBase):
"""Multi-resolution feature extractor.
args:
features: List of features.
... | null |
141,568 | from pytracking.utils import TrackerParams, FeatureParams, Choice
from pytracking.features.extractor import MultiResolutionExtractor
from pytracking.features import deep
import torch
class MultiResolutionExtractor(ExtractorBase):
def __init__(self, features, patch_mode='replicate', max_scale_change=None):
de... | null |
141,569 | from pytracking.utils import TrackerParams, FeatureParams, Choice
from pytracking.features.extractor import MultiResolutionExtractor
from pytracking.features import deep
import torch
class MultiResolutionExtractor(ExtractorBase):
"""Multi-resolution feature extractor.
args:
features: List of features.
... | null |
141,570 | from pytracking.utils import TrackerParams, FeatureParams, Choice
from pytracking.features.extractor import MultiResolutionExtractor
from pytracking.features import deep
import torch
class MultiResolutionExtractor(ExtractorBase):
"""Multi-resolution feature extractor.
args:
features: List of features.
... | null |
141,571 | from pytracking.utils import TrackerParams, FeatureParams, Choice
from pytracking.features.extractor import MultiResolutionExtractor
from pytracking.features import deep
import torch
class MultiResolutionExtractor(ExtractorBase):
"""Multi-resolution feature extractor.
args:
features: List of features.
... | null |
141,572 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,573 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,574 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,575 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
def __init__(self, net_path, use_gpu=True, initialize=False, image_format='rgb',
mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), **kwargs):
de... | null |
141,576 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
def __init__(self, net_path, use_gpu=True, initialize=False, image_format='rgb',
mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), **kwargs):
de... | null |
141,577 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,578 | from pytracking.utils import TrackerParams, FeatureParams
from pytracking.features.extractor import MultiResolutionExtractor
from pytracking.features import deep
import torch
class MultiResolutionExtractor(ExtractorBase):
def __init__(self, features, patch_mode='replicate', max_scale_change=None):
def stride... | null |
141,579 | from pytracking.utils import TrackerParams, FeatureParams
from pytracking.features.extractor import MultiResolutionExtractor
from pytracking.features import deep
import torch
class MultiResolutionExtractor(ExtractorBase):
"""Multi-resolution feature extractor.
args:
features: List of features.
"""
... | null |
141,580 | from pytracking.utils import TrackerParams
from pytracking.features.net_wrappers import NetWithBackbone
class NetWithBackbone(NetWrapper):
"""Wraps a network with a common backbone.
Assumes the network have a 'extract_backbone_features(image)' function."""
def __init__(self, net_path, use_gpu=True, initia... | null |
141,581 | import torch
import torch.nn.functional as F
import numpy as np
def numpy_to_torch(a: np.ndarray):
return torch.from_numpy(a).float().permute(2, 0, 1).unsqueeze(0) | null |
141,582 | import torch
import torch.nn.functional as F
import numpy as np
def torch_to_numpy(a: torch.Tensor):
return a.squeeze(0).permute(1,2,0).numpy() | null |
141,583 | import torch
import torch.nn.functional as F
import numpy as np
def sample_patch(im: torch.Tensor, pos: torch.Tensor, sample_sz: torch.Tensor, output_sz: torch.Tensor = None,
mode: str = 'replicate', max_scale_change=None, is_mask=False):
"""Sample an image patch.
args:
im: Image
... | Extract transformed image samples. args: im: Image. pos: Center position for extraction. scale: Image scale to extract features from. image_sz: Size to resize the image samples to before extraction. transforms: A set of image transforms to apply. |
141,584 | import torch
import torch.nn.functional as F
import numpy as np
def sample_patch(im: torch.Tensor, pos: torch.Tensor, sample_sz: torch.Tensor, output_sz: torch.Tensor = None,
mode: str = 'replicate', max_scale_change=None, is_mask=False):
"""Sample an image patch.
args:
im: Image
... | Extract image patches at multiple scales. args: im: Image. pos: Center position for extraction. scales: Image scales to extract image patches from. image_sz: Size to resize the image samples to mode: how to treat image borders: 'replicate' (default), 'inside' or 'inside_major' max_scale_change: maximum allowed scale ch... |
141,585 | from collections import namedtuple
import importlib
from pytracking.evaluation.data import SequenceList
def load_dataset(name: str, **kwargs):
""" Import and load a single dataset."""
name = name.lower()
dset_info = dataset_dict.get(name)
if dset_info is None:
raise ValueError('Unknown dataset \... | Get a list of strings containing the short or long names of all attributes in the dataset. |
141,586 | import sys
import copy
import collections
Rectangle = collections.namedtuple('Rectangle', ['x', 'y', 'width', 'height'])
Point = collections.namedtuple('Point', ['x', 'y'])
Polygon = collections.namedtuple('Polygon', ['points'])
def parse_region(string):
tokens = map(float, string.split(','))
if len(tokens) ==... | null |
141,587 | import sys
import copy
import collections
Rectangle = collections.namedtuple('Rectangle', ['x', 'y', 'width', 'height'])
Polygon = collections.namedtuple('Polygon', ['points'])
def encode_region(region):
if isinstance(region, Polygon):
return ','.join(['{},{}'.format(p.x,p.y) for p in region.points])
e... | null |
141,588 | import sys
import copy
import collections
Rectangle = collections.namedtuple('Rectangle', ['x', 'y', 'width', 'height'])
Polygon = collections.namedtuple('Polygon', ['points'])
def convert_region(region, to):
if to == 'rectangle':
if isinstance(region, Rectangle):
return copy.copy(region)
... | null |
141,589 | import sys
import copy
import collections
import numpy as np
The provided code snippet includes necessary dependencies for implementing the `make_full_size` function. Write a Python function `def make_full_size(x, output_sz)` to solve the following problem:
zero-pad input x (right and down) to match output_sz x: numpy... | zero-pad input x (right and down) to match output_sz x: numpy array e.g., binary mask output_sz: size of the output [width, height] |
141,590 | import importlib
import os
import numpy as np
from collections import OrderedDict
from pytracking.evaluation.environment import env_settings
import time
import cv2 as cv
from pytracking.utils.visdom import Visdom
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from pytracking.utils.plotting import ... | Generate list of trackers. args: name: Name of tracking method. parameter_name: Name of parameter file. run_ids: A single or list of run_ids. display_name: Name to be displayed in the result plots. |
141,591 | from pytracking.evaluation import Tracker, get_dataset, trackerlist
def atom_nfs_uav():
# Run three runs of ATOM on NFS and UAV datasets
trackers = trackerlist('atom', 'default', range(3))
dataset = get_dataset('nfs', 'uav')
return trackers, dataset | null |
141,592 | from pytracking.evaluation import Tracker, get_dataset, trackerlist
def uav_test():
# Run DiMP18, ATOM and ECO on the UAV dataset
trackers = trackerlist('dimp', 'dimp18', range(1)) + \
trackerlist('atom', 'default', range(1)) + \
trackerlist('eco', 'default', range(1))
datase... | null |
141,593 | import os
import sys
import argparse
from pytracking.evaluation import get_dataset
from pytracking.evaluation.running import run_dataset
from pytracking.evaluation import Tracker
def run_dataset(dataset, trackers, debug=False, threads=0, visdom_info=None):
"""Runs a list of trackers on a dataset.
args:
... | Run tracker on sequence or dataset. args: tracker_name: Name of tracking method. tracker_param: Name of parameter file. run_id: The run id. dataset_name: Name of dataset (otb, nfs, uav, tpl, vot, tn, gott, gotv, lasot). sequence: Sequence number or name. debug: Debug level. threads: Number of threads. visdom_info: Dict... |
141,594 | import os
import sys
import argparse
from pytracking.evaluation import Tracker
The provided code snippet includes necessary dependencies for implementing the `run_video` function. Write a Python function `def run_video(tracker_name, tracker_param, videofile, optional_box=None, debug=None, save_results=False)` to solve... | Run the tracker on your webcam. args: tracker_name: Name of tracking method. tracker_param: Name of parameter file. debug: Debug level. |
141,595 | import warnings
import numpy as np
from skimage.morphology import binary_dilation, disk
from math import floor
The provided code snippet includes necessary dependencies for implementing the `davis_jaccard_measure_torch` function. Write a Python function `def davis_jaccard_measure_torch(fg_mask, gt_mask)` to solve the ... | Compute region similarity as the Jaccard Index. :param fg_mask: (ndarray): binary segmentation map. :param gt_mask: (ndarray): binary annotation map. :return: jaccard (float): region similarity |
141,596 | import os
import sys
import importlib
import numpy as np
import torch
import time
import matplotlib.patches as patches
import cv2 as cv
import matplotlib.pyplot as plt
from pytracking.analysis.plot_results import get_plot_draw_styles
from pytracking.utils.plotting import draw_figure
from pytracking.evaluation import ge... | Playback saved results of input trackers for a particular sequence. You can navigate the sequence using left/right arrow keys. You can also change to 'auto' mode by pressing space bar, in which case the sequence will be replayed at a particular speed. The speed for playback in 'auto' mode can be controlled using the le... |
141,597 | import tikzplotlib
import matplotlib
import matplotlib.pyplot as plt
import os
import torch
import pickle
import json
import math
from pytracking.evaluation.environment import env_settings
from pytracking.analysis.extract_results import extract_results, extract_results_prec_rec_f1
def get_plot_draw_styles():
plot_d... | Plot results for the given trackers args: trackers - List of trackers to evaluate dataset - List of sequences to evaluate report_name - Name of the folder in env_settings.perm_mat_path where the computed results and plots are saved merge_results - If True, multiple random runs for a non-deterministic trackers are avera... |
141,598 | import tikzplotlib
import matplotlib
import matplotlib.pyplot as plt
import os
import torch
import pickle
import json
import math
from pytracking.evaluation.environment import env_settings
from pytracking.analysis.extract_results import extract_results, extract_results_prec_rec_f1
def merge_multiple_runs(eval_data):
... | Print the results for the given trackers in a formatted table args: trackers - List of trackers to evaluate dataset - List of sequences to evaluate report_name - Name of the folder in env_settings.perm_mat_path where the computed results and plots are saved merge_results - If True, multiple random runs for a non-determ... |
141,599 | import tikzplotlib
import matplotlib
import matplotlib.pyplot as plt
import os
import torch
import pickle
import json
import math
from pytracking.evaluation.environment import env_settings
from pytracking.analysis.extract_results import extract_results, extract_results_prec_rec_f1
def get_plot_draw_styles():
plot_d... | Plot success plot for GOT-10k dataset using the json reports. Save the json reports from http://got-10k.aitestunion.com/leaderboard in the directory set to env_settings.got_reports_path The tracker name in the experiment file should be set to the name of the report file for that tracker, e.g. DiMP50_report_2019_09_02_1... |
141,600 | import tikzplotlib
import matplotlib
import matplotlib.pyplot as plt
import os
import torch
import pickle
import json
import math
from pytracking.evaluation.environment import env_settings
from pytracking.analysis.extract_results import extract_results, extract_results_prec_rec_f1
def merge_multiple_runs(eval_data):
... | Print per-sequence results for the given trackers. Additionally, the sequences to list can be filtered using the filter criteria. args: trackers - List of trackers to evaluate dataset - List of sequences to evaluate report_name - Name of the folder in env_settings.perm_mat_path where the computed results and plots are ... |
141,601 | import tikzplotlib
import matplotlib
import matplotlib.pyplot as plt
import os
import torch
import pickle
import json
import math
from pytracking.evaluation.environment import env_settings
from pytracking.analysis.extract_results import extract_results, extract_results_prec_rec_f1
def merge_multiple_runs(eval_data):
... | Print per-attribute results for the given trackers. args: trackers - List of trackers to evaluate datasets - Dict of sequences to evaluate, each list of sequences corresponds to one attribute. report_name - Name of the folder in env_settings.perm_mat_path where the computed results and plots are saved merge_results - I... |
141,602 | import tikzplotlib
import matplotlib
import matplotlib.pyplot as plt
import os
import torch
import pickle
import json
import math
from pytracking.evaluation.environment import env_settings
from pytracking.analysis.extract_results import extract_results, extract_results_prec_rec_f1
def get_plot_draw_styles():
plot_d... | null |
141,603 | import os
import numpy as np
import torch
import pandas as pd
from collections import OrderedDict
from ltr.data.image_loader import imread_indexed
from pytracking.evaluation import get_dataset
from pathlib import Path
from pytracking.analysis.plot_results import generate_formatted_report
import pytracking.analysis.vos_... | evaluate a list of trackers on a vos dataset. args: trackers - list of trackers to evaluate dataset - name of the dataset force - Force re-evaluation. If False, the pre-computed results are loaded if available |
141,604 | import os
import sys
import argparse
import importlib
from pytracking.evaluation.running import run_dataset
def run_dataset(dataset, trackers, debug=False, threads=0, visdom_info=None):
"""Runs a list of trackers on a dataset.
args:
dataset: List of Sequence instances, forming a dataset.
tracke... | Run experiment. args: experiment_module: Name of experiment module in the experiments/ folder. experiment_name: Name of the experiment function. debug: Debug level. threads: Number of threads. |
141,605 | import os
from pytracking.tracker.base import BaseTracker
import torch
import torch.nn.functional as F
import math
import time
from pytracking import dcf, TensorList
from pytracking.features.preprocessing import numpy_to_torch
from ltr.models.layers import activation
from collections import defaultdict, OrderedDict
de... | null |
141,606 | from pytracking import TensorList
import random
The provided code snippet includes necessary dependencies for implementing the `Choice` function. Write a Python function `def Choice(*args)` to solve the following problem:
Can be used to sample random parameter values.
Here is the function:
def Choice(*args):
"""... | Can be used to sample random parameter values. |
141,607 | import os
import ltr.admin.loading as ltr_loading
from pytracking.evaluation.environment import env_settings
def env_settings():
env_module_name = 'pytracking.evaluation.local'
try:
env_module = importlib.import_module(env_module_name)
return env_module.local_env_settings()
except:
... | Load network for tracking. args: net_path - Path to network. If it is not an absolute path, it is relative to the network_path in the local.py. See ltr.admin.loading.load_network for further details. **kwargs - Additional key-word arguments that are sent to ltr.admin.loading.load_network. |
141,608 | import matplotlib.pyplot as plt
import numpy as np
import torch
import cv2
def draw_figure(fig):
fig.canvas.draw()
fig.canvas.flush_events()
plt.pause(0.001)
The provided code snippet includes necessary dependencies for implementing the `show_tensor` function. Write a Python function `def show_tensor(a: to... | Display a 2D tensor. args: fig_num: Figure number. title: Title of figure. |
141,609 | import matplotlib.pyplot as plt
import numpy as np
import torch
import cv2
def draw_figure(fig):
fig.canvas.draw()
fig.canvas.flush_events()
plt.pause(0.001)
The provided code snippet includes necessary dependencies for implementing the `plot_graph` function. Write a Python function `def plot_graph(a: torc... | Plot graph. Data is a 1D tensor. args: fig_num: Figure number. title: Title of figure. |
141,610 | import matplotlib.pyplot as plt
import numpy as np
import torch
import cv2
def show_image_with_boxes(im, boxes, iou_pred=None, disp_ids=None):
im_np = im.clone().cpu().squeeze().numpy()
im_np = np.ascontiguousarray(im_np.transpose(1, 2, 0).astype(np.uint8))
boxes = boxes.view(-1, 4).cpu().numpy().round().... | null |
141,611 | import matplotlib.pyplot as plt
import numpy as np
import torch
import cv2
def _pascal_color_map(N=256, normalized=False):
"""
Python implementation of the color map function for the PASCAL VOC data set.
Official Matlab version can be found in the PASCAL VOC devkit
http://host.robots.ox.ac.uk/pascal/VOC... | Overlay mask over image. Source: https://github.com/albertomontesg/davis-interactive/blob/master/davisinteractive/utils/visualization.py This function allows you to overlay a mask over an image with some transparency. # Arguments im: Numpy Array. Array with the image. The shape must be (H, W, 3) and the pixels must be ... |
141,612 | import numpy as np
def convert_vot_anno_to_rect(vot_anno, type):
if len(vot_anno) == 4:
return vot_anno
if type == 'union':
x1 = min(vot_anno[0::2])
x2 = max(vot_anno[0::2])
y1 = min(vot_anno[1::2])
y2 = max(vot_anno[1::2])
return [x1, y1, x2 - x1, y2 - y1]
... | null |
141,613 | import numpy as np
import os
import shutil
from pytracking.evaluation.environment import env_settings
def env_settings():
env_module_name = 'pytracking.evaluation.local'
try:
env_module = importlib.import_module(env_module_name)
return env_module.local_env_settings()
except:
env_fil... | Packs got10k results into a zip folder which can be directly uploaded to the evaluation server. The packed file is saved in the folder env_settings().got_packed_results_path args: tracker_name - name of the tracker param_name - name of the parameter file output_name - name of the packed zip file |
141,614 | import os
import sys
import gdown
import re
import shutil
import argparse
import tempfile
from pytracking.evaluation.environment import env_settings
pytracking_results_link_dict = {
"dimp": {
"prdimp50_003.zip": "1p13j3iwcOCubBi3ms0hLwqnP6-x0J8Mc",
"prdimp50_002.zip": "1PPKgrAepbuyM2kjfzYAozQKTL6Ajc... | Script to automatically download tracker results for PyTracking. args: download_path - Directory where the zipped results are downloaded trackers - Tracker results which are to be downloaded. If set to 'pytracking', results for all pytracking based trackers will be downloaded. If set to 'external', results for availabl... |
141,615 | import os
import sys
import gdown
import re
import shutil
import argparse
import tempfile
from pytracking.evaluation.environment import env_settings
def env_settings():
env_module_name = 'pytracking.evaluation.local'
try:
env_module = importlib.import_module(env_module_name)
return env_module.l... | Unpacks zipped benchmark results. The directory 'download_path' should have the following structure - root - tracker1 - param1.zip - param2.zip . . - tracker2 - param1.zip - param2.zip . . args: download_path - Path to the directory where the zipped results are stored output_path - Path to the directory where the resul... |
141,616 | import os
import sys
import json
import torch
import argparse
from tqdm import tqdm
from collections import defaultdict
from pytracking.evaluation import get_dataset, Tracker
import ltr.data.processing_utils as prutils
from pytracking import dcf
def load_dump_seq_data_from_disk(path):
d = {}
if os.path.exists(p... | null |
141,617 | import numpy as np
import os
import shutil
from pytracking.evaluation.environment import env_settings
from pytracking.evaluation.datasets import get_dataset
def env_settings():
env_module_name = 'pytracking.evaluation.local'
try:
env_module = importlib.import_module(env_module_name)
return env_... | Packs trackingnet results into a zip folder which can be directly uploaded to the evaluation server. The packed file is saved in the folder env_settings().tn_packed_results_path args: tracker_name - name of the tracker param_name - name of the parameter file run_id - run id for the tracker output_name - name of the pac... |
141,618 | import os
import sys
import argparse
from pytracking.evaluation import Tracker
def run_vot2020(tracker_name, tracker_param, run_id=None, debug=0, visdom_info=None):
tracker = Tracker(tracker_name, tracker_param, run_id)
tracker.run_vot2020(debug, visdom_info) | null |
141,619 | import os
import sys
import argparse
from pytracking.evaluation import Tracker
def run_vot(tracker_name, tracker_param, run_id=None):
tracker = Tracker(tracker_name, tracker_param, run_id)
tracker.run_vot() | null |
141,620 | import torch
import torch.nn as nn
import torch.nn.functional as F
from pdb import set_trace as stx
def conv(in_channels, out_channels, kernel_size, bias=False, stride = 1):
return nn.Conv2d(
in_channels, out_channels, kernel_size,
padding=(kernel_size//2), bias=bias, stride = stride) | null |
141,621 | import os
from torch.utils.data import Dataset
import torch
from PIL import Image
import torchvision.transforms.functional as TF
from pdb import set_trace as stx
import random
def is_image_file(filename):
return any(filename.endswith(extension) for extension in ['jpeg', 'JPEG', 'jpg', 'png', 'JPG', 'PNG', 'gif']) | null |
141,622 | import os
from dataset_RGB import DataLoaderTrain, DataLoaderVal, DataLoaderTest
class DataLoaderTrain(Dataset):
def __init__(self, rgb_dir, img_options=None):
def __len__(self):
def __getitem__(self, index):
def get_training_data(rgb_dir, img_options):
assert os.path.exists(rgb_dir)
return Dat... | null |
141,623 | import os
from dataset_RGB import DataLoaderTrain, DataLoaderVal, DataLoaderTest
class DataLoaderVal(Dataset):
def __init__(self, rgb_dir, img_options=None, rgb_dir2=None):
super(DataLoaderVal, self).__init__()
inp_files = sorted(os.listdir(os.path.join(rgb_dir, 'input')))
tar_files = sort... | null |
141,624 | import os
from dataset_RGB import DataLoaderTrain, DataLoaderVal, DataLoaderTest
class DataLoaderTest(Dataset):
def __init__(self, inp_dir, img_options):
super(DataLoaderTest, self).__init__()
inp_files = sorted(os.listdir(inp_dir))
self.inp_filenames = [os.path.join(inp_dir, x) for x in i... | null |
141,625 | import os
from natsort import natsorted
from glob import glob
def mkdir(path):
if not os.path.exists(path):
os.makedirs(path)
def mkdirs(paths):
if isinstance(paths, list) and not isinstance(paths, str):
for path in paths:
mkdir(path)
else:
mkdir(paths) | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.