repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
noise2noise | noise2noise-master/download_kodak.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 1,343 | 29.545455 | 95 | py |
noise2noise | noise2noise-master/config.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 8,864 | 39.665138 | 207 | py |
noise2noise | noise2noise-master/util.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 2,129 | 33.918033 | 89 | py |
noise2noise | noise2noise-master/dataset_tool_tf.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 3,115 | 31.8 | 93 | py |
noise2noise | noise2noise-master/dataset_tool_mri.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 7,975 | 42.347826 | 987 | py |
noise2noise | noise2noise-master/train.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 6,718 | 39.969512 | 102 | py |
noise2noise | noise2noise-master/dnnlib/util.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 8,907 | 29.930556 | 151 | py |
noise2noise | noise2noise-master/dnnlib/__init__.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 701 | 35.947368 | 126 | py |
noise2noise | noise2noise-master/dnnlib/tflib/tfutil.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 6,195 | 34.405714 | 130 | py |
noise2noise | noise2noise-master/dnnlib/tflib/autosummary.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 6,945 | 39.858824 | 118 | py |
noise2noise | noise2noise-master/dnnlib/tflib/network.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 22,715 | 45.644764 | 151 | py |
noise2noise | noise2noise-master/dnnlib/tflib/__init__.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 500 | 30.3125 | 76 | py |
noise2noise | noise2noise-master/dnnlib/tflib/optimizer.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 9,828 | 46.028708 | 164 | py |
noise2noise | noise2noise-master/dnnlib/submission/run_context.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 4,766 | 42.336364 | 213 | py |
noise2noise | noise2noise-master/dnnlib/submission/__init__.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 390 | 38.1 | 76 | py |
noise2noise | noise2noise-master/dnnlib/submission/submit.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 11,443 | 37.531987 | 175 | py |
noise2noise | noise2noise-master/dnnlib/submission/_internal/run.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | 1,436 | 33.214286 | 94 | py |
SERT | SERT-master/hside_simu_test.py | import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import os
import argparse
from utility import *
from hsi_setup import Engine, train_options, make_dataset
import time
if __name__ == '__main__':
"""Training settings"""
parser = argpars... | 1,643 | 23.176471 | 72 | py |
SERT | SERT-master/hside_real.py | import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import os
import argparse
from utility import *
import datetime
import time
from hsi_setup import Engine, train_options, make_dataset
#os.environ["WANDB_MODE"] ='offline'
if __name__ == '__main... | 2,369 | 25.333333 | 113 | py |
SERT | SERT-master/hsi_setup.py | from email.mime import base, image
from locale import normalize
from math import fabs
from xml.sax import SAXException
import torch
import torch.optim as optim
import models
import os
import argparse
from os.path import join
from utility import *
from utility.ssim import SSIMLoss,SAMLoss
from thop import profile
from... | 41,464 | 41.835744 | 166 | py |
SERT | SERT-master/hside_simu.py | import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import os
import argparse
from utility import *
import datetime
import time
from hsi_setup import Engine, train_options, make_dataset
import wandb
if __name__ == '__main__':
"""Training sett... | 3,121 | 29.019231 | 170 | py |
SERT | SERT-master/hside_urban.py | import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import os
import argparse
import datetime
from utility import *
from hsi_setup import Engine, train_options, make_dataset
if __name__ == '__main__':
"""Training settings"""
parser = ar... | 3,580 | 29.87069 | 113 | py |
SERT | SERT-master/hside_simu_complex.py | import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import os
import argparse
import datetime
from utility import *
from hsi_setup import Engine, train_options, make_dataset
if __name__ == '__main__':
"""Training settings"""
parser = ar... | 4,281 | 31.938462 | 181 | py |
SERT | SERT-master/hside_urban_test.py | import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import os
import argparse
from utility import *
from hsi_setup import Engine, train_options, make_dataset
if __name__ == '__main__':
"""Training settings"""
parser = argparse.ArgumentP... | 1,535 | 23.774194 | 75 | py |
SERT | SERT-master/hside_real_test.py | import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import os
import argparse
from utility import *
from hsi_setup import Engine, train_options, make_dataset
if __name__ == '__main__':
"""Training settings"""
parser = argparse.ArgumentP... | 1,136 | 23.191489 | 88 | py |
SERT | SERT-master/utility/ssim.py | import torch
import torch.nn.functional as F
def _fspecial_gauss_1d(size, sigma):
r"""Create 1-D gauss kernel
Args:
size (int): the size of gauss kernel
sigma (float): sigma of normal distribution
Returns:
torch.Tensor: 1D kernel
"""
coords = torch.arange(size).to(dtype=to... | 10,533 | 34.829932 | 129 | py |
SERT | SERT-master/utility/lmdb_dataset.py | import torch.utils.data as data
import numpy as np
from PIL import Image
import os
import os.path
class LMDBDataset(data.Dataset):
def __init__(self, db_path, repeat=1):
import lmdb
self.db_path = db_path
self.env = lmdb.open(db_path, max_readers=1, readonly=True, lock=False,
... | 1,605 | 30.490196 | 79 | py |
SERT | SERT-master/utility/load_tif.py | import numpy as np
import os
from torch.utils.data import Dataset
import torch
import torch.nn.functional as F
import random
import scipy.stats as stats
from torch.utils.data import DataLoader
from skimage import io
import cv2
####################i######################################################################... | 7,553 | 36.959799 | 140 | py |
SERT | SERT-master/utility/validation.py | import torch
import torchvision
import random
import cv2
import shutil
try:
from .util import *
except:
from util import *
from torchvision.transforms import Compose, ToPILImage, ToTensor, RandomHorizontalFlip, RandomChoice
from torch.utils.data import DataLoader, Dataset
from torchnet.dataset import Transfor... | 994 | 26.638889 | 100 | py |
SERT | SERT-master/utility/lmdb_data.py | """Create lmdb dataset"""
from util import *
import lmdb
import scipy.io as scio
def create_lmdb_train(
datadir, fns, name, matkey,
crop_sizes, scales, ksizes, strides,
load=h5py.File, augment=True,
seed=2017):
"""
Create Augmented Dataset
"""
def preprocess(data):
new_data = []... | 4,284 | 32.217054 | 105 | py |
SERT | SERT-master/utility/helper.py | import os
import sys
import time
import math
import torch
import torch.nn as nn
import torch.nn.init as init
import datetime
from tensorboardX import SummaryWriter
import socket
import wandb
def adjust_learning_rate(optimizer, lr):
print('Adjust Learning Rate => %.4e' %lr)
for param_group in optimizer.par... | 4,909 | 28.053254 | 126 | py |
SERT | SERT-master/utility/dataset.py | # There are functions for creating a train and validation iterator.
from os import mkdir
import torch
import torchvision
import random
import cv2
try:
from .util import *
except:
from util import *
from torchvision.transforms import Compose, ToPILImage, ToTensor, RandomHorizontalFlip, RandomChoice
from torch... | 21,829 | 33.928 | 140 | py |
SERT | SERT-master/utility/indexes.py | import numpy as np
import torch
from skimage.measure import compare_ssim, compare_psnr
from functools import partial
class Bandwise(object):
def __init__(self, index_fn):
self.index_fn = index_fn
def __call__(self, X, Y):
C = X.shape[-3]
bwindex = []
for ch in range(C):
... | 1,066 | 27.078947 | 121 | py |
SERT | SERT-master/utility/mat_data.py | """generate testing mat dataset"""
import os
import numpy as np
import h5py
from os.path import join, exists
from scipy.io import loadmat, savemat
from util import crop_center, Visualize3D, minmax_normalize
from PIL import Image
def create_mat_dataset(datadir, fnames, newdir, matkey, func=None, load=h5py.File):
i... | 3,241 | 28.743119 | 152 | py |
SERT | SERT-master/utility/util.py | import matplotlib.pyplot as plt
import numpy as np
import torch
import torchvision
import cv2
import h5py
import os
import random
import threading
from itertools import product
from scipy.io import loadmat, savemat
from functools import partial
from scipy.ndimage import zoom
from matplotlib.widgets import Slider
from... | 6,743 | 28.709251 | 175 | py |
SERT | SERT-master/utility/__init__.py | from .dataset import *
from .util import *
from .helper import *
from .lmdb_dataset import LMDBDataset
from .indexes import *
from .load_tif import * | 149 | 24 | 37 | py |
SERT | SERT-master/models/__init__.py | from .sert import SERT
from .competing_methods import *
def sert_base():
net = SERT(inp_channels=31,dim = 96, window_sizes=[16,32,32] , depths=[ 6,6,6], num_heads=[ 6,6,6],split_sizes=[1,2,4],mlp_ratio=2,weight_factor=0.1,memory_blocks=128,down_rank=8) #16,32,32
net.use_2dconv = Tru... | 3,539 | 29.782609 | 220 | py |
SERT | SERT-master/models/sert.py |
from tkinter import W
from turtle import forward
import torch
import torch.nn as nn
import torch.nn.functional as F
from pdb import set_trace as stx
import numbers
from einops import rearrange
import numpy as np
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
def window_partition(x, window_size):... | 17,738 | 34.620482 | 200 | py |
SERT | SERT-master/models/competing_methods/SST.py |
from turtle import forward
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
def window_partition(x, window_size):
"""
Args:
x: (B, H, W, C)
window_size (int): window size
"""
... | 16,392 | 39.376847 | 184 | py |
SERT | SERT-master/models/competing_methods/__init__.py | from .GRNet import U_Net_GR
from .qrnn import QRNNREDC3D
from .T3SC.multilayer import MultilayerModel
from .macnet import MACNet
from .SST import SST | 149 | 29 | 44 | py |
SERT | SERT-master/models/competing_methods/GRNet.py | from re import S
from turtle import forward
from matplotlib.pyplot import sca
from numpy import True_, pad
import torch
import torch.nn as nn
import torch.nn.functional as F
class conv_relu(nn.Module):
def __init__(self, in_ch, out_ch, kernel_size=3, stride=1, padding=1, padding_mode='zeros', bias=True):
s... | 14,247 | 38.359116 | 139 | py |
SERT | SERT-master/models/competing_methods/macnet/MACNet.py | from collections import namedtuple
from .ops.utils import est_noise,count
# from model.qrnn.combinations import *
from .non_local import NLBlockND,EfficientNL
from .combinations import *
Params = namedtuple('Params', ['in_channels', 'channels', 'num_half_layer','rs'])
from skimage.restoration import denoise_nl_means,e... | 4,441 | 38.309735 | 104 | py |
SERT | SERT-master/models/competing_methods/macnet/combinations.py | import torch
import torch.nn as nn
from torch.nn import functional
from models.competing_methods.sync_batchnorm import SynchronizedBatchNorm2d, SynchronizedBatchNorm3d
BatchNorm3d = SynchronizedBatchNorm3d
BatchNorm2d=SynchronizedBatchNorm2d
class BNReLUConv3d(nn.Sequential):
def __init__(self, in_channels, chann... | 11,593 | 48.33617 | 119 | py |
SERT | SERT-master/models/competing_methods/macnet/non_local.py | import torch
from torch import nn
from torch.nn import functional as F
class EfficientNL(nn.Module):
def __init__(self, in_channels, key_channels=None, head_count=None, value_channels=None):
super(EfficientNL, self).__init__()
self.in_channels = in_channels
self.key_channels = key_channels
... | 8,755 | 40.107981 | 111 | py |
SERT | SERT-master/models/competing_methods/macnet/__init__.py | from .MACNet import MACNet | 26 | 26 | 26 | py |
SERT | SERT-master/models/competing_methods/macnet/ops/gauss.py | #!/usr/bin/env python
"""Module providing functionality surrounding gaussian function.
"""
SVN_REVISION = '$LastChangedRevision: 16541 $'
import sys
import numpy
def gaussian2(size, sigma):
"""Returns a normalized circularly symmetric 2D gauss kernel array
f(x,y) = A.e^{-(x^2/2*sigma^2 + y^2/2*sigma^2)} whe... | 1,954 | 31.583333 | 87 | py |
SERT | SERT-master/models/competing_methods/macnet/ops/utils_blocks.py | import torch
import torch.nn.functional as F
from ops.im2col import Im2Col, Col2Im, Col2Cube,Cube2Col
def shape_pad_even(tensor_shape, patch,stride):
assert len(tensor_shape) == 4
b,c,h,w = tensor_shape
required_pad_h = stride - (h-patch) % stride
required_pad_w = stride - (w-patch) % stride
retur... | 7,650 | 39.057592 | 144 | py |
SERT | SERT-master/models/competing_methods/macnet/ops/utils.py | import torch
import torch.functional as F
from random import randint
import argparse
import torch.nn as nn
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
from skimage.measure import compare_ssim, compare_psnr
from .gauss import fspecial_gauss
from scipy import signal
def kronecker(A, B):
r... | 13,403 | 27.887931 | 123 | py |
SERT | SERT-master/models/competing_methods/macnet/ops/utils_plot.py | import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
from torchvision.utils import make_grid
from ops.im2col import *
from ops.utils import get_mask
def plot_tensor(img, **kwargs):
inp_shape = tuple(img.shape)
print(inp_shape)
img_np = torch_to_np(img)
if inp_shape[1]==3:
im... | 2,976 | 22.626984 | 83 | py |
SERT | SERT-master/models/competing_methods/macnet/ops/im2col.py | from torch.nn import functional as F
import torch
from torch.nn.modules.utils import _pair
import math
def Im2Col(input_tensor, kernel_size, stride, padding,dilation=1,tensorized=False,):
batch = input_tensor.shape[0]
out = F.unfold(input_tensor, kernel_size=kernel_size, padding=padding, stride=stride,dilatio... | 5,405 | 42.248 | 159 | py |
SERT | SERT-master/models/competing_methods/sync_batchnorm/replicate.py | # -*- coding: utf-8 -*-
# File : replicate.py
# Author : Jiayuan Mao
# Email : [email protected]
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import functools
from torch.nn.parallel.da... | 3,226 | 32.968421 | 115 | py |
SERT | SERT-master/models/competing_methods/sync_batchnorm/unittest.py | # -*- coding: utf-8 -*-
# File : unittest.py
# Author : Jiayuan Mao
# Email : [email protected]
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import unittest
import numpy as np
from tor... | 835 | 26.866667 | 157 | py |
SERT | SERT-master/models/competing_methods/sync_batchnorm/batchnorm.py | # -*- coding: utf-8 -*-
# File : batchnorm.py
# Author : Jiayuan Mao
# Email : [email protected]
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import collections
import torch
import tor... | 12,973 | 40.056962 | 116 | py |
SERT | SERT-master/models/competing_methods/sync_batchnorm/comm.py | # -*- coding: utf-8 -*-
# File : comm.py
# Author : Jiayuan Mao
# Email : [email protected]
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import queue
import collections
import threading... | 4,278 | 31.416667 | 117 | py |
SERT | SERT-master/models/competing_methods/sync_batchnorm/__init__.py | # -*- coding: utf-8 -*-
# File : __init__.py
# Author : Jiayuan Mao
# Email : [email protected]
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
from .batchnorm import SynchronizedBatchNorm... | 449 | 33.615385 | 96 | py |
SERT | SERT-master/models/competing_methods/qrnn/combinations.py | import torch
import torch.nn as nn
from torch.nn import functional
from models.competing_methods.sync_batchnorm import SynchronizedBatchNorm2d, SynchronizedBatchNorm3d
BatchNorm3d = SynchronizedBatchNorm3d
class BNReLUConv3d(nn.Sequential):
def __init__(self, in_channels, channels, k=3, s=1, p=1, inplace=False):... | 3,464 | 42.3125 | 143 | py |
SERT | SERT-master/models/competing_methods/qrnn/resnet.py | import torch
import torch.nn as nn
import numpy as np
import os
if __name__ == '__main__':
from qrnn3d import *
else:
from .qrnn3d import *
class ResQRNN3D(nn.Module):
def __init__(self, in_channels, channels, n_resblocks):
super(ResQRNN3D, self).__init__()
bn = True
act ... | 1,415 | 23 | 70 | py |
SERT | SERT-master/models/competing_methods/qrnn/utils.py | import torch
import torch.nn as nn
class QRNNREDC3D(nn.Module):
def __init__(self, in_channels, channels, num_half_layer, sample_idx,
BiQRNNConv3D=None, BiQRNNDeConv3D=None,
QRNN3DEncoder=None, QRNN3DDecoder=None, is_2d=False, has_ad=True, bn=True, act='tanh', plain=False):
super(QRNNREDC3D, self... | 5,623 | 39.753623 | 152 | py |
SERT | SERT-master/models/competing_methods/qrnn/qrnn3d.py | import torch
import torch.nn as nn
import torch.nn.functional as FF
import numpy as np
from functools import partial
if __name__ == '__main__':
from combinations import *
from utils import *
else:
from .combinations import *
from .utils import *
"""F pooling"""
class QRNN3DLayer(nn.Module):
def ... | 5,125 | 32.503268 | 129 | py |
SERT | SERT-master/models/competing_methods/qrnn/redc3d.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
if __name__ == '__main__':
from combinations import *
else:
from .combinations import *
class REDC3D(torch.nn.Module):
"""Residual Encoder-Decoder Convolution 3D
Args:
downsample: downsample... | 2,115 | 34.864407 | 87 | py |
SERT | SERT-master/models/competing_methods/qrnn/__init__.py | from .qrnn3d import QRNNREDC3D
from .redc3d import REDC3D
from .resnet import ResQRNN3D
| 88 | 21.25 | 30 | py |
SERT | SERT-master/models/competing_methods/T3SC/multilayer.py | import logging
import torch
import torch.nn as nn
from models.competing_methods.T3SC import layers
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
class MultilayerModel(nn.Module):
def __init__(
self,
channels,
layers,
ssl=0,
n_ssl=0,
ckpt=No... | 2,291 | 25.964706 | 76 | py |
SERT | SERT-master/models/competing_methods/T3SC/layers/lowrank_sc_layer.py | import torch
import torch.nn.functional as F
import torch.nn as nn
import math
import logging
from models.competing_methods.T3SC.layers.encoding_layer import EncodingLayer
from models.competing_methods.T3SC.layers.soft_thresholding import SoftThresholding
logger = logging.getLogger(__name__)
logger.setLevel(logging.D... | 5,915 | 29.65285 | 83 | py |
SERT | SERT-master/models/competing_methods/T3SC/layers/soft_thresholding.py | import torch
import torch.nn as nn
import torch.nn.functional as F
MODES = ["SG", "SC", "MG", "MC"]
class SoftThresholding(nn.Module):
def __init__(self, mode, lbda_init, code_size=None, K=None):
super().__init__()
assert mode in MODES, f"Mode {mode!r} not recognized"
self.mode = mode
... | 1,204 | 27.690476 | 73 | py |
SERT | SERT-master/models/competing_methods/T3SC/layers/encoding_layer.py | import logging
import torch.nn as nn
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
class EncodingLayer(nn.Module):
def __init__(
self,
in_channels=None,
code_size=None,
input_centering=False,
**kwargs,
):
super().__init__()
self.i... | 1,251 | 22.622642 | 75 | py |
SERT | SERT-master/models/competing_methods/T3SC/layers/__init__.py | from .lowrank_sc_layer import LowRankSCLayer
from .encoding_layer import EncodingLayer
from .soft_thresholding import SoftThresholding
| 135 | 33 | 47 | py |
CamDiff | CamDiff-main/inpainting_diff.py | from diffusers import StableDiffusionInpaintPipeline
import torch
import os
# from einops import repeat
import numpy as np
import time
import argparse
from PIL import Image
import random
# from efficientnet_classification import EfficientnetPipeline
from clip_classification import ClipPipeline
WIDTH = 512
HEIGHT = 51... | 11,126 | 35.009709 | 128 | py |
CamDiff | CamDiff-main/paper.py | import PIL
import os
from PIL import Image
def image_grid(imgs, rows, cols):
assert len(imgs) == rows*cols
w, h = imgs[0].size
grid = PIL.Image.new('RGB', size=(cols*w, rows*h))
grid_w, grid_h = grid.size
for i, img in enumerate(imgs):
grid.paste(img, box=(i%cols*w, i//cols*h))
re... | 1,004 | 31.419355 | 97 | py |
CamDiff | CamDiff-main/clip_classification.py | import os
import clip
import torch
import numpy as np
def get_label_list(input_dir):
images = [os.path.join(input_dir, file_path) for file_path in os.listdir(input_dir)]
label_list = []
for image in images:
if len(os.path.split(image)[1].split("-")) == 1:
continue
else:
... | 1,529 | 32.26087 | 107 | py |
EBM-HEP | EBM-HEP-main/mcmc.py | import torch
def energy_wrapper(nenergy):
'''
Wrapper to facilitate flexible energy function sign
'''
energy = - nenergy
return energy
# Partially based on code from Yilun Du, Improved Contrastive Divergence Training of Energy Based Models.
# https://github.com/yilundu/improved_contrastive_diverge... | 2,631 | 31.493827 | 115 | py |
EBM-HEP | EBM-HEP-main/ebm_models.py |
import copy
import math
import torch
import torch.nn as nn
import torch.nn.utils.spectral_norm as spectral_norm
import torch.nn.functional as F
import torch.utils.data as data
from torch.utils.data import Dataset
import torch.optim as optim
import torchvision
from torchvision.datasets import MNIST
from torchvision im... | 6,173 | 29.564356 | 112 | py |
EBM-HEP | EBM-HEP-main/utils.py |
import os
from pathlib import Path
import random
import h5py
import numpy as np
from numpy import inf
import torch
import torch.nn.functional as F
import torch.nn as nn
import pytorch_lightning as pl
from pytorch_lightning.callbacks import LearningRateMonitor, ModelCheckpoint, TQDMProgressBar
import uproot_methods
... | 6,933 | 27.652893 | 116 | py |
EBM-HEP | EBM-HEP-main/ebm_preamble.py | #__all__ = ['utils', 'load_data', 'ebm_models']
import os
import json
import math
import numpy as np
from math import inf
import h5py
import random
import copy
import time, argparse
import timeit
import datetime
from pathlib import Path
from sklearn.preprocessing import MinMaxScaler, RobustScaler
from sklearn.model_s... | 1,444 | 27.333333 | 93 | py |
EBM-HEP | EBM-HEP-main/ebm_jet_attn.py | #!/usr/bin/env python
from ebm_preamble import *
FLAGS = {
'max_len': 10000,
'new_sample_rate': 0.05,
'singlestep': False, # for KL improved training, only back-prop through the last LD step
'MH': True, # Metropolis-Hastings step for HMC
'val_steps': 128,
'scaled': Fa... | 18,407 | 40.647059 | 221 | py |
EBM-HEP | EBM-HEP-main/load_data.py |
import os
import numpy as np
import h5py
from sklearn.preprocessing import MinMaxScaler, RobustScaler
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
import torch
import torch.nn.functional as F
import uproot_methods
from utils import jet_e, jet_pt, jet_mass
from math import in... | 8,832 | 28.055921 | 158 | py |
EBM-HEP | EBM-HEP-main/__init__.py |
__version__ = "0.1"
| 22 | 4.75 | 19 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/ex2_tpr_proposed.py | import numpy as np
from tensorflow.keras.models import load_model
import tensorflow as tf
import time
import gen_data
import util
import parametric_si
def run():
d = 8
IMG_WIDTH = d
IMG_HEIGHT = d
IMG_CHANNELS = 1
mu_1 = 0
mu_2 = 1.5
threshold = 20
# np.random.seed(1)
X_test, Y_... | 2,136 | 19.548077 | 100 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/ex4_count_no_interval.py | import numpy as np
from tensorflow.keras.models import load_model
import tensorflow as tf
import time
import gen_data
import util
import parametric_si
def run():
n = 16
d = int(np.sqrt(n))
IMG_WIDTH = d
IMG_HEIGHT = d
IMG_CHANNELS = 1
mu_1 = 0
mu_2 = 2
threshold = 20
# np.rando... | 2,198 | 20.144231 | 100 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/ex3_len_interval_proposed_oc.py | import numpy as np
from tensorflow.keras.models import load_model
import tensorflow as tf
import time
import gen_data
import util
def run():
d = 8
IMG_WIDTH = d
IMG_HEIGHT = d
IMG_CHANNELS = 1
mu_1 = 0
mu_2 = 2
global_list_ineq = []
X_test, Y_test = gen_data.generate(1, IMG_WIDTH, m... | 3,789 | 23.294872 | 108 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/training.py | import numpy as np
from tensorflow.keras.models import Model, load_model
from tensorflow.keras.layers import Input
from tensorflow.keras.layers import Conv2D, UpSampling2D
from tensorflow.keras.layers import MaxPooling2D
from tensorflow.keras.layers import concatenate
from tensorflow.keras.callbacks import EarlyStoppi... | 1,416 | 27.34 | 100 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/ex2_tpr_proposed_oc.py | import numpy as np
from tensorflow.keras.models import load_model
import tensorflow as tf
import time
import gen_data
import util
def run():
d = 8
IMG_WIDTH = d
IMG_HEIGHT = d
IMG_CHANNELS = 1
mu_1 = 0
mu_2 = 2
global_list_ineq = []
X_test, Y_test = gen_data.generate(1, IMG_WIDTH, m... | 4,137 | 23.05814 | 108 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/parametric_si.py | import numpy as np
import tensorflow as tf
import util
def run_parametric_si(u, v, model, d, IMG_CHANNELS, threshold):
zk = -threshold
list_zk = [zk]
list_results = []
while zk < threshold:
x = u + v * zk
global_list_ineq = []
X_test = np.reshape(x, (1, d, d, IMG_CHANNELS)... | 3,232 | 26.87069 | 112 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/util.py | import numpy as np
from mpmath import mp
mp.dps = 500
def compute_naive_p(test_statistic, n_a, n_b, sigma):
z = test_statistic / (sigma * np.sqrt(1 / n_a + 1 / n_b))
naive_p = mp.ncdf(z)
return float(naive_p)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def construct_z(binary_vec, list_zk, list... | 9,342 | 28.380503 | 136 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/gen_data.py | import numpy as np
from scipy.stats import skewnorm
def generate_non_normal(n, d, mu_1, mu_2):
list_X_train = []
list_X_label = []
for _ in range(n):
X_train = []
X_label = []
for i in range(d):
if (i < d / 4) or (i >= 3 * d / 4):
vec_train = []
... | 3,463 | 32.631068 | 90 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/ex1_fpr_proposed_oc.py | import numpy as np
from tensorflow.keras.models import load_model
import tensorflow as tf
import time
import gen_data
import util
def run():
n = 16
d = int(np.sqrt(n))
IMG_WIDTH = d
IMG_HEIGHT = d
IMG_CHANNELS = 1
mu_1 = 0
mu_2 = 0
global_list_ineq = []
X_test, Y_test = gen_dat... | 4,163 | 22.931034 | 108 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/ex1_fpr_proposed.py | import numpy as np
from tensorflow.keras.models import load_model
import tensorflow as tf
import time
import gen_data
import util
import parametric_si
def run():
n = 16
d = int(np.sqrt(n))
IMG_WIDTH = d
IMG_HEIGHT = d
IMG_CHANNELS = 1
mu_1 = 0
mu_2 = 0
threshold = 20
# np.rando... | 2,160 | 19.386792 | 100 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/ex1_fpr_naive.py | import numpy as np
from tensorflow.keras.models import load_model
import tensorflow as tf
import time
import gen_data
import util
import parametric_si
def run():
n = 16
d = int(np.sqrt(n))
IMG_WIDTH = d
mu_1 = 0
mu_2 = 0
X_test, Y_test = gen_data.generate(1, IMG_WIDTH, mu_1, mu_2)
mode... | 1,834 | 17.72449 | 71 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/ex3_len_interval_proposed.py | import numpy as np
from tensorflow.keras.models import load_model
import tensorflow as tf
import time
import gen_data
import util
import parametric_si
def run():
d = 8
IMG_WIDTH = d
IMG_HEIGHT = d
IMG_CHANNELS = 1
mu_1 = 0
mu_2 = 2
threshold = 20
# np.random.seed(1)
X_test, Y_te... | 1,907 | 19.516129 | 100 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/plot/plot_fpr.py | import numpy as np
import matplotlib.pyplot as plt
line1 = [0.04, 0.04, 0.05, 0.04]
line2 = [0.04, 0.05, 0.05, 0.05]
line3 = [0.11, 0.33, 0.60, 0.77]
index = ['16', '64', '256', '1024']
xi = [1, 2, 3, 4]
plt.rcParams.update({'font.size': 17})
plt.title("False Positive Rate (FPR)")
plt.ylim(0, 1.03)
plt.plot(xi, ... | 642 | 20.433333 | 66 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/plot/plot_len_interval.py | import numpy as np
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 18})
plt.title("Interval Length")
x_1 = [0.12254761267840242, 0.2360774560483192, 0.26384502143271105, 0.055860407571420634, 0.18671892561562808, 0.05340873883171593, 0.02656998260333987, 0.37134713479488624, 0.5174398587536528, 0.31... | 5,238 | 186.107143 | 2,474 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/plot/plot_no_interval_increase_node.py | import numpy as np
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 18})
# plt.title("# encounted intervals")
xx_1 = [36, 42, 40, 41, 37, 37, 42, 37, 43, 44, 34, 41, 42, 41, 39, 36, 42, 40, 36, 38, 36, 41, 38, 42, 39, 38, 42, 39, 42, 39, 41, 38, 36, 39, 37, 44, 37, 40, 38, 42, 39, 39, 37, 39, 40, 41... | 2,691 | 69.842105 | 607 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/plot/plot_fpr_violate.py | import numpy as np
import matplotlib.pyplot as plt
# line1 = [0.06, 0.059, 0.06, 0.05]
# line2 = [0.11, 0.1, 0.1, 0.1]
#
# index = ['16', '64', '256', '1024']
#
# xi = [1, 2, 3, 4]
#
# # plt.rcParams.update({'font.size': 18})
# # plt.figure(figsize=(7, 4.5))
# plt.rcParams.update({'font.size': 18})
# plt.figure(figsiz... | 2,445 | 21.036036 | 49 | py |
dnn_segmentation_selective_inference | dnn_segmentation_selective_inference-main/plot/plot_power.py | import numpy as np
import matplotlib.pyplot as plt
line1 = [0.09, 0.31, 0.62, 0.79]
line2 = [0.04, 0.09, 0.22, 0.36]
index = ['0.5', '1.0', '1.5', '2.0']
xi = [1, 2, 3, 4]
plt.rcParams.update({'font.size': 18})
plt.title("Power")
plt.ylim(0, 1.03)
plt.plot(xi, line1, 'o-', label='proposed-method', linewidth=3)
p... | 547 | 18.571429 | 66 | py |
UNITER | UNITER-master/train_nlvr2.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER finetuning for NLVR2
"""
import argparse
import os
from os.path import exists, join
from time import time
import torch
from torch.nn import functional as F
from torch.nn.utils import clip_grad_norm_
from torch.utils.data import DataLoader... | 17,550 | 41.703163 | 79 | py |
UNITER | UNITER-master/pretrain.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER pre-training
"""
import argparse
from collections import defaultdict
import json
import math
import os
from os.path import exists, join
from time import time
import torch
from torch.utils.data import DataLoader
from torch.nn import functi... | 25,780 | 39.094868 | 79 | py |
UNITER | UNITER-master/train_itm.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER finetuning for Image-Text Retrieval
"""
import argparse
import os
from os.path import exists, join
from time import time
import torch
from torch.nn.utils import clip_grad_norm_
from torch.utils.data import DataLoader, ConcatDataset
from a... | 17,930 | 42.627737 | 79 | py |
UNITER | UNITER-master/prepro.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
preprocess NLVR annotations into LMDB
"""
import argparse
import json
import pickle
import os
from os.path import exists
from cytoolz import curry
from tqdm import tqdm
from pytorch_pretrained_bert import BertTokenizer
from data.data import ope... | 6,939 | 36.923497 | 79 | py |
UNITER | UNITER-master/inf_vcr.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
run inference of VCR for submission
"""
import argparse
import json
import os
from os.path import exists
import pandas as pd
from time import time
import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader
from ap... | 10,802 | 36.905263 | 78 | py |
UNITER | UNITER-master/train_vcr.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
UNITER finetuning for VCR
"""
import argparse
import json
import os
from os.path import exists, join
from time import time
import torch
from torch.nn import functional as F
from torch.nn.utils import clip_grad_norm_
from torch.utils.data import ... | 20,770 | 41.131846 | 79 | py |
UNITER | UNITER-master/inf_vqa.py | """
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
run inference of VQA for submission
"""
import argparse
import json
import os
from os.path import exists
from time import time
import torch
from torch.utils.data import DataLoader
from apex import amp
from horovod import torch as hvd
import num... | 6,692 | 35.774725 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.