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 |
|---|---|---|---|---|---|---|
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/models/esrgan/RRDBNet_arch.py | import functools
import torch
import torch.nn as nn
import torch.nn.functional as F
def make_layer(block, n_layers):
layers = []
for _ in range(n_layers):
layers.append(block())
return nn.Sequential(*layers)
class ResidualDenseBlock_5C(nn.Module):
def __init__(self, nf=64, gc=32, bias=True):... | 3,451 | 43.25641 | 175 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/models/esrgan/srgan_model.py | import torch
from collections import OrderedDict
from archs.esrgan import build_network
from losses.esrgan import build_loss
from utils.esrgan import get_root_logger
from utils.esrgan.registry import MODEL_REGISTRY
from .sr_model import SRModel
@MODEL_REGISTRY.register()
class SRGANModel(SRModel):
"""SRGAN model... | 5,589 | 38.090909 | 119 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/models/liif/rcan.py | import math
from argparse import Namespace
import torch
import torch.nn as nn
from models.liif.models import register
def default_conv(in_channels, out_channels, kernel_size, bias=True):
return nn.Conv2d(
in_channels, out_channels, kernel_size,
padding=(kernel_size//2), bias=bias)
class MeanShi... | 7,084 | 33.730392 | 116 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/models/liif/liif.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from models.liif.models import register
from models.liif import models
from utils.utils_liif import make_coord
@register('liif')
class LIIF(nn.Module):
def __init__(self, encoder_spec, imnet_spec=None,
local_ensemble=True, feat_... | 3,928 | 33.165217 | 82 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/models/liif/rdn.py | from argparse import Namespace
import torch
import torch.nn as nn
from models.liif.models import register
class RDB_Conv(nn.Module):
def __init__(self, inChannels, growRate, kSize=3):
super(RDB_Conv, self).__init__()
Cin = inChannels
G = growRate
self.conv = nn.Sequential(*[
... | 3,689 | 28.758065 | 90 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/models/liif/mlp.py | import torch.nn as nn
from models.liif.models import register
@register('mlp')
class MLP(nn.Module):
def __init__(self, in_dim, out_dim, hidden_list):
super().__init__()
layers = []
lastv = in_dim
for hidden in hidden_list:
layers.append(nn.Linear(lastv, hidden))
... | 612 | 25.652174 | 53 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/models/liif/misc.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import models
from models.liif.models import register
from utils.utils_liif import make_coord
@register('metasr')
class MetaSR(nn.Module):
def __init__(self, encoder_spec):
super().__init__()
self.encoder = models.make(encoder_s... | 2,325 | 32.228571 | 78 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/models/liif/edsr.py | import math
from argparse import Namespace
import torch
import torch.nn as nn
import torch.nn.functional as F
from models.liif.models import register
def default_conv(in_channels, out_channels, kernel_size, bias=True):
return nn.Conv2d(
in_channels, out_channels, kernel_size,
padding=(kernel_siz... | 6,408 | 31.20603 | 95 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/msrn/msrn.py | import kornia
import numpy as np
from tqdm import tqdm
import torch
from torch import nn
from torch.utils import data
import torch.nn.functional as F
import math
import os
import cv2
import sys
import rasterio
def save_tif(path_out_samples, fname, res, target_resolution=0.7,
name=None, name_id='MSRN07',
... | 13,217 | 29.109339 | 122 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/datasets/liif/wrappers.py | import os
import functools
import random
import math
import kornia
from PIL import Image
import numpy as np
import torch
from torch.utils.data import Dataset
from torchvision import transforms
from torchvision.utils import save_image
from datasets.liif.datasets import register
from utils.utils_liif import to_pixel_sa... | 7,406 | 30.519149 | 104 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/datasets/liif/image_folder.py | import os
import json
from PIL import Image
import pickle
import imageio
import numpy as np
import torch
from torch.utils.data import Dataset
from torchvision import transforms
from datasets.liif.datasets import register
@register('image-folder')
class ImageFolder(Dataset):
def __init__(self, root_path, split_f... | 2,780 | 29.9 | 80 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/utils/utils_liif.py | import os
import time
import shutil
import math
import cv2
import torch
import numpy as np
from torch.optim import SGD, Adam
from tensorboardX import SummaryWriter
class Averager():
def __init__(self):
self.n = 0.0
self.v = 0.0
def add(self, v, n=1.0):
self.v = (self.v * self.n + v ... | 4,495 | 24.40113 | 85 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/utils/utils_fsrcnn.py | import torch
import numpy as np
import cv2
import os
import shutil
import time
from tensorboardX import SummaryWriter
def calc_patch_size(func):
def wrapper(args):
if args.scale == 2:
args.patch_size = 10
elif args.scale == 3:
args.patch_size = 7
elif args.scale == ... | 5,291 | 27.918033 | 114 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/utils/esrgan/test_paired_image_dataset.py | import math
import os
import torchvision.utils
from datasets.esrgan import build_dataloader, build_dataset
def test_datasets():
"""Test paired image dataset.
Args:
mode: There are three modes: 'lmdb', 'folder', 'meta_info_file'.
"""
opt = {}
opt['dist'] = False
opt['phase'] = 'train'
... | 1,580 | 26.736842 | 108 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/utils/esrgan/misc.py | import numpy as np
import os
import random
import time
import torch
from os import path as osp
from .dist_util import master_only
from .logger import get_root_logger
def set_random_seed(seed):
"""Set random seeds."""
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual... | 4,355 | 33.03125 | 115 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/utils/esrgan/logger.py | import datetime
import logging
import time
from .dist_util import get_dist_info, master_only
class MessageLogger():
"""Message logger for printing.
Args:
opt (dict): Config. It contains the following keys:
name (str): Exp name.
logger (dict): Contains 'print_freq' (str) for lo... | 6,080 | 36.306748 | 112 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/utils/esrgan/img_util.py | import cv2
import math
import numpy as np
import os
import torch
from torchvision.utils import make_grid
def img2tensor(imgs, bgr2rgb=True, float32=True):
"""Numpy array to tensor.
Args:
imgs (list[ndarray] | ndarray): Input images.
bgr2rgb (bool): Whether to change bgr to rgb.
float32... | 6,121 | 37.746835 | 116 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/utils/esrgan/matlab_functions.py | import math
import numpy as np
import torch
def cubic(x):
"""cubic function used for calculate_weights_indices."""
absx = torch.abs(x)
absx2 = absx**2
absx3 = absx**3
return (1.5 * absx3 - 2.5 * absx2 + 1) * (
(absx <= 1).type_as(absx)) + (-0.5 * absx3 + 2.5 * absx2 - 4 * absx + 2) * (((ab... | 13,496 | 41.046729 | 118 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/utils/esrgan/dist_util.py | import functools
import os
import subprocess
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
def init_dist(launcher, backend='nccl', **kwargs):
if mp.get_start_method(allow_none=True) is None:
mp.set_start_method('spawn')
if launcher == 'pytorch':
_init_dist_py... | 2,502 | 30.683544 | 81 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/archs/esrgan/discriminator_arch.py | from torch import nn as nn
from utils.esrgan.registry import ARCH_REGISTRY
@ARCH_REGISTRY.register()
class VGGStyleDiscriminator128(nn.Module):
"""VGG style discriminator with input size 128 x 128.
It is used to train SRGAN and ESRGAN.
Args:
num_in_ch (int): Channel number of inputs. Default: 3.
... | 3,381 | 44.702703 | 110 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/archs/esrgan/vgg_arch.py | import os
import torch
from collections import OrderedDict
from torch import nn as nn
from torchvision.models import vgg as vgg
from utils.esrgan.registry import ARCH_REGISTRY
VGG_PRETRAIN_PATH = 'experiments/pretrained_models/vgg19-dcbb9e9d.pth'
NAMES = {
'vgg11': [
'conv1_1', 'relu1_1', 'pool1', 'conv2_... | 6,329 | 38.31677 | 115 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/archs/esrgan/rrdbnet_arch.py | import torch
torch.cuda.empty_cache()
from torch import nn as nn
from torch.nn import functional as F
from utils.esrgan.registry import ARCH_REGISTRY
from .arch_util import default_init_weights, make_layer
class ResidualDenseBlock(nn.Module):
"""Residual Dense Block.
Used in RRDB block in ESRGAN.
Args:
... | 4,060 | 40.020202 | 95 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/archs/esrgan/arch_util.py | import math
import torch
from torch import nn as nn
from torch.nn import functional as F
from torch.nn import init as init
from torch.nn.modules.batchnorm import _BatchNorm
from ops.esrgan import ModulatedDeformConvPack, modulated_deform_conv
from utils.esrgan import get_root_logger
@torch.no_grad()
def default_init... | 8,231 | 37.647887 | 119 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/ops/esrgan/deform_conv.py | import math
import torch
from torch import nn as nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn import functional as F
from torch.nn.modules.utils import _pair, _single
try:
from . import deform_conv_ext
except ImportError:
import os
BASICSR_JIT... | 15,571 | 40.525333 | 120 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/losses/esrgan/losses.py | import math
import torch
from torch import autograd as autograd
from torch import nn as nn
from torch.nn import functional as F
from archs.esrgan.vgg_arch import VGGFeatureExtractor
from utils.esrgan.registry import LOSS_REGISTRY
from .loss_util import weighted_loss
_reduction_modes = ['none', 'mean', 'sum']
@weigh... | 15,276 | 37.002488 | 120 | py |
iquaflow-sisr-use-case | iquaflow-sisr-use-case-main/losses/esrgan/loss_util.py | import functools
from torch.nn import functional as F
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are 'none', 'mean' and 'sum'.
Returns:
Tensor: Reduced loss tensor.
"""
reduction_enum... | 2,893 | 32.651163 | 78 | py |
GlowIP | GlowIP-master/train_dcgan.py | # the code for DCGAN was sourced from https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html
import os
import random
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
import torch.utils.data
import torchvision.datasets as dset
import t... | 6,181 | 36.017964 | 118 | py |
GlowIP | GlowIP-master/train_glow.py | import torch
from torchvision import datasets
import torchvision.transforms as transforms
from torchvision.utils import make_grid
from glow.glow import Glow
import numpy as np
import skimage.io as sio
import matplotlib.pyplot as plt
import os
import json
import argparse
import re
from collections import defaultdict
d... | 9,639 | 46.960199 | 165 | py |
GlowIP | GlowIP-master/dcgan/dcgan.py | # the code for DCGAN was sourced from https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.htmlimport torch.nn as nn
import torch.nn as nn
nc = 3
nz = 100
ngf = 64
ndf = 64
class Generator(nn.Module):
def __init__(self, ngpu):
super(Generator, self).__init__()
self.ngpu = ngpu
self... | 2,636 | 34.16 | 123 | py |
GlowIP | GlowIP-master/solvers/cs.py | import numpy as np
import torch
from torchvision import datasets
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
from skimage.measure import compare_psnr, compare_ssim
from skimage.transform import resize
import PIL
import skimage.io as sio
from glow.glow import Glow
from dcgan.dcgan import ... | 30,063 | 49.442953 | 164 | py |
GlowIP | GlowIP-master/solvers/inpainter.py | import numpy as np
import torch
from torchvision import datasets
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
from skimage.measure import compare_psnr, compare_ssim
import skimage.io as sio
from glow.glow import Glow
from dcgan.dcgan import Generator
import json
import os
import warnings
... | 21,413 | 46.376106 | 164 | py |
GlowIP | GlowIP-master/solvers/denoiser.py | import numpy as np
import torch
from torchvision import datasets
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
from skimage.measure import compare_psnr, compare_ssim
import skimage.io as sio
from glow.glow import Glow
from dcgan.dcgan import Generator
import json
import os
import warnings
... | 16,362 | 45.751429 | 164 | py |
GlowIP | GlowIP-master/plots/plot_utils.py | import torch
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from mpl_toolkits.mplot3d import Axes3D
def histZNoisy(noise_std, max_images, glow, dataloader,batch_size,size):
z_norm = {"clean":[],"noisy":[]}
n_images = 0
with torch.no_grad():
for i, dat... | 20,850 | 39.964637 | 123 | py |
GlowIP | GlowIP-master/glow/squeeze.py | import torch
import torch.nn as nn
import numpy as np
# device
if torch.cuda.is_available():
device = "cuda"
else:
device = "cpu"
class Squeeze(nn.Module):
def __init__(self, factor, contiguous=False):
super(Squeeze, self).__init__()
self.factor = factor
self.conti... | 2,755 | 36.753425 | 132 | py |
GlowIP | GlowIP-master/glow/split.py | import torch
import torch.nn as nn
# device
if torch.cuda.is_available():
device = "cuda"
else:
device = "cpu"
class Split(nn.Module):
def __init__(self):
super(Split, self).__init__()
def forward(self, x, y = None, reverse=False):
n,c,h,w = x.size()
if not reverse:... | 885 | 20.609756 | 77 | py |
GlowIP | GlowIP-master/glow/invertible_conv.py | import torch
import torch.nn as nn
import numpy as np
from torch.nn import functional as F
# device
if torch.cuda.is_available():
device = "cuda"
else:
device = "cpu"
class InvertibleConvolution(nn.Module):
def __init__(self, channels, device, ):
super(InvertibleConvolution, self).__init__()
... | 2,772 | 35.012987 | 105 | py |
GlowIP | GlowIP-master/glow/flow.py | import torch
import torch.nn as nn
import numpy as np
from .actnorm import ActNorm
from .invertible_conv import InvertibleConvolution
from .coupling import CouplingLayer
# device
if torch.cuda.is_available():
device = "cuda"
else:
device = "cpu"
class Flow(nn.Module):
def __init__(self, channels, coupli... | 3,582 | 44.35443 | 100 | py |
GlowIP | GlowIP-master/glow/actnorm.py | import torch
import torch.nn as nn
import numpy as np
# device
if torch.cuda.is_available():
device = "cuda"
else:
device = "cpu"
class ActNorm(nn.Module):
def __init__(self, channels,device):
super(ActNorm, self).__init__()
size = (1,channels,1,1)
self.logs = torch.n... | 4,506 | 46.442105 | 192 | py |
GlowIP | GlowIP-master/glow/glow.py | import torch
import torch.nn as nn
from .flow import Flow
from .squeeze import Squeeze
from .split import Split
import numpy as np
import skimage.io as sio
from skimage.transform import resize
import torch.utils.checkpoint as checkpoint
# device
if torch.cuda.is_available():
device = "cuda"
else:
device = "cpu... | 7,969 | 38.455446 | 107 | py |
GlowIP | GlowIP-master/glow/net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from .actnorm import ActNorm
# device
if torch.cuda.is_available():
device = "cuda"
else:
device = "cpu"
class NN(nn.Module):
def __init__(self, channels_in, channels_out, device, init_last_zeros=False):
s... | 2,486 | 30.481013 | 106 | py |
GlowIP | GlowIP-master/glow/coupling.py | import torch
import torch.nn as nn
import numpy as np
from .net import NN
# device
if torch.cuda.is_available():
device = "cuda"
else:
device = "cpu"
class CouplingLayer(nn.Module):
def __init__(self, channels, coupling, coupling_bias, device, nn_init_last_zeros=False):
super(CouplingLayer, self)... | 5,243 | 46.672727 | 114 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/threadpoolctl.py | """threadpoolctl
This module provides utilities to introspect native libraries that relies on
thread pools (notably BLAS and OpenMP implementations) and dynamically set the
maximal number of threads they can use.
"""
# License: BSD 3-Clause
# The code to introspect dynamically loaded libraries on POSIX systems is
# a... | 30,647 | 37.454203 | 86 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/tqdm/keras.py | from __future__ import absolute_import, division
from .auto import tqdm as tqdm_auto
from copy import copy
from functools import partial
try:
import keras
except ImportError as e:
try:
from tensorflow import keras
except ImportError:
raise e
__author__ = {"github.com/": ["casperdcl"]}
__all_... | 4,208 | 34.369748 | 81 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/arcade/experimental/light_demo.py | import math
import traceback
import arcade
from arcade.experimental.lights import Light, LightLayer
# Do the math to figure out our screen dimensions
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
SCREEN_TITLE = "Lighting Demo (Experimental)"
class MyGame(arcade.Window):
def __init__(self, width, height, title):
... | 3,189 | 36.529412 | 103 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/arcade/resources/__init__.py | from typing import Union
from pathlib import Path
from . import shaders
#: The absolute path to this directory
RESOURCE_PATH = Path(__file__).parent.absolute()
def resolve_resource_path(path: Union[str, Path]) -> Path:
"""Resolves a resource path and returns a Path object.
:param Union[str, Path] path: A Pa... | 32,185 | 66.902954 | 119 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/numpy/random/tests/test_generator_mt19937.py | import sys
import hashlib
import pytest
import numpy as np
from numpy.linalg import LinAlgError
from numpy.testing import (
assert_, assert_raises, assert_equal, assert_allclose,
assert_warns, assert_no_warnings, assert_array_equal,
assert_array_almost_equal, suppress_warnings)
from numpy.random import G... | 102,771 | 40.930641 | 90 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/numpy/ma/tests/test_core.py | # pylint: disable-msg=W0400,W0511,W0611,W0612,W0614,R0201,E1102
"""Tests suite for MaskedArray & subclassing.
:author: Pierre Gerard-Marchant
:contact: pierregm_at_uga_dot_edu
"""
__author__ = "Pierre GF Gerard-Marchant"
import sys
import warnings
import operator
import itertools
import textwrap
import pytest
from f... | 199,164 | 36.677828 | 86 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/scipy/linalg/basic.py | #
# Author: Pearu Peterson, March 2002
#
# w/ additions by Travis Oliphant, March 2002
# and Jake Vanderplas, August 2012
from warnings import warn
import numpy as np
from numpy import atleast_1d, atleast_2d
from .flinalg import get_flinalg_funcs
from .lapack import get_lapack_funcs, _compute_lwork
from .... | 64,903 | 34.427948 | 79 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/spacy/_ml.py | # coding: utf8
from __future__ import unicode_literals
import numpy
import warnings
from thinc.v2v import Model, Maxout, Softmax, Affine, ReLu
from thinc.t2t import ExtractWindow, ParametricAttention
from thinc.t2v import Pooling, sum_pool, mean_pool
from thinc.i2v import HashEmbed
from thinc.misc import Residual, Fea... | 33,293 | 32.128358 | 94 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/spacy/lang/id/_tokenizer_exceptions_list.py | # coding: utf8
from __future__ import unicode_literals
ID_BASE_EXCEPTIONS = set(
"""
aba-aba
abah-abah
abal-abal
abang-abang
abar-abar
abong-abong
abrit-abrit
abrit-abritan
abu-abu
abuh-abuhan
abuk-abuk
abun-abun
acak-acak
acak-acakan
acang-acang
acap-acap
aci-aci
aci-acian
aci-acinya
aco-acoan
ad-blocker
ad-inter... | 53,655 | 12.736815 | 39 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/spacy/lang/fr/_tokenizer_exceptions_list.py | # coding: utf8
from __future__ import unicode_literals
FR_BASE_EXCEPTIONS = [
"(+)-amphétamine",
"(5R,6S)-7,8-didehydro-4,5-époxy-3-méthoxy-N-méthylmorphinan-6-ol",
"(R)-amphétamine",
"(S)-amphétamine",
"(−)-amphétamine",
"0-day",
"0-days",
"1,1-diméthylhydrazine",
"1,2,3-tris-nitro... | 354,419 | 21.669822 | 74 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/spacy/ml/tok2vec.py | from __future__ import unicode_literals
from thinc.api import chain, layerize, clone, concatenate, with_flatten, uniqued
from thinc.api import noop, with_square_sequences
from thinc.v2v import Maxout, Model
from thinc.i2v import HashEmbed, StaticVectors
from thinc.t2t import ExtractWindow
from thinc.misc import Residu... | 5,862 | 32.124294 | 87 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/spacy/displacy/__init__.py | # coding: utf8
"""
spaCy's built in visualization suite for dependencies and named entities.
DOCS: https://spacy.io/api/top-level#displacy
USAGE: https://spacy.io/usage/visualizers
"""
from __future__ import unicode_literals
import warnings
from .render import DependencyRenderer, EntityRenderer
from ..tokens import ... | 7,587 | 33.967742 | 88 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/sklearn/ensemble/_hist_gradient_boosting/tests/test_monotonic_contraints.py | import numpy as np
import pytest
from sklearn.ensemble._hist_gradient_boosting.grower import TreeGrower
from sklearn.ensemble._hist_gradient_boosting.common import G_H_DTYPE
from sklearn.ensemble._hist_gradient_boosting.common import X_BINNED_DTYPE
from sklearn.ensemble._hist_gradient_boosting.common import MonotonicC... | 14,424 | 40.451149 | 79 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/rates.py | # coding: utf8
"""Generators that provide different rates, schedules, decays or series."""
from __future__ import unicode_literals, division
import numpy
from ._registry import registry
@registry.schedules.register("constant_then.v1")
def constant_then(rate, steps, schedule):
"""Yield a constant rate for N steps,... | 3,613 | 26.8 | 104 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/tests/unit/test_pytorch_wrapper.py | # coding: utf8
from __future__ import unicode_literals
from thinc.v2v import Affine
from thinc.neural.optimizers import SGD
import numpy
try:
import torch.nn
from thinc.extra.wrappers import PyTorchWrapper
except ImportError:
PyTorchWrapper = None
def check_learns_zero_output(model, sgd, X, Y):
"""C... | 1,559 | 27.888889 | 59 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/extra/wrappers.py | # coding: utf8
from __future__ import unicode_literals
import contextlib
from ..compat import BytesIO
from ..neural._classes.model import Model
try:
import cupy
except ImportError:
cupy = None
try:
import torch.autograd
import torch.optim
import torch
import torch.utils.dlpack
from torch.... | 7,493 | 32.909502 | 86 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/extra/datasets.py | # coding: utf8
from __future__ import unicode_literals
import random # pragma: no cover
import io # pragma: no cover
from collections import Counter # pragma: no cover
import os.path # pragma: no cover
import csv # pragma: no cover
import numpy
import json
import sys
from srsly import cloudpickle as pickle
from p... | 8,352 | 30.760456 | 87 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/extra/_vendorized/keras_datasets.py | # https://raw.githubusercontent.com/fchollet/keras/master/keras/datasets/mnist.py
# Copyright Francois Chollet, Google, others (2015)
# Under MIT license
import gzip
import sys
import numpy as np
from .keras_data_utils import get_file
try:
import cPickle
except:
import pickle as cPickle
def load_mnist(path... | 3,962 | 28.574627 | 88 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/extra/_vendorized/keras_data_utils.py | # https://raw.githubusercontent.com/fchollet/keras/master/keras/utils/data_utils.py
# Copyright Francois Chollet, Google, others (2015)
# Under MIT license
from __future__ import absolute_import
from __future__ import print_function
import tarfile
import zipfile
import os
import sys
import shutil
import hashlib
from ... | 5,452 | 31.076471 | 110 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/extra/_vendorized/keras_generic_utils.py | # https://raw.githubusercontent.com/fchollet/keras/master/keras/utils/data_utils.py
# Copyright Francois Chollet, Google, others (2015)
# Under MIT license
from __future__ import absolute_import
import numpy as np
import time
import sys
import marshal
import types as python_types
from ...compat import string_types
d... | 6,387 | 32.445026 | 84 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/neural/util.py | # coding: utf8
from __future__ import print_function, unicode_literals
import numpy
from pathlib import Path
import itertools
try:
import cupy
from cupy import get_array_module
except ImportError:
cupy = None
get_array_module = lambda _: numpy
try:
basestring
except NameError:
basestring = s... | 4,528 | 23.481081 | 87 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/neural/_lsuv.py | # coding: utf8
from __future__ import unicode_literals
import numpy as np
from .util import copy_array
# Layer-sequential Unit Variance initialization, by
# https://github.com/ducha-aiki/LSUV-keras/blob/master/lsuv_init.py
# Orthonorm init code is taken from Lasagne
# https://github.com/Lasagne/Lasagne/blob/master/... | 1,608 | 27.22807 | 76 | py |
LTPAL | LTPAL-master/ltpal/Lib/site-packages/thinc/neural/_classes/encoder_decoder.py | # coding: utf8
from __future__ import unicode_literals, print_function
from .model import Model
from ...api import chain, clone, with_getitem, wrap, with_reshape
from .softmax import Softmax
from .relu import ReLu
from .layernorm import LayerNorm
from .maxout import Maxout
from .resnet import Residual
from .affine impo... | 6,108 | 34.935294 | 84 | py |
HQM | HQM-main/main.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 16,564 | 45.926346 | 139 | py |
HQM | HQM-main/engine.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 14,996 | 44.308157 | 124 | py |
HQM | HQM-main/models/detr.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 18,131 | 45.852713 | 115 | py |
HQM | HQM-main/models/hard_mask_att_each.py | import torch
from torch.nn.functional import linear, pad
from torch import Tensor
from torch.nn import MultiheadAttention
from typing import Optional, Tuple, List
import warnings
def multi_head_attention_forward(
query: Tensor,
key: Tensor,
... | 19,155 | 51.482192 | 159 | py |
HQM | HQM-main/models/matcher.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 42,956 | 51.643382 | 120 | py |
HQM | HQM-main/models/segmentation.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 15,977 | 42.183784 | 120 | py |
HQM | HQM-main/models/position_encoding.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 3,751 | 38.083333 | 103 | py |
HQM | HQM-main/models/hard_mask_att_each_p.py | import torch
from torch.nn.functional import linear, pad
from torch import Tensor
from torch.nn import MultiheadAttention
from typing import Optional, Tuple, List
import warnings
def multi_head_attention_forward(
query: Tensor,
key: Tensor,
... | 18,772 | 51.438547 | 159 | py |
HQM | HQM-main/models/backbone.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 4,852 | 37.515873 | 113 | py |
HQM | HQM-main/models/hard_mask_img.py | import torch
from torch.nn.functional import linear, pad
from torch import Tensor
from torch.nn import MultiheadAttention
from typing import Optional, Tuple, List
import warnings
def multi_head_attention_forward(
query: Tensor,
key: Tensor,
... | 18,286 | 51.398281 | 123 | py |
HQM | HQM-main/models/transformer.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 622,784 | 49.079206 | 132 | py |
HQM | HQM-main/models/hard_mask_att.py | import torch
from torch.nn.functional import linear, pad
from torch import Tensor
from torch.nn import MultiheadAttention
from typing import Optional, Tuple, List
import warnings
def multi_head_attention_forward(
query: Tensor,
key: Tensor,
... | 18,733 | 51.623596 | 135 | py |
HQM | HQM-main/models/guass_mask_att.py | import torch
from torch._overrides import has_torch_function, handle_torch_function
from torch.nn.functional import linear, pad, softmax, dropout
Tensor = torch.Tensor
def multi_head_attention_forward_gaussian(query, # type: Tensor
key, # type: Tensor
... | 13,551 | 47.924188 | 115 | py |
HQM | HQM-main/models/hoi.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
from scipy.optimize import linear_sum_assign... | 18,606 | 44.94321 | 130 | py |
HQM | HQM-main/models/hard_mask_att_each2.py | import torch
from torch.nn.functional import linear, pad
from torch import Tensor
from torch.nn import MultiheadAttention
from typing import Optional, Tuple, List
import warnings
def multi_head_attention_forward(
query: Tensor,
key: Tensor,
... | 19,353 | 51.167116 | 159 | py |
HQM | HQM-main/models/Hard_Sample/HQM/hoi_HQM.py | import torch, random
from torch import nn
import torch.nn.functional as F
from util.box_ops import box_cxcywh_to_xyxy, generalized_box_iou, box_xyxy_to_cxcywh
from models.backbone import build_backbone
from models.matcher import build_matcher
from models.transformer import build_hoi_transformer_HQM
from util.box_ops i... | 44,058 | 47.845898 | 182 | py |
HQM | HQM-main/models/Hard_Sample/AMM/hoi_hardm_query_att_each_pos.py | import torch
from torch import nn
import torch.nn.functional as F
from util.box_ops import box_cxcywh_to_xyxy, generalized_box_iou, box_xyxy_to_cxcywh
from models.backbone import build_backbone
from models.matcher import build_matcher
from models.transformer import build_hoi_transformer_AMM
from util.box_ops import bo... | 39,299 | 47.04401 | 144 | py |
HQM | HQM-main/models/Hard_Sample/GBS/DN_DETR.py | import torch
from torch import nn
import torch.nn.functional as F
from util.box_ops import box_xyxy_to_cxcywh
from models.backbone import build_backbone
from models.matcher import build_matcher
from models.transformer import build_hoi_transformer_ts_qpos_eobj_attention_map
from util.box_ops import box_cxcywh_to_xyxy,... | 35,189 | 47.271605 | 118 | py |
HQM | HQM-main/models/Hard_Sample/GBS/hoi_share_qpos_ezero_shiftbbox_04_06.py | import torch
from torch import nn
import torch.nn.functional as F
from util.box_ops import box_xyxy_to_cxcywh
from models.backbone import build_backbone
from models.matcher import build_matcher
from models.transformer import build_hoi_transformer_GBS
from util.box_ops import box_cxcywh_to_xyxy, generalized_box_iou
fr... | 35,168 | 47.242798 | 118 | py |
HQM | HQM-main/util/plot_utils.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 4,640 | 42.373832 | 118 | py |
HQM | HQM-main/util/misc.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 14,152 | 31.312785 | 95 | py |
HQM | HQM-main/util/vis_utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
import colorsys
import logging
import numpy as np
from enum import Enum, unique
import cv2
import matplotlib.colors as mplc
import matplotlib.figure as mplfigure
import pycocotools.mask as mask_util
import torch
from matplotlib.backends.backend_agg import FigureCanvasA... | 17,862 | 35.983437 | 101 | py |
HQM | HQM-main/util/box_ops.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 2,976 | 30.336842 | 110 | py |
HQM | HQM-main/datasets/hico.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
"""
HICO detection dataset.
"""
from pathlib... | 9,475 | 40.2 | 118 | py |
HQM | HQM-main/datasets/__init__.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 3,119 | 42.333333 | 74 | py |
HQM | HQM-main/datasets/coco_eval.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 9,150 | 33.662879 | 103 | py |
HQM | HQM-main/datasets/coco_panoptic.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 4,138 | 38.04717 | 111 | py |
HQM | HQM-main/datasets/coco.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 5,668 | 33.357576 | 118 | py |
HQM | HQM-main/datasets/hico_gt.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
"""
HICO detection dataset.
"""
import pickl... | 18,433 | 44.292383 | 121 | py |
HQM | HQM-main/datasets/transforms.py | # ------------------------------------------------------------------------
# Copyright (c) Hitachi, Ltd. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------
# Modified from DETR (https://github.com/fac... | 9,196 | 30.713793 | 104 | py |
HQM | HQM-main/CDN/main.py | import argparse
import time
import datetime
import random
from pathlib import Path
import json
import numpy as np
import torch
from torch.utils.data import DataLoader, DistributedSampler
import datasets
import util.misc as utils
from datasets import build_dataset
from engine import train_one_epoch, evaluate_hoi
from ... | 15,822 | 46.803625 | 132 | py |
HQM | HQM-main/CDN/engine.py | import math
import os
import sys
from typing import Iterable
import numpy as np
import copy
import itertools
import torch
import util.misc as utils
from datasets.hico_eval import HICOEvaluator
from datasets.vcoco_eval import VCOCOEvaluator
def train_one_epoch(model: torch.nn.Module, criterion: torch.nn.Module,
... | 4,711 | 38.932203 | 116 | py |
HQM | HQM-main/CDN/models/matcher.py | import torch
from scipy.optimize import linear_sum_assignment
from torch import nn
from util.box_ops import box_cxcywh_to_xyxy, generalized_box_iou
class HungarianMatcherHOI(nn.Module):
def __init__(self, cost_obj_class: float = 1, cost_verb_class: float = 1, cost_bbox: float = 1,
cost_giou: floa... | 4,013 | 51.12987 | 139 | py |
HQM | HQM-main/CDN/models/position_encoding.py | import math
import torch
from torch import nn
from util.misc import NestedTensor
class PositionEmbeddingSine(nn.Module):
def __init__(self, num_pos_feats=64, temperature=10000, normalize=False, scale=None):
super().__init__()
self.num_pos_feats = num_pos_feats
self.temperature = temperatur... | 2,909 | 36.792208 | 103 | py |
HQM | HQM-main/CDN/models/backbone.py | from collections import OrderedDict
import torch
import torch.nn.functional as F
import torchvision
from torch import nn
from torchvision.models._utils import IntermediateLayerGetter
from typing import Dict, List
from util.misc import NestedTensor, is_main_process
from .position_encoding import build_position_encodi... | 3,916 | 36.663462 | 113 | py |
HQM | HQM-main/CDN/models/hoi.py | from scipy.optimize import linear_sum_assignment
import torch
from torch import nn
import torch.nn.functional as F
from util.box_ops import box_cxcywh_to_xyxy, generalized_box_iou
from util.misc import (NestedTensor, nested_tensor_from_tensor_list,
accuracy, get_world_size, interpolate,
... | 22,948 | 44.806387 | 137 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.