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 |
|---|---|---|---|---|---|---|
TuRBO | TuRBO-master/setup.py | from setuptools import setup, find_packages
setup(
name="turbo",
version="0.0.1",
packages=find_packages(),
install_requires=["numpy>=1.17.3", "torch>=1.3.0", "gpytorch>=0.3.6"],
)
| 198 | 21.111111 | 74 | py |
TuRBO | TuRBO-master/turbo/turbo_m.py | ###############################################################################
# Copyright (c) 2019 Uber Technologies, Inc. #
# #
# Licensed under the Uber Non-Commercial License (the "License"); #
... | 10,583 | 41.677419 | 110 | py |
TuRBO | TuRBO-master/turbo/gp.py | ###############################################################################
# Copyright (c) 2019 Uber Technologies, Inc. #
# #
# Licensed under the Uber Non-Commercial License (the "License"); #
... | 3,760 | 36.989899 | 117 | py |
TuRBO | TuRBO-master/turbo/turbo_1.py | ###############################################################################
# Copyright (c) 2019 Uber Technologies, Inc. #
# #
# Licensed under the Uber Non-Commercial License (the "License"); #
... | 11,981 | 38.675497 | 117 | py |
lisa | lisa-master/devel/unet_keras_kidney_bodynavigation.py | # %%
# %%
from __future__ import print_function
from loguru import logger
import io3d
import io3d.datasets
import sed3
import numpy as np
import matplotlib.pyplot as plt
logger.enable("io3d")
logger.disable("io3d")
import matplotlib.pyplot as plt
from pathlib import Path
import bodynavigation
import exsu
import sy... | 6,930 | 19.813814 | 141 | py |
lisa | lisa-master/devel/unet_keras_tools.py | from __future__ import print_function
from loguru import logger
import io3d
import io3d.datasets
import sed3
import numpy as np
import matplotlib.pyplot as plt
logger.enable("io3d")
logger.disable("io3d")
import matplotlib.pyplot as plt
from pathlib import Path
import bodynavigation
import exsu
import sys
import os
... | 18,662 | 37.401235 | 173 | py |
LineaRE | LineaRE-master/dataloader.py | import numpy as np
import torch
from torch.utils.data import Dataset
from config import config
class TrainDataset(Dataset):
def __init__(self, triples, ent_num, neg_size, mode):
self.triples = triples
self.ent_num = ent_num
self.neg_size = neg_size
self.neg_sample_size = neg_size ... | 4,204 | 32.64 | 95 | py |
LineaRE | LineaRE-master/utils.py | import json
import logging
import os
import numpy as np
import torch
import torch.nn.functional as func
from torch.utils.data import DataLoader
from config import config
from dataloader import TrainDataset, BidirectionalOneShotIterator, TestDataset
def read_elements(file_path):
with open(file_path, 'r') as f:
... | 14,116 | 34.2925 | 88 | py |
LineaRE | LineaRE-master/model.py | import torch
import torch.nn as nn
from math import pi
from config import config
class Model(nn.Module):
def __init__(self, ent_num, rel_num):
super(Model, self).__init__()
self.register_buffer("gamma", torch.tensor(config.gamma))
self.register_buffer("ents", torch.arange(ent_num).unsquee... | 17,770 | 40.521028 | 94 | py |
LineaRE | LineaRE-master/run.py | import logging
import os
import torch
from config import config
from model import TransE, TransH, TransD, STransE, LineaRE, DistMult, ComplEx, RotatE, SimpleTransR, TransIJ
from utils import set_logger, read_elements, read_triples, log_metrics, save_model, train_data_iterator, \
get_optim, train_step, test_step, ... | 7,287 | 40.409091 | 118 | py |
LineaRE | LineaRE-master/new code/utils.py | import logging
from os import path
from queue import Queue
from threading import Thread
import torch
from configure import config
def set_logger():
logging.basicConfig(
format='%(asctime)s | %(levelname)s: %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S',
filename=path.join(config.save_path, ... | 3,067 | 25.448276 | 85 | py |
LineaRE | LineaRE-master/new code/data.py | import logging
from pathlib import Path
import numpy as np
import torch
from torch.utils.data import Dataset, DataLoader
import utils
from configure import config
def read_elements(file_path):
elements2id = {}
with open(file_path, 'r') as f:
for line in f:
e_id, e_str = line.strip().split('\t')
elements2i... | 8,392 | 27.841924 | 93 | py |
LineaRE | LineaRE-master/new code/configure.py | import json
import logging
import torch
class Configure(object):
def __init__(self, config_path):
with open(config_path, 'r') as fjson:
json_config = json.load(fjson)
self.dim = json_config['dim']
self.norm_p = json_config['norm_p']
self.alpha = json_config['alpha']
self.beta = json_config['beta']
se... | 1,634 | 33.0625 | 62 | py |
LineaRE | LineaRE-master/new code/traintest.py | import copy
import json
import logging
import pathlib
from os import path
from typing import Dict
import numpy as np
import torch
from torch import nn
from torch.optim.lr_scheduler import ExponentialLR
from configure import config
from data import KG, BiOneShotIterator
from lineare import LineaRE
class TrainTest:
... | 5,341 | 33.915033 | 99 | py |
LineaRE | LineaRE-master/new code/lineare.py | import logging
import numpy as np
import torch
from torch import nn
from configure import config
class LineaRE(nn.Module):
def __init__(self, num_ents, num_rels):
super(LineaRE, self).__init__()
self.register_buffer('gamma', torch.tensor(config.gamma))
self.register_buffer('ents', torch.arange(num_ents).unsq... | 5,501 | 33.822785 | 109 | py |
MobileNet-SSD | MobileNet-SSD-master/gen.py | import argparse
FLAGS = None
class Generator():
def __init__(self):
self.first_prior = True
self.anchors = create_ssd_anchors()
self.last = "data"
def header(self, name):
print("name: \"%s\"" % name)
def data_deploy(self):
print(
"""input: "data"
input_shape {
dim: 1
... | 17,879 | 20.911765 | 112 | py |
MobileNet-SSD | MobileNet-SSD-master/demo.py | import numpy as np
import sys,os
import cv2
caffe_root = '/home/yaochuanqi/work/ssd/caffe/'
sys.path.insert(0, caffe_root + 'python')
import caffe
net_file= 'deploy.prototxt'
caffe_model='mobilenet_iter_73000.caffemodel'
test_dir = "images"
if not os.path.exists(caffe_model):
print(caffe_model + " do... | 1,975 | 26.444444 | 76 | py |
MobileNet-SSD | MobileNet-SSD-master/merge_bn.py | import os
import sys
import argparse
import logging
import numpy as np
try:
caffe_root = '/home/yaochuanqi/work/caffe/'
sys.path.insert(0, caffe_root + 'python')
import caffe
except ImportError:
logging.fatal("Cannot find caffe!")
from caffe.proto import caffe_pb2
from google.protobuf import text_forma... | 4,426 | 33.317829 | 100 | py |
pyterrier_colbert | pyterrier_colbert-main/pyterrier_colbert/indexing.py | import pyterrier as pt
import os
from pyterrier_colbert.ranking import ColBERTFactory
import numpy as np
from colbert.indexing.faiss import index_faiss
from colbert.indexing.loaders import load_doclens
import os
import ujson
import random
import copy
import queue
import math
from colbert.utils.parser import Arguments
i... | 18,554 | 36.409274 | 150 | py |
pyterrier_colbert | pyterrier_colbert-main/pyterrier_colbert/__init__.py |
#import importlib
#ranking = importlib.import_module('.' + 'indexing', package='pyterrier_colbert')
#ranking = importlib.import_module('.' + 'ranking', package='pyterrier_colbert')
import torch
from colbert.utils.utils import print_message
from collections import OrderedDict, defaultdict
def load_checkpoint(path, ... | 1,578 | 32.595745 | 131 | py |
pyterrier_colbert | pyterrier_colbert-main/pyterrier_colbert/ranking.py |
import os
import torch
import pandas as pd
import pyterrier as pt
assert pt.started(), "please run pt.init() before importing pyt_colbert"
from pyterrier import tqdm
from pyterrier.datasets import Dataset
from typing import Union, Tuple
from colbert.evaluation.load_model import load_model
from . import load_checkpoin... | 50,973 | 42.642123 | 198 | py |
pyterrier_colbert | pyterrier_colbert-main/pyterrier_colbert/faiss_term_index.py | import os
import time
import random
import torch
import numpy as np
from collections import defaultdict
from multiprocessing import Pool
from colbert.modeling.inference import ModelInference
from colbert.utils.utils import print_message, flatten, batch
from colbert.indexing.loaders import get_parts
from colbert.evalu... | 8,826 | 37.885463 | 179 | py |
pyterrier_colbert | pyterrier_colbert-main/tests/test_indexing.py | import unittest
import pandas as pd
import tempfile
CHECKPOINT="http://www.dcs.gla.ac.uk/~craigm/colbert.dnn.zip"
class TestIndexing(unittest.TestCase):
def _indexing_1doc(self, indexmgr, model, dim=None):
#minimum test case size is 100 docs, 40 Wordpiece tokens, and nx > k. we found 200 worked
im... | 8,372 | 44.016129 | 417 | py |
HetEmotionNet | HetEmotionNet-main/model/GTblock.py | import torch
import torch.nn as nn
from model.GTlayer import GTLayer
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
class permute(nn.Module):
def __init__(self):
super(permute, self).__init__()
def forward(self, x):
return x.permute(0, 2, 1)
class GTN(nn.Module):
... | 3,037 | 31.319149 | 111 | py |
HetEmotionNet | HetEmotionNet-main/model/STDCN.py | import torch
import torch.nn as nn
import torch.nn.functional as F
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
torch.cuda.set_device(0)
class permute(nn.Module):
def __init__(self):
super(permute, self).__init__()
def forward(self, x):
return x.permute(0, 2, 1)
c... | 3,586 | 31.609091 | 111 | py |
HetEmotionNet | HetEmotionNet-main/model/GTlayer.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
class GTLayer(nn.Module):
def __init__(self, in_channels, out_channels, first=True):
super(GTLayer, self).__init__()
self.in_channels = in_channel... | 2,628 | 34.527027 | 112 | py |
HetEmotionNet | HetEmotionNet-main/model/prototype.py | import torch as t
from model.GTblock import GTN
from model.STDCN import *
class permute(nn.Module):
def __init__(self):
super(permute, self).__init__()
def forward(self, x):
return x.permute(0, 2, 1)
class Net(nn.Module):
def __init__(self, model_config):
super(Net, self).__init... | 2,448 | 36.676923 | 102 | py |
HetEmotionNet | HetEmotionNet-main/model/utils.py | import torch as t
import numpy as np
from torch_geometric.data import Dataset, Data
import scipy.io as sio
import os
device = t.device('cuda' if t.cuda.is_available() else 'cpu')
@t.no_grad()
def acc(net, labels, label_num, dataloader):
# Calculate the confusion matrix and accuracy of the current batch
confu... | 1,624 | 35.931818 | 86 | py |
GANonymization | GANonymization-main/main.py | import os.path
import pathlib
import shutil
import cv2
import fire
import pandas as pd
import pytorch_lightning
import torchvision.transforms
from loguru import logger
from sklearn.model_selection import train_test_split
from torchvision.transforms import RandomHorizontalFlip, Compose
from torchvision.utils import sav... | 8,989 | 48.395604 | 118 | py |
GANonymization | GANonymization-main/lib/analysis.py | import math
import os.path
import numpy as np
import pandas as pd
import torch
from PIL import Image
from deepface import DeepFace
from loguru import logger
from matplotlib import pyplot as plt
from scipy.stats import shapiro, wilcoxon
from statsmodels.stats.multitest import multipletests
from torchvision.transforms i... | 13,171 | 52.112903 | 162 | py |
GANonymization | GANonymization-main/lib/evaluator.py | import os.path
import numpy as np
import pandas as pd
import seaborn as sn
import torch
from loguru import logger
from matplotlib import pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
from sklearn.metrics import classification_report
from torch.utils.data import DataLoader
from torchmetrics.classification... | 5,557 | 46.913793 | 114 | py |
GANonymization | GANonymization-main/lib/trainer.py | import os
import random
import numpy as np
import pytorch_lightning
import torch
from loguru import logger
from pytorch_lightning import LightningModule
from pytorch_lightning.callbacks import ModelCheckpoint, LearningRateMonitor, EarlyStopping
from pytorch_lightning.loggers import TensorBoardLogger
def setup_torch_... | 3,589 | 45.025641 | 123 | py |
GANonymization | GANonymization-main/lib/models/pix2pix.py | import os.path
import pytorch_lightning
import torch
from torch import nn
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.utils import save_image, make_grid
from lib.datasets.image_dataset import ImageDataset
def weights_init_normal(m):
classname = m.__class__.__name_... | 10,286 | 34.843206 | 118 | py |
GANonymization | GANonymization-main/lib/models/generic_classifier.py | from typing import List
import pytorch_lightning as pl
import torch
from loguru import logger
from pytorch_lightning.cli import ReduceLROnPlateau
from torch import nn, Tensor
from torch.utils.data import DataLoader
from torchmetrics.classification import MulticlassAccuracy, MultilabelAccuracy
from torchvision.models i... | 4,690 | 42.036697 | 112 | py |
GANonymization | GANonymization-main/lib/datasets/image_dataset.py | import os
import numpy as np
import torchvision.transforms as transforms
from PIL import Image
from torch.utils.data import Dataset
from lib.utils import glob_dir
class ImageDataset(Dataset):
"""
An ImageDataset manages the access to images in a folder structure of train, val, and test.
"""
def __i... | 1,808 | 36.6875 | 106 | py |
GANonymization | GANonymization-main/lib/datasets/labeled_dataset.py | import json
import os
from typing import List, Tuple
import numpy as np
import pandas as pd
import torch
from PIL import Image
from loguru import logger
from sklearn.utils import compute_class_weight
from torch import Tensor
from torch.utils.data import DataLoader
from torchvision.transforms import Compose
from lib.d... | 4,453 | 41.826923 | 117 | py |
GANonymization | GANonymization-main/lib/datasets/unlabeled_dataset.py | import os
from typing import Tuple
import numpy as np
import torch
from PIL import Image
from loguru import logger
from torch import Tensor
from torch.utils.data import DataLoader
from torchvision.transforms import Compose
from lib.datasets import DatasetSplit
from lib.utils import glob_dir
class UnlabeledDataset(t... | 1,506 | 34.046512 | 98 | py |
GANonymization | GANonymization-main/lib/transform/pix2pix_transformer.py | import torch
from torchvision.transforms import transforms
from lib.models.pix2pix import Pix2Pix
class Pix2PixTransformer:
"""
The GANonymization transformer synthesizes images based on facial landmarks images.
"""
def __init__(self, model_file: str, img_size: int, device: int):
self.model ... | 1,182 | 32.8 | 87 | py |
brian2hears | brian2hears-master/docs_sphinx/conf.py | # -*- coding: utf-8 -*-
#
# brian2hears documentation build configuration file
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are c... | 13,993 | 32.801932 | 98 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/keras/load.py | from keras.models import load_model as keras_load_model
from .resnet.resnet import sensitivity, specificity, j_stat, compare_scores
def load_model(filename, custom_objects={'sensitivity': sensitivity, 'specificity': specificity, 'j_stat': j_stat,
'compare_scores': compare_scor... | 394 | 55.428571 | 114 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/keras/senet/se_resnet.py | '''
Squeeze-and-Excitation ResNets
References:
- [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385)
- []() # added when paper is published on Arxiv
'''
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from keras.models i... | 15,245 | 35.561151 | 110 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/keras/senet/se.py | from keras.layers import GlobalAveragePooling3D, Reshape, Dense, multiply, add, Permute, Conv3D
from keras import backend as K
def squeeze_excite_block(input, ratio=16):
''' Create a channel-wise squeeze-excite block
Args:
input: input tensor
filters: number of output filters
Returns: a ... | 2,058 | 27.205479 | 127 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/keras/resnet/resnet.py | from __future__ import division
import six
from keras.models import Model
from keras.layers import (
Input,
Activation,
Dense,
Flatten
)
from keras.layers.convolutional import (
Conv3D,
MaxPooling3D,
AveragePooling3D
)
from keras.layers.merge import add
from keras.layers.normalization impor... | 10,397 | 38.090226 | 116 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/build.py | import os
import math
import torch
import torch.nn
from .classification import resnet
from .classification import custom
from .segmentation import unet
from . import graph
def fetch_model_by_name(model_name, *args, **kwargs):
try:
if "res" in model_name.lower():
return getattr(resnet, model_n... | 3,130 | 38.1375 | 114 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/classification/custom.py | from torch import nn
from unet3d.models.pytorch.autoencoder.variational import VariationalAutoEncoder
from .decoder import BasicDecoder, Decoder1D
from .resnet import conv1x1x1, ResNet, BasicBlock
class RegularizedResNet(VariationalAutoEncoder):
def __init__(self, n_outputs, *args, **kwargs):
super(Regul... | 4,384 | 43.292929 | 115 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/classification/resnet.py | """
Modified from https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
"""
import torch.nn as nn
__all__ = ['ResNet', 'resnet_18', 'resnet_34', 'resnet_50', 'resnet_101',
'resnet_152', 'resnext_50_32x4d', 'resnext_101_32x8d', 'conv3x3x3',
'conv1x1x1']
def conv3x3x3(in_pla... | 11,846 | 36.729299 | 118 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/classification/decoder.py | from functools import partial
from torch import nn
from .myronenko import MyronenkoLayer, MyronenkoResidualBlock
from . import resnet
class BasicDecoder(nn.Module):
def __init__(self, in_planes, layers, block=resnet.BasicBlock, plane_dilation=2, upsampling_mode="trilinear",
upsampling_scale=2):... | 8,019 | 48.202454 | 119 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/classification/myronenko.py | from torch import nn as nn
from .resnet import conv3x3x3, conv1x1x1
class MyronenkoConvolutionBlock(nn.Module):
def __init__(self, in_planes, planes, stride=1, norm_layer=None, norm_groups=8, kernel_size=3):
super(MyronenkoConvolutionBlock, self).__init__()
self.norm_groups = norm_groups
i... | 4,771 | 40.495652 | 120 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/fcn/fcn.py | from torch import nn
class FCN(nn.Module):
def __init__(self, hidden_layers_list, n_inputs, n_outputs):
super().__init__()
_layers = list()
_n_inputs = n_inputs
for hidden_layer in hidden_layers_list:
_layer = nn.Linear(_n_inputs, hidden_layer)
_n_inputs = h... | 566 | 28.842105 | 64 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/segmentation/unet.py | import torch
from ..classification.myronenko import MyronenkoEncoder
from ..classification.decoder import MirroredDecoder
from ..autoencoder.variational import ConvolutionalAutoEncoder
class UNetEncoder(MyronenkoEncoder):
def forward(self, x):
outputs = list()
for layer, downsampling in zip(self.l... | 2,037 | 31.870968 | 120 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/autoencoder/vqvae2.py | import torch
from torch import nn
from torch.nn import functional as F
# Copyright 2018 The Sonnet Authors. 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 copy of the License at
#
# http:... | 7,487 | 31.137339 | 87 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/autoencoder/variational.py | from functools import partial
import numpy as np
import torch.nn as nn
import torch
from unet3d.models.pytorch.classification.decoder import MyronenkoDecoder, MirroredDecoder
from unet3d.models.pytorch.classification.myronenko import MyronenkoEncoder, MyronenkoConvolutionBlock
from unet3d.models.pytorch.classificatio... | 8,509 | 51.530864 | 129 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/graph/graph_cmr_layers.py | """
This file contains definitions of layers used to build the GraphCNN
"""
from __future__ import division
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class GraphConvolution(nn.Module):
"""Simple GCN layer, similar to https://arxiv.org/abs/1609.02907."""
def __init__(self,... | 4,710 | 35.238462 | 100 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/graph/utils.py | from itertools import permutations
import nibabel as nib
import torch
import os
def load_surface(surface_filename):
surface = nib.load(os.path.abspath(surface_filename))
vertices = surface.darrays[0].data
n_vertices = vertices.shape[0]
faces = surface.darrays[1].data
adjacency_matrix = faces_to_ad... | 973 | 28.515152 | 86 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/models/pytorch/graph/graph_cmr_net.py | """
Modified from:
https://github.com/nkolot/GraphCMR/blob/master/models/graph_cnn.py
"""
from __future__ import division
import torch
import torch.nn as nn
from .graph_cmr_layers import GraphResBlock, GraphLinear
from .utils import load_surface, AdjacencyMatrixWrapper
from ..classification.resnet import resnet_18
... | 2,788 | 45.483333 | 119 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/scripts/train.py | import os
import argparse
import pandas as pd
import numpy as np
from unet3d.train import run_training
from unet3d.utils.filenames import wrapped_partial, generate_filenames, load_bias, load_sequence
from unet3d.utils.sequences import (WholeVolumeToSurfaceSequence, HCPRegressionSequence, ParcelBasedSequence,
... | 11,414 | 46.169421 | 120 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/train/keras.py | import os
from keras.callbacks import ModelCheckpoint, ReduceLROnPlateau, CSVLogger
import keras
import nibabel as nib
from unet3d.models.keras.load import load_model
from unet3d.models.keras.build import build_model
import numpy as np
from unet3d.utils.sequences import HCPRegressionSequence
def run_keras_training(co... | 7,893 | 49.929032 | 118 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/train/pytorch.py | import os
import shutil
import warnings
import numpy as np
import nibabel as nib
import pandas as pd
import torch
from torch.utils.data import DataLoader
import torch.nn
from ..models.pytorch.build import build_or_load_model
from ..utils.pytorch import WholeBrainCIFTI2DenseScalarDataset
from .pytorch_training_utils im... | 14,187 | 47.589041 | 120 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/train/pytorch_training_utils.py | """
Modified from: https://github.com/pytorch/examples/blob/master/imagenet/main.py
"""
import shutil
import time
import torch
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
try:
from torch.utils.data._utils.collate import default_collate
except ModuleNotFo... | 7,760 | 31.472803 | 120 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/train/train.py |
def run_training_with_package(package="keras", *args, **kwargs):
"""
Agnostic function to run the training with the specified deep learning package/framework.
:param package:
:param args:
:param kwargs:
:return:
"""
if package == "keras":
from .keras import run_keras_training a... | 557 | 30 | 93 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/utils/filenames.py | import os
from functools import partial, update_wrapper
from unet3d.utils import sequences as keras_sequences
from unet3d.utils.pytorch import dataset as pytorch_datasets
from unet3d.utils.utils import load_image, load_json, in_config
unet3d_path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__fil... | 9,790 | 50.26178 | 120 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/utils/sequences.py | import os
from functools import partial
import numpy as np
import nibabel as nib
from nilearn.image import new_img_like, resample_to_img, reorder_img
import random
import warnings
from .nilearn_custom_utils.nilearn_utils import crop_img
from .radiomic_utils import binary_classification, multilabel_classification, fetc... | 36,756 | 50.625 | 122 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/utils/pytorch/ssim.py | # Modified from https://github.com/VainF/pytorch-msssim
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 ... | 10,488 | 36.195035 | 137 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/utils/pytorch/functions.py | from torch.nn.functional import l1_loss, mse_loss
import torch
from .pt3dunet import compute_per_channel_dice
def per_channel_dice_loss(x, y, **kwargs):
return 1 - compute_per_channel_dice(x, y, **kwargs).mean()
def variational_regularized_loss(predicted, vae_x, mu, logvar, x, y, pred_loss=l1_loss, decoder_loss... | 2,908 | 41.15942 | 116 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/utils/pytorch/dataset.py | from torch.utils.data import Dataset
import torch
import numpy as np
from ..sequences import (WholeVolumeToSurfaceSequence, HCPRegressionSequence, get_metric_data,
WholeVolumeAutoEncoderSequence, WholeVolumeSegmentationSequence, WindowedAutoEncoderSequence,
SubjectPre... | 5,005 | 41.067227 | 119 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/utils/pytorch/pt3dunet.py | # from wolny's GitHub project: https://github.com/wolny/pytorch-3dunet
def compute_per_channel_dice(input, target, epsilon=1e-6, weight=None):
"""
Computes DiceCoefficient as defined in https://arxiv.org/abs/1606.04797 given a multi channel input and target.
Assumes the input is a normalized probability,... | 1,799 | 38.130435 | 116 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/predict/utils.py | import numpy as np
def pytorch_predict_batch_array(model, batch, n_gpus=1):
import torch
batch_x = torch.tensor(np.moveaxis(np.asarray(batch), -1, 1)).float()
pred_x = pytorch_predict_batch(batch_x, model, n_gpus)
return np.moveaxis(pred_x.numpy(), 1, -1)
def get_feature_filename_and_subject_id(data... | 816 | 29.259259 | 73 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/predict/volumetric.py | import os
import numpy as np
from nilearn.image import new_img_like, resample_to_img
from unet3d.predict.utils import pytorch_predict_batch_array, get_feature_filename_and_subject_id
from unet3d.utils.utils import one_hot_image_to_label_map, get_nibabel_data
def load_volumetric_model(model_name, model_filename, n_ou... | 11,525 | 58.107692 | 117 | py |
3DUnetCNN | 3DUnetCNN-master/unet3d/predict/predict.py | import os
import numpy as np
import nibabel as nib
import pandas as pd
from nilearn.image import new_img_like
from unet3d.predict.volumetric import load_volumetric_model_and_dataset, load_images_from_dataset, \
prediction_to_image, write_prediction_image_to_file
from unet3d.predict.utils import pytorch_predict_bat... | 27,747 | 56.808333 | 129 | py |
3DUnetCNN | 3DUnetCNN-master/legacy/unet3dlegacy/training.py | import math
from functools import partial
from keras import backend as K
from keras.callbacks import ModelCheckpoint, CSVLogger, LearningRateScheduler, ReduceLROnPlateau, EarlyStopping
from keras.models import load_model
from unet3d.metrics import (dice_coefficient, dice_coefficient_loss, dice_coef, dice_coef_loss,
... | 4,931 | 54.41573 | 120 | py |
3DUnetCNN | 3DUnetCNN-master/legacy/unet3dlegacy/metrics.py | from functools import partial
from keras import backend as K
def dice_coefficient(y_true, y_pred, smooth=1.):
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
intersection = K.sum(y_true_f * y_pred_f)
return (2. * intersection + smooth) / (K.sum(y_true_f) + K.sum(y_pred_f) + smooth)
def di... | 1,508 | 30.4375 | 100 | py |
3DUnetCNN | 3DUnetCNN-master/legacy/unet3dlegacy/model/isensee2017.py | from functools import partial
from keras.layers import Input, LeakyReLU, Add, UpSampling3D, Activation, SpatialDropout3D, Conv3D
from keras.engine import Model
from keras.optimizers import Adam
from .unet import create_convolution_block, concatenate
from ..metrics import weighted_dice_coefficient_loss
create_convol... | 4,212 | 39.509615 | 111 | py |
3DUnetCNN | 3DUnetCNN-master/legacy/unet3dlegacy/model/unet.py | import numpy as np
from keras import backend as K
from keras.engine import Input, Model
from keras.layers import Conv3D, MaxPooling3D, UpSampling3D, Activation, BatchNormalization, PReLU, Deconvolution3D
from keras.optimizers import Adam
from unet3d.metrics import get_label_dice_coefficient_function, dice_coefficient,... | 6,865 | 49.859259 | 120 | py |
3DUnetCNN | 3DUnetCNN-master/legacy/test/test_training.py | from unittest import TestCase
from keras.callbacks import ReduceLROnPlateau, EarlyStopping
from unet3d.training import get_callbacks
class TestCallbakcs(TestCase):
def test_reduce_on_plateau(self):
_, _, scheduler = get_callbacks(model_file='model.h5', learning_rate_patience=50, learning_rate_drop=0.5)
... | 564 | 32.235294 | 113 | py |
3DUnetCNN | 3DUnetCNN-master/legacy/test/test_metrics.py | from unittest import TestCase
import numpy as np
import keras.backend as K
from unet3d.metrics import weighted_dice_coefficient
class TestWeightedDice(TestCase):
def test_weighted_dice_coefficient(self):
data = np.zeros((5**3) * 3).reshape(3, 5, 5, 5)
data[0, 0:1] = 1
data[1, 0:2] = 1
... | 1,282 | 31.897436 | 120 | py |
DiffPure | DiffPure-master/eval_sde_adv_bpda.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 11,271 | 39.257143 | 127 | py |
DiffPure | DiffPure-master/utils.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 11,516 | 38.713793 | 119 | py |
DiffPure | DiffPure-master/eval_sde_adv.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 14,171 | 42.740741 | 128 | py |
DiffPure | DiffPure-master/stadv_eot/attacks.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 4,525 | 32.036496 | 79 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/color_transformers.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/color_transformers.py
#
# The license for the original versi... | 14,822 | 38.007895 | 91 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/utils.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/utils.py
#
# The license for the original version of this fi... | 3,667 | 32.651376 | 78 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/norms.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/norms.py
#
# The license for the original version of this fi... | 1,881 | 35.192308 | 78 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/perturbations.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/perturbations.py
#
# The license for the original version of... | 5,078 | 38.069231 | 86 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/color_spaces.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/color_spaces.py
#
# The license for the original version of ... | 8,620 | 30.578755 | 85 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/adversarial_training.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/adversarial_training.py
#
# The license for the or... | 25,356 | 45.019964 | 103 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/adversarial_attacks.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/adversarial_attacks.py
#
# The license for the ori... | 32,417 | 44.659155 | 102 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/loss_functions.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/loss_functions.py
#
# The license for the original... | 22,556 | 39.065719 | 97 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/adversarial_perturbations.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/adversarial_perturbations.py
#
# The license for t... | 31,509 | 37.710074 | 108 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/spatial_transformers.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/spatial_transformers.py
#
# The license for the or... | 20,065 | 36.931947 | 103 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/utils/pytorch_ssim.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/utils/pytorch_ssim.py
#
# The license for the orig... | 3,267 | 35.719101 | 104 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/utils/image_utils.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/utils/image_utils.py
#
# The license for the origi... | 7,342 | 36.850515 | 100 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/utils/checkpoints.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/utils/checkpoints.py
#
# The license for the origi... | 12,317 | 38.480769 | 100 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/utils/discretization.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/utils/discretization.py
#
# The license for the or... | 9,786 | 42.497778 | 103 | py |
DiffPure | DiffPure-master/stadv_eot/recoloradv/mister_ed/utils/pytorch_utils.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from recoloradv.
#
# Source:
# https://github.com/cassidylaidlaw/ReColorAdv/blob/master/recoloradv/mister_ed/utils/pytorch_utils.py
#
# The license for the ori... | 22,236 | 33.854232 | 102 | py |
DiffPure | DiffPure-master/ddpm/unet_ddpm.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/ermongroup/SDEdit/blob/main/models/diffusion.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_UNET_DDPM).
# -------------------------------... | 13,040 | 36.690751 | 95 | py |
DiffPure | DiffPure-master/score_sde/losses.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 8,334 | 38.50237 | 115 | py |
DiffPure | DiffPure-master/score_sde/sampling.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 17,567 | 35.148148 | 116 | py |
DiffPure | DiffPure-master/score_sde/sde_lib.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/yang-song/score_sde_pytorch/blob/main/sde_lib.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_SCORE_SDE).
# ------------------------------... | 7,909 | 29.19084 | 123 | py |
DiffPure | DiffPure-master/score_sde/models/up_or_down_sampling.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/yang-song/score_sde_pytorch/blob/main/models/up_or_down_sampling.py
#
# The license for the original version of this file can be
# found in the `score_sde` directory (LICENSE_SCORE_SDE).
# ... | 9,287 | 33.917293 | 91 | py |
DiffPure | DiffPure-master/score_sde/models/utils.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 6,151 | 31.723404 | 109 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.