repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/utils/parrots_wrapper.py | # Copyright (c) OpenMMLab. All rights reserved.
from functools import partial
import torch
TORCH_VERSION = torch.__version__
def is_rocm_pytorch() -> bool:
is_rocm = False
if TORCH_VERSION != 'parrots':
try:
from torch.utils.cpp_extension import ROCM_HOME
is_rocm = True if ((... | 3,536 | 31.75 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/utils/logging.py | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import torch.distributed as dist
logger_initialized = {}
def get_logger(name, log_file=None, log_level=logging.INFO, file_mode='w'):
"""Initialize and get a logger by name.
If the logger has not been initialized, this method will initialize the... | 3,986 | 34.918919 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/utils/testing.py | # Copyright (c) Open-MMLab.
import sys
from collections.abc import Iterable
from runpy import run_path
from shlex import split
from typing import Any, Dict, List
from unittest.mock import patch
def check_python_script(cmd):
"""Run the python cmd script with `__main__`. The difference between
`os.system` is th... | 4,289 | 29.425532 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/utils/ext_loader.py | # Copyright (c) OpenMMLab. All rights reserved.
import importlib
import os
import pkgutil
import warnings
from collections import namedtuple
import torch
if torch.__version__ != 'parrots':
def load_ext(name, funcs):
ext = importlib.import_module('mmcv.' + name)
for fun in funcs:
asser... | 2,021 | 27.083333 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/utils/__init__.py | # flake8: noqa
# Copyright (c) OpenMMLab. All rights reserved.
from .config import Config, ConfigDict, DictAction
from .misc import (check_prerequisites, concat_list, deprecated_api_warning,
has_method, import_modules_from_strings, is_list_of,
is_method_overridden, is_seq_of, is_st... | 3,915 | 54.942857 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/utils/trace.py | import warnings
import torch
from annotator.uniformer.mmcv.utils import digit_version
def is_jit_tracing() -> bool:
if (torch.__version__ != 'parrots'
and digit_version(torch.__version__) >= digit_version('1.6.0')):
on_trace = torch.jit.is_tracing()
# In PyTorch 1.6, torch.jit.is_tra... | 795 | 32.166667 | 76 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/utils/env.py | # Copyright (c) OpenMMLab. All rights reserved.
"""This file holding some environment constant for sharing by other files."""
import os.path as osp
import subprocess
import sys
from collections import defaultdict
import cv2
import torch
import annotator.uniformer.mmcv as mmcv
from .parrots_wrapper import get_build_c... | 3,367 | 34.083333 | 97 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/deform_roi_pool.py | # Copyright (c) OpenMMLab. All rights reserved.
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['deform_roi_pool_forward', 'deform_roi... | 7,410 | 35.15122 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/nms.py | import os
import numpy as np
import torch
from annotator.uniformer.mmcv.utils import deprecated_api_warning
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['nms', 'softnms', 'nms_match', 'nms_rotated'])
# This function is modified from: https://github.com/pytorch/vision/
class NMSop(t... | 16,237 | 37.84689 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/ball_query.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['ball_query_forward'])
class BallQuery(Function):
"""Find nearby points in spherical space."""
@staticmethod
def forward(ctx, min_rad... | 1,695 | 29.285714 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/roiaware_pool3d.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import nn as nn
from torch.autograd import Function
import annotator.uniformer.mmcv as mmcv
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['roiaware_pool3d_forward', 'roiaware_pool3d_backward'])
class RoIAwarePool... | 4,256 | 36.017391 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/cc_attention.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import PLUGIN_LAYERS, Scale
def NEG_INF_DIAG(n, device):
"""Returns a diagonal matrix of size [n, n].
The diagonal are all "-inf". This is for avoiding calcula... | 3,041 | 35.214286 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/deform_conv.py | # Copyright (c) OpenMMLab. All rights reserved.
from typing import Tuple, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair, _single
from... | 15,603 | 37.433498 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/knn.py | import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['knn_forward'])
class KNN(Function):
r"""KNN (CUDA) based on heap data structure.
Modified from `PAConv <https://github.com/CVMI-Lab/PAConv/tree/main/
scene_seg/lib/pointops/src/knnq... | 2,599 | 32.333333 | 75 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/correlation.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import Tensor, nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['correlation_forw... | 6,697 | 33 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/roi_pool.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext',
... | 2,517 | 27.942529 | 75 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/roi_align.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from ..utils import deprecated_api_warning, ext_loader
ext_module = ext_loader.load_ext('_ext',
... | 8,519 | 37.035714 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/sync_bn.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.distributed as dist
import torch.nn.functional as F
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.module import Module
from torch.nn.parameter import Parameter
from annotator.un... | 11,267 | 39.242857 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/roipoint_pool3d.py | from torch import nn as nn
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['roipoint_pool3d_forward'])
class RoIPointPool3d(nn.Module):
"""Encode the geometry-specific features of each 3D proposal.
Please refer to `Paper of PartA2 <https://arxiv.... | 2,990 | 37.346154 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/saconv.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import CONV_LAYERS, ConvAWS2d, constant_init
from annotator.uniformer.mmcv.ops.deform_conv import deform_conv2d
from annotator.uniformer.mmcv.utils import TORCH_VERSION, ... | 5,804 | 38.760274 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/point_sample.py | # Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend # noqa
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, g... | 12,287 | 35.462908 | 101 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/upfirdn2d.py | # modified from https://github.com/rosinality/stylegan2-pytorch/blob/master/op/upfirdn2d.py # noqa:E501
# Copyright (c) 2021, NVIDIA Corporation. All rights reserved.
# NVIDIA Source Code License for StyleGAN2 with Adaptive Discriminator
# Augmentation (ADA)
# =========================================================... | 11,800 | 34.652568 | 104 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/fused_bias_leakyrelu.py | # modified from https://github.com/rosinality/stylegan2-pytorch/blob/master/op/fused_act.py # noqa:E501
# Copyright (c) 2021, NVIDIA Corporation. All rights reserved.
# NVIDIA Source Code License for StyleGAN2 with Adaptive Discriminator
# Augmentation (ADA)
# ==========================================================... | 10,027 | 36.27881 | 103 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/group_points.py | # Copyright (c) OpenMMLab. All rights reserved.
from typing import Tuple
import torch
from torch import nn as nn
from torch.autograd import Function
from ..utils import ext_loader
from .ball_query import ball_query
from .knn import knn
ext_module = ext_loader.load_ext(
'_ext', ['group_points_forward', 'group_poi... | 8,135 | 35.16 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/iou3d.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', [
'iou3d_boxes_iou_bev_forward', 'iou3d_nms_forward',
'iou3d_nms_normal_forward'
])
def boxes_iou_bev(boxes_a, boxes_b):
"""Calculate boxes IoU in the Bird's Eye View.
... | 2,988 | 33.755814 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/border_align.py | # Copyright (c) OpenMMLab. All rights reserved.
# modified from
# https://github.com/Megvii-BaseDetection/cvpods/blob/master/cvpods/layers/border_align.py
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from ..utils import ext_loader
ext_... | 3,725 | 32.872727 | 90 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/carafe.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Function
from torch.nn.modules.module import Module
from ..cnn import UPSAMPLE_LAYERS, normal_init, xavier_init
from ..utils import ext_loader
ext_module = ext_loader.load_ext(... | 9,873 | 33.284722 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/points_in_boxes.py | import torch
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', [
'points_in_boxes_part_forward', 'points_in_boxes_cpu_forward',
'points_in_boxes_all_forward'
])
def points_in_boxes_part(points, boxes):
"""Find the box in which each point is (CUDA).
Args:
points (torch.... | 5,241 | 38.119403 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/three_interpolate.py | from typing import Tuple
import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['three_interpolate_forward', 'three_interpolate_backward'])
class ThreeInterpolate(Function):
"""Performs weighted linear interpolation on 3 features.
Ple... | 2,147 | 30.130435 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/corner_pool.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import nn
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', [
'top_pool_forward', 'top_pool_backward', 'bottom_pool_forward',
'bottom_pool_backward', 'left_pool_forward', 'left_poo... | 4,697 | 28 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/tin_shift.py | # Copyright (c) OpenMMLab. All rights reserved.
# Code reference from "Temporal Interlacing Network"
# https://github.com/deepcs233/TIN/blob/master/cuda_shift/rtc_wrap.py
# Hao Shao, Shengju Qian, Yu Liu
# shaoh19@mails.tsinghua.edu.cn, sjqian@cse.cuhk.edu.hk, yuliu@ee.cuhk.edu.hk
import torch
import torch.nn as nn
fr... | 2,141 | 30.043478 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/assign_score_withk.py | from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['assign_score_withk_forward', 'assign_score_withk_backward'])
class AssignScoreWithK(Function):
r"""Perform weighted sum to generate output features according to scores.
Modified from `PAConv <h... | 4,344 | 34.040323 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/three_nn.py | from typing import Tuple
import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['three_nn_forward'])
class ThreeNN(Function):
"""Find the top-3 nearest neighbors of the target set from the source set.
Please refer to `Paper of PointNet++ <... | 1,515 | 28.153846 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/bbox.py | # Copyright (c) OpenMMLab. All rights reserved.
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['bbox_overlaps'])
def bbox_overlaps(bboxes1, bboxes2, mode='iou', aligned=False, offset=0):
"""Calculate overlap between two set of bboxes.
If ``aligned`` is ``False``, then calculate the... | 2,508 | 33.369863 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/multi_scale_deform_attn.py | # Copyright (c) OpenMMLab. All rights reserved.
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.uniformer.mmcv import deprecated_api_warning
from annotator.uniformer.mmcv.cnn import constant... | 15,175 | 41.272981 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/psa_mask.py | # Modified from https://github.com/hszhao/semseg/blob/master/lib/psa
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext',
['psamask_forward', 'psamask_backward'])
cla... | 2,773 | 28.827957 | 73 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/focal_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', [
'sigmoid_focal_loss_forward', 'sigmoid_focal_loss_backward',
... | 6,582 | 29.906103 | 76 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/points_sampler.py | from typing import List
import torch
from torch import nn as nn
from annotator.uniformer.mmcv.runner import force_fp32
from .furthest_point_sample import (furthest_point_sample,
furthest_point_sample_with_dist)
def calc_square_dist(point_feat_a, point_feat_b, norm=True):
"""C... | 6,063 | 33.067416 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/voxelize.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['dynamic_voxelize_forward', 'hard_voxelize_forward'])
class _Voxelization(Funct... | 5,286 | 38.75188 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/masked_conv.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['masked_im2... | 3,761 | 32.589286 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/furthest_point_sample.py | import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', [
'furthest_point_sampling_forward',
'furthest_point_sampling_with_dist_forward'
])
class FurthestPointSampling(Function):
"""Uses iterative furthest point sampling to select a set of... | 2,550 | 29.369048 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/modulated_deform_conv.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair, _single
from annotator.uniformer.mmcv.utils import deprecated_api_warning
from ..cnn impo... | 10,574 | 36.367491 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/info.py | # Copyright (c) OpenMMLab. All rights reserved.
import glob
import os
import torch
if torch.__version__ == 'parrots':
import parrots
def get_compiler_version():
return 'GCC ' + parrots.version.compiler
def get_compiling_cuda_version():
return parrots.version.cuda
else:
from ..utils i... | 887 | 23 | 71 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/pixel_group.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['pixel_group'])
def pixel_group(score, mask, embedding, kernel_label, kernel_contour,
kernel_region_num, distance_threshold):
"""Group pixels i... | 3,113 | 39.973684 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/contour_expand.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['contour_expand'])
def contour_expand(kernel_mask, internal_kernel_label, min_kernel_area,
kernel_num):
"""Expand kernel contours so that fo... | 1,795 | 34.92 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/gather_points.py | import torch
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['gather_points_forward', 'gather_points_backward'])
class GatherPoints(Function):
"""Gather points with given index."""
@staticmethod
def forward(ctx, features: torch.Tensor,
... | 1,607 | 26.724138 | 69 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/roi_align_rotated.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext', ['roi_align_rotated_forward', 'roi_align_rotated_backward'])
class RoIAlignRotatedFunction(Function):
@staticmethod
def symb... | 6,434 | 35.151685 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/merge_cells.py | # Copyright (c) OpenMMLab. All rights reserved.
from abc import abstractmethod
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..cnn import ConvModule
class BaseMergeCell(nn.Module):
"""The basic class for cells used in NAS-FPN and NAS-FCOS.
BaseMergeCell takes 2 inputs. After apply... | 5,403 | 35.026667 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv/ops/scatter_points.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch import nn
from torch.autograd import Function
from ..utils import ext_loader
ext_module = ext_loader.load_ext(
'_ext',
['dynamic_point_to_voxel_forward', 'dynamic_point_to_voxel_backward'])
class _DynamicScatter(Function):
@staticm... | 5,201 | 37.25 | 79 | py |
libri-light | libri-light-main/eval/eval_PER.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import os
import subprocess
import sys
import json
import random
from pathlib import Path
from CPC_loader import load_cpc_features, get_features_state_dict
import PER_src.simplePhonemLearner as per_src
from torch.utils.data import Da... | 10,291 | 36.562044 | 94 | py |
libri-light | libri-light-main/eval/eval_ABX.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import sys
import torch
import json
import os
import numpy as np
import ABX_src.abx_group_computation as abx_g
import ABX_src.abx_iterators as abx_it
from CPC_loader import load_cpc_features, build_feature_from_file
from pathlib impo... | 7,987 | 37.403846 | 82 | py |
libri-light | libri-light-main/eval/eval_WER.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import os
import torchaudio
import torch
import time
import json
import progressbar
from torch.utils.data import Dataset, DataLoader
import torch.multiprocessing as mp
import jiwer
from pathlib import Path
from WER_src.letter_ctc im... | 10,090 | 30.633229 | 121 | py |
libri-light | libri-light-main/eval/CPC_loader.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import torch
import torchaudio
import torch.nn as nn
import torch.nn.functional as F
def download_state_dict(model_name):
base_url = "https://dl.fbaipublicfiles.com/librilight/CPC_checkpoints"
return torch.hub.load_state_d... | 7,994 | 30.72619 | 79 | py |
libri-light | libri-light-main/eval/WER_src/simple_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Dict, List
import torch
from torch.utils.data import Dataset
import torchaudio
from copy import deepcopy
import time
from pathlib import Path
def parse_ctc_labels_from_root(root, letters_path="./WER_data/letters.lst"):
let... | 4,001 | 30.265625 | 118 | py |
libri-light | libri-light-main/eval/WER_src/letter_ctc.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
def cut_data(seq, seq_len):
max_len = seq_len.max()
seq = seq[:, :max_len]
return seq
class LetterClassifier(torch.nn.Module):
def __init__(self, feature_maker, dim_encoder, n_letters, kernel_size=8, p_dropout=0.0):... | 1,993 | 34.607143 | 92 | py |
libri-light | libri-light-main/eval/PER_src/seq_alignment.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from copy import deepcopy
import torch
import progressbar
import math
import numpy as np
from torch.multiprocessing import Lock, Manager
from .PER_src import per_operator
def cut_data(seq, sizeSeq):
maxSeq = sizeSeq.max()
seq = seq[:, :max... | 4,564 | 28.451613 | 128 | py |
libri-light | libri-light-main/eval/PER_src/simplePhonemLearner.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torchaudio
from copy import deepcopy
import torch
import time
from pathlib import Path
from torch.utils.data import Dataset
from torch.multiprocessing import Pool
def load(path_item):
seq_name = path_item.stem
data = torchaudio.load... | 7,716 | 31.42437 | 128 | py |
libri-light | libri-light-main/eval/ABX_src/abx_group_computation.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import math
from .ABX_src import dtw
import progressbar
def get_distance_function_from_name(name_str):
if name_str == 'euclidian':
return get_euclidian_distance_batch
if name_str == 'cosine':
return get_cosine_... | 4,914 | 31.335526 | 86 | py |
libri-light | libri-light-main/eval/ABX_src/abx_iterators.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import progressbar
import math
import random
def normalize_with_singularity(x):
r"""
Normalize the given vector across the third dimension.
Extend all vectors by eps=1e-12 to put the null vector at the maximal
cosine d... | 15,291 | 34.480278 | 120 | py |
libri-light | libri-light-main/eval/ABX_src/unit_tests.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
import torch
from nose.tools import eq_, ok_
from . import abx_group_computation
from . import abx_iterators
import numpy as np
import math
class TestDistancesDTW(unittest.TestCase):
def testDTWFunction(self):
X = torc... | 9,517 | 37.691057 | 92 | py |
libri-light | libri-light-main/data_preparation/make_vad_inputs.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from pathlib import Path
import torchaudio
import progressbar
import argparse
import torch
import tqdm
def findAllSeqs(dirName,
extension='.flac',
loadCache=False):
r"""
Lists all the sequences wit... | 4,323 | 29.885714 | 78 | py |
libri-light | libri-light-main/data_preparation/metadata_completion/utilities.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pathlib import Path
import pickle
import json
import torchaudio
import progressbar
import argparse
import os
import matplotlib
from collections import namedtuple
matplotlib.use('agg')
def torchaudio_legacy_info(path):
"""
https://gith... | 9,937 | 25.08399 | 80 | py |
libri-light | libri-light-main/data_preparation/rebuild_limited_train/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import pathlib
from collections import namedtuple
import torchaudio
import shutil
Speaker = namedtuple('Speaker', ['id', 'gender', 'subset'])
FileRecord = namedtuple(
'FileRecord', ['fname', 'length', 'speaker', 'book', 'text_file'])
def get... | 4,211 | 29.085714 | 96 | py |
masakhane-news | masakhane-news-main/code/train_textclass.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 28,494 | 41.593423 | 150 | py |
masakhane-news | masakhane-news-main/code/util_textclass.py | import os
import torch
import logging
import pandas as pd
import numpy as np
from torch.utils.data import TensorDataset
logger = logging.getLogger(__name__)
class Instance:
def __init__(self, text, label):
self.text = text
self.label = label
class InputFeatures(object):
"""A single set of f... | 3,345 | 34.221053 | 122 | py |
masakhane-news | masakhane-news-main/code/classical_models/sklearn-models.py | import os
import pandas as pd
import tqdm
import numpy as np
from sklearn.naive_bayes import GaussianNB, MultinomialNB
from sklearn import metrics
from sklearn.metrics import accuracy_score,f1_score
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.neighbors import KNeighborsClassifier
from skle... | 11,028 | 32.831288 | 116 | py |
masakhane-news | masakhane-news-main/code/text2text/classification_dataset.py |
from typing import Dict
import os
import pandas as pd
import torch
from torch.utils.data import Dataset
from transformers import AutoTokenizer
class ClassificationDataset(Dataset):
def __init__(self, tokenizer: AutoTokenizer, data_path:str, **kwargs):
self.tokenizer = tokenizer
self.__d... | 4,652 | 35.351563 | 122 | py |
masakhane-news | masakhane-news-main/code/text2text/classification_trainer.py | from classification_dataset import ClassificationDataset,ClassificationDatasetTest
from utils import LoggingCallback
import random
import argparse
import textwrap
import torch
from tqdm.auto import tqdm
from sklearn import metrics
from torch.utils.data import Dataset, DataLoader
from transformers import AutoTokenizer
f... | 10,502 | 35.723776 | 110 | py |
masakhane-news | masakhane-news-main/code/text2text/utils.py | import os
import logging
import torch
import random
import numpy as np
import pytorch_lightning as pl
from classification_dataset import ClassificationDataset
logger = logging.getLogger(__name__)
class LoggingCallback(pl.Callback):
def on_validation_end(self, trainer, pl_module):
logger.info("***** Vali... | 1,505 | 30.375 | 79 | py |
masakhane-news | masakhane-news-main/code/text2text/model.py | import torch
from transformers import AutoTokenizer, T5Tokenizer
from transformers import FlaxT5ForConditionalGeneration
from transformers import T5ForConditionalGeneration
import pytorch_lightning as pl
from transformers import (
AdamW,
T5ForConditionalGeneration,
T5Tokenizer,
get_linear_schedule_with_... | 4,980 | 33.590278 | 127 | py |
DDI_prediction | DDI_prediction-master/d2d_main.py | import matplotlib.pyplot as plt
import random
import numpy
from sklearn.metrics import roc_auc_score, average_precision_score, roc_curve
import numpy as np
from d2d_evaluation import create_train_test_split_relese, create_train_test_split_ratio, average_precision_at_k, write_AUC_output, image_ext, dpi
from d2d_graph_fe... | 12,517 | 44.85348 | 277 | py |
DDI_prediction | DDI_prediction-master/calculate_katz.py | import time
import networkx as nx
import random
import numpy as np
from scipy.sparse import lil_matrix, csr_matrix
from d2d_evaluation import create_train_test_split_relese, create_train_test_split_ratio
#############to repeat the expermints:
import os
from keras import backend as K
import tensorflow as tf
#seed = ... | 4,306 | 32.387597 | 163 | py |
DDI_prediction | DDI_prediction-master/d2d_predict.py | import keras.backend as K
import numpy
import pandas as pd
import random
import networkx as nx
#import matplotlib.pyplot as plt
import numpy as np
from keras.layers import Embedding, Flatten, Add, Conv2D, Reshape, Conv1D
import xgboost as xgb
from keras.models import Model
from keras.layers import Input, Dense, Dropou... | 33,995 | 47.221277 | 231 | py |
DDI_prediction | DDI_prediction-master/Zhang DDI Prediction/Zhang_DDI_prediction_experiment.py | # in this program,we want to write object-oriented codes,and enhance the extension.
from d2d_predict import drugs_nn_predictor, drugs_xgboost_predictor, drugs_tanimoto_predictor
__author__ = 'zhang'
from pylab import *
import networkx as nx
import math
from numpy.linalg import inv
from sklearn.metrics import precision... | 33,691 | 47.828986 | 219 | py |
backdoor_learning_curves | backdoor_learning_curves-master/incremental.py | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import warnings
warnings.filterwarnings("ignore")
from sklearn.metrics.pairwise import pairwise_kernels
from src.utilities.data import load_mnist
from src.utilities.plot.settings import *
from secml.ml.classifiers import CClassifierSVM, CClassifierLogistic, CClassifie... | 28,354 | 31.221591 | 107 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/test/explain_cifar10.py | import sys
sys.path.extend(["./"])
import warnings
warnings.filterwarnings("ignore")
from secml.ml.classifiers import CClassifierPyTorch
from src.utilities.data import load_bin_cifar
import torch
from torchvision import models
from src.classifiers.model.pretrained import PretrainedNet
from secml.ml.classifiers import... | 3,624 | 26.462121 | 84 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/test/explain_imagenette.py | import sys
sys.path.extend(["./"])
import warnings
warnings.filterwarnings("ignore")
from secml.ml.classifiers import CClassifierPyTorch
from src.utilities.data import load_bin_imagenette
import torch
from torchvision import models
from src.classifiers.model.pretrained import PretrainedNet
from secml.ml.features.norm... | 4,206 | 27.815068 | 97 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/utilities/attack.py | from typing import Callable
import numpy as np
from secml.data import CDataset
from secml.ml import CClassifier, CNormalizerDNN
from secml.ml.peval.metrics import CMetric, CMetricAccuracy
from src.utilities.metrics import eval_performance
from src.utilities.data import data_append
from secml.array import CArray
from to... | 2,156 | 29.380282 | 87 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/utilities/data.py | from typing import Union, Tuple, List
from numpy import ndarray
import torch
from torchvision.datasets import ImageFolder
from torchvision import transforms
from secml.data.splitter import CTrainTestSplit
from secml.ml.features import CNormalizerMinMax
from secml.data import CDataset
from secml.data.loader import CDa... | 6,693 | 29.427273 | 94 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/experiments/nn/backdoor_slope.py | import sys
sys.path.extend(["./"])
import warnings
warnings.filterwarnings("ignore")
from src.classifiers.model.incremental_torch_trainer import (
CIncrementalClassifierPytorch,
)
from src.utilities.data import load_imagenette, set_seeds
import torch
from torchvision import models
from secml.ml.features.normaliza... | 6,198 | 31.973404 | 95 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/experiments/binary/test_slope_imagenette.py | import sys
print("updated")
sys.path.extend(["./"])
from src.utilities.data import load_bin_imagenette
from secml.ml.classifiers import CClassifierPyTorch
from src.experiments.binary.slope_utilities import test_poison_slope
from src.experiments.binary.arguments import input_args
from src.classifiers.model.pretrained ... | 3,345 | 29.144144 | 88 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/experiments/binary/test_slope_cifar.py | import sys
print("updated")
sys.path.extend(["./"])
from src.utilities.data import load_bin_cifar
from secml.ml.classifiers import CClassifierPyTorch
from src.experiments.binary.slope_utilities import test_poison_slope
from src.experiments.binary.arguments import input_args
from src.classifiers.model.pretrained impor... | 3,061 | 29.019608 | 83 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/classifiers/model/modules.py | import torch.nn as nn
class Reshape(nn.Module):
def __init__(self, shape):
super(Reshape, self).__init__()
self.shape = shape
def forward(self, x):
k, n, m = self.shape
return x.view(-1, k, n, m)
class DNNExtractor(nn.Module):
def forward(self, x):
ft = self.feat... | 439 | 19 | 39 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/classifiers/model/pretrained.py | import torch.nn as nn
from src.classifiers.model.modules import DNNExtractor
from src.classifiers.model.modules import Reshape
import torch
class PretrainedNet(DNNExtractor):
def __init__(self, model: nn.Module, in_shape=(1, 224, 224), n_classes=10):
super(PretrainedNet, self).__init__()
# change... | 1,088 | 32 | 79 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/classifiers/model/incremental_torch_trainer.py | from secml.ml import CClassifierPyTorch
from functools import reduce
import torch
from torch.nn import CrossEntropyLoss
import matplotlib.pyplot as plt
_loss = CrossEntropyLoss()
class CIncrementalClassifierPytorch(CClassifierPyTorch):
def __init__(
self,
model,
beta=1,
loss=_loss... | 4,084 | 32.211382 | 93 | py |
backdoor_learning_curves | backdoor_learning_curves-master/src/classifiers/model/alexnet.py | import torch
import torch.nn as nn
class AlexNet(nn.Module):
def __init__(self, num_classes: int = 1000, dropout: float = 0.5) -> None:
super().__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2),
nn.ReLU(inplace=True),
... | 1,404 | 34.125 | 78 | py |
Unified-Gesture-and-Fingertip-Detection | Unified-Gesture-and-Fingertip-Detection-master/train.py | from math import ceil
import tensorflow as tf
from net.network import model
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.callbacks import ModelCheckpoint
from generator import train_generator, valid_generator
def loss_function_1(y_true, y_pred):
""" Probabilistic output loss """
a = tf.c... | 2,107 | 34.133333 | 113 | py |
Unified-Gesture-and-Fingertip-Detection | Unified-Gesture-and-Fingertip-Detection-master/net/network.py | from tensorflow.keras.models import Model
from tensorflow.keras.applications import VGG16
from tensorflow.keras.layers import Conv2D, Flatten, Dense, Dropout, Reshape, UpSampling2D, Activation
def model():
vgg = VGG16(include_top=False, input_shape=(128, 128, 3))
x = vgg.output
y = x
x = Flatten()(x)... | 847 | 29.285714 | 102 | py |
Unified-Gesture-and-Fingertip-Detection | Unified-Gesture-and-Fingertip-Detection-master/hand_detector/solo/solo_net.py | from tensorflow.keras.models import Model
from tensorflow.keras.applications import VGG16
from tensorflow.keras.layers import Conv2D, Reshape
def model():
model = VGG16(include_top=False, input_shape=(416, 416, 3))
x = model.output
x = Conv2D(1, (1, 1), activation='sigmoid')(x)
output = Reshape((13, 1... | 467 | 25 | 63 | py |
Unified-Gesture-and-Fingertip-Detection | Unified-Gesture-and-Fingertip-Detection-master/hand_detector/solo/train.py | import os
from math import floor
from tensorflow.keras.optimizers import Adam
from hand_detector.solo.solo_net import model
from tensorflow.keras.callbacks import ModelCheckpoint
from hand_detector.solo.generator import train_generator
# create model
model = model()
model.summary()
# compile
adam = Adam(lr=1e-5)
mode... | 1,092 | 30.228571 | 113 | py |
Unified-Gesture-and-Fingertip-Detection | Unified-Gesture-and-Fingertip-Detection-master/hand_detector/yolo/train.py | from math import ceil
import tensorflow as tf
from hand_detector.yolo.darknet import model
from tensorflow.keras.optimizers import Adam
from hand_detector.yolo.utils.info import data_info
from tensorflow.keras.callbacks import ModelCheckpoint
from hand_detector.yolo.generator import train_generator, valid_generator
d... | 1,981 | 37.862745 | 108 | py |
Unified-Gesture-and-Fingertip-Detection | Unified-Gesture-and-Fingertip-Detection-master/hand_detector/yolo/darknet.py | from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, Conv2D, MaxPooling2D, BatchNormalization, Activation
def conv_batch_norm_relu(x, n_filters, f, padding='same', activation='relu'):
x = Conv2D(n_filters, f, padding=padding)(x)
x = BatchNormalization()(x)
x = Activation(ac... | 2,379 | 44.769231 | 95 | py |
crossover-sgd | crossover-sgd-master/imagenet_native_test.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 4,274 | 24.446429 | 130 | py |
crossover-sgd | crossover-sgd-master/imagenet_test.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 33,012 | 36.345023 | 351 | py |
crossover-sgd | crossover-sgd-master/imagenet_test_no_group_no_seg.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 32,322 | 36.110218 | 357 | py |
crossover-sgd | crossover-sgd-master/crossover_test.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 35,312 | 37.635667 | 286 | py |
crossover-sgd | crossover-sgd-master/imagenet_test_no_fa_no_seg.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 32,450 | 36.129291 | 359 | py |
crossover-sgd | crossover-sgd-master/imagenet_test_no_group_no_fairness.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 32,458 | 36.180985 | 363 | py |
crossover-sgd | crossover-sgd-master/test_pytorch.py | import torch
import sys
print('__Python VERSION:', sys.version)
print('__pyTorch VERSION:', torch.__version__)
print('__CUDA VERSION')
# call(["nvcc", "--version"]) does not work
print('__Number CUDA Devices:', torch.cuda.device_count())
print('__Devices')
print('Active CUDA Device: GPU', torch.cuda.current_device())
... | 435 | 35.333333 | 61 | py |
crossover-sgd | crossover-sgd-master/resnet.py | '''
Properly implemented ResNet-s for CIFAR10 as described in paper [1].
The implementation and structure of this file is hugely influenced by [2]
which is implemented for ImageNet and doesn't have option A for identity.
Moreover, most of the implementations on the web is copy-paste from
torchvision's resnet and has wr... | 4,995 | 31.653595 | 120 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.