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
DiffDVR
DiffDVR-master/pytests/tests/stepsize/vis_stepsize.py
import os import sys sys.path.append(os.getcwd()) import h5py import tests.vis_gui import torch import numpy as np import skimage.transform import matplotlib.colors import matplotlib.pyplot import pyrenderer class UIStepsize(tests.vis_gui.UI): def __init__(self, folder): keys = [ "filename"...
4,080
35.765766
99
py
DiffDVR
DiffDVR-master/pytests/tests/camera/run_image1d.py
import numpy as np import torch import os import matplotlib.pyplot as plt from matplotlib import gridspec import tqdm import imageio from diffdvr import Renderer, CameraOnASphere, Entropy, ColorMatches, Settings, setup_default_settings, \ fibonacci_sphere, renderer_dtype_torch, renderer_dtype_np, ProfileRenderer f...
13,803
41.473846
119
py
DiffDVR
DiffDVR-master/pytests/tests/camera/run_entropy2d.py
import numpy as np import torch import os import matplotlib.pyplot as plt from matplotlib import gridspec import matplotlib.ticker as mticker import matplotlib import matplotlib.colors import tqdm import imageio from diffdvr import Renderer, CameraOnASphere, Entropy, ColorMatches, Settings, setup_default_settings, \ ...
33,526
45.760112
149
py
DiffDVR
DiffDVR-master/pytests/tests/camera/test_camera_optimization.py
import numpy as np import torch import sys import os import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec import matplotlib.animation import tqdm # load pyrenderer from diffdvr import renderer_dtype_torch import pyrenderer from vis import lossvis from vis import cameravis def make_real3(vector): ...
10,423
37.043796
151
py
DiffDVR
DiffDVR-master/pytests/tests/camera/test_viewport_optimization.py
import numpy as np import torch import matplotlib.pyplot as plt import matplotlib import tqdm import re from typing import Optional from diffdvr import Renderer, CameraOnASphere, Entropy, ColorMatches, Settings, setup_default_settings, \ fibonacci_sphere, renderer_dtype_torch, renderer_dtype_np import pyrenderer de...
20,734
41.752577
124
py
DiffDVR
DiffDVR-master/pytests/tests/tf/test_tf_optimization.py
import numpy as np import torch import sys import os import matplotlib.pyplot as plt import matplotlib.animation import tqdm # load pyrenderer from diffdvr import make_real3 import pyrenderer from vis import tfvis # TF parameterization: # color by Sigmoid, opacity by SoftPlus class TransformTF(torch.nn.Module): de...
8,224
34
112
py
DiffDVR
DiffDVR-master/pytests/tests/tf/run_reconstruction.py
import sys import os sys.path.insert(0, os.getcwd()) import numpy as np import torch import os import matplotlib.pyplot as plt from matplotlib import gridspec from matplotlib.patches import Polygon import tqdm import imageio from diffdvr import Renderer, CameraOnASphere, Settings, setup_default_settings, \ fibon...
32,858
43.584803
146
py
DiffDVR
DiffDVR-master/pytests/tests/tf/train_styletransfer.py
""" Large hyperparameter training session """ import sys import os sys.path.append(os.getcwd()) import numpy as np import torch import os import tqdm import time import h5py import argparse import json from collections import defaultdict import subprocess import imageio from diffdvr import Renderer, CameraOnASphere,...
14,153
41.504505
130
py
DiffDVR
DiffDVR-master/pytests/tests/tf/train_meta.py
""" Large hyperparameter training session """ import sys import os sys.path.append(os.getcwd()) import numpy as np import torch import os import tqdm import time import h5py import argparse import json from collections import defaultdict import subprocess from diffdvr import Renderer, CameraOnASphere, Settings, setu...
11,824
39.635739
111
py
DiffDVR
DiffDVR-master/pytests/diffdvr/renderer.py
import torch import torch.nn as nn import numpy as np import time from diffdvr.utils import implies import pyrenderer class ProfileRenderer: def __init__(self): self.forward_ms = 0.0 self.forward_bytes = 0 self.backward_ms = 0.0 class Timer: def __init__(self, enable, cuda): s...
17,146
46.630556
140
py
DiffDVR
DiffDVR-master/pytests/diffdvr/settings.py
import torch import numpy as np import json import os from typing import Optional, NamedTuple from diffdvr.utils import make_real3, renderer_dtype_torch, renderer_dtype_np import pyrenderer """ Loads settings from .json file exported by the GUI """ class Settings: def __init__(self, file): self._filepat...
7,446
39.254054
96
py
DiffDVR
DiffDVR-master/pytests/diffdvr/priors.py
import torch from typing import Union, Sequence class SmoothnessPrior(torch.nn.Module): """ n-dimensional smoothness prior loss. For each dimension i, the value $\int (f'_i(x))^2 dx$ is computed, i.e. the first derivative along dimension i, squared and summed/averaged over the image """ def __init__(sel...
1,083
29.111111
85
py
DiffDVR
DiffDVR-master/pytests/diffdvr/utils.py
import atexit import torch import sys import os import numpy as np from typing import Tuple, Union try: import pyrenderer except ModuleNotFoundError: __newpath = os.path.abspath(os.path.join(os.path.split(__file__)[0], '../../bin')) sys.path.append(__newpath) print("Search pyrenderer in '%s'"%__newpath) impo...
2,830
30.808989
92
py
DiffDVR
DiffDVR-master/pytests/diffdvr/parametrizations.py
import torch import torch.nn.functional as F import numpy as np from typing import Sequence from diffdvr.utils import inverseSigmoid, inverseSoftplus import pyrenderer class VolumeDensities(torch.nn.Module): """ Default parametrization of the density volume: The input which is optimized for is in the full...
6,979
35.165803
86
py
DiffDVR
DiffDVR-master/pytests/diffdvr/__init__.py
from .utils import make_real3, make_real4, \ inverseSigmoid, InverseSigmoid, \ inverseSoftplus, InverseSoftplus, \ implies, toCHW, fibonacci_sphere, \ renderer_dtype_torch, renderer_dtype_np, \ cvector_to_numpy from .entropy import Entropy, ColorMatches from .settings import Settings, setup_default_setting...
524
25.25
65
py
DiffDVR
DiffDVR-master/pytests/diffdvr/entropy.py
import torch import numpy as np from typing import Optional, Union, Sequence import diffdvr.utils import pyrenderer class Entropy(torch.nn.Module): """ Computes the entropy of the input tensor: $H(x) = sum_i (p_i log_2(p_i) )$ where $p_i$ is the input tensor. """ def __init__(self, dim : Opti...
3,647
32.163636
83
py
DiffDVR
DiffDVR-master/pytests/losses/ssim.py
# Source: # https://github.com/jorge-pessoa/pytorch-msssim/blob/master/pytorch_msssim/__init__.py import torch import torch.nn.functional as F from math import exp import numpy as np def gaussian(window_size, sigma): gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in range(window_size...
4,707
32.15493
118
py
DiffDVR
DiffDVR-master/pytests/losses/tecogan.py
import torch import torch.nn as nn import torch.nn.functional as F import math # Input: B x C=7 x W x H # with B split in half between ground truth and prediction # with C=7, first three layers: RGB of the prediction/ground truth. # Last four layers: bilinear upscaled input image class TecoGANDiscriminator...
2,654
36.394366
102
py
DiffDVR
DiffDVR-master/pytests/losses/lossbuilder.py
import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo import torchvision.models as models from .ssim import MSSSIM, SSIM import losses.lpips as lpips class LossBuilder: def __init__(self, device): self.vgg_path = 'https://download.pytorch....
21,033
42.458678
140
py
DiffDVR
DiffDVR-master/pytests/losses/enhancenetlarge.py
import torch import torch.nn as nn import torch.nn.functional as F import math from .makelayers import _make_layers # Input: B x C=7 x W x H # with B split in half between ground truth and prediction # with C=7, first three layers: RGB of the prediction/ground truth. # Last four layers: bilinear upscaled ...
2,222
37.327586
102
py
DiffDVR
DiffDVR-master/pytests/losses/enhancenetsmall.py
import torch import torch.nn as nn import torch.nn.functional as F import math from .makelayers import _make_layers # Input: B x C=7 x W x H # with B split in half between ground truth and prediction # with C=7, first three layers: RGB of the prediction/ground truth. # Last four layers: bilinear upscaled ...
2,205
37.034483
102
py
DiffDVR
DiffDVR-master/pytests/losses/lpips/base_model.py
import os import torch from torch.autograd import Variable class BaseModel(): def __init__(self): pass; def name(self): return 'BaseModel' def initialize(self, use_gpu=True, gpu_ids=[0]): self.use_gpu = use_gpu self.gpu_ids = gpu_ids def forward(self): ...
1,542
26.070175
77
py
DiffDVR
DiffDVR-master/pytests/losses/lpips/utils.py
import numpy as np #from skimage.measure import compare_ssim import torch from torch.autograd import Variable def normalize_tensor(in_feat,eps=1e-10): norm_factor = torch.sqrt(torch.sum(in_feat**2,dim=1,keepdim=True)) return in_feat/(norm_factor+eps) def l2(p0, p1, range=255.): return .5*np.mean((p0 / ran...
4,288
33.312
80
py
DiffDVR
DiffDVR-master/pytests/losses/lpips/pretrained_networks.py
from collections import namedtuple import torch from torchvision import models as tv class squeezenet(torch.nn.Module): def __init__(self, requires_grad=False, pretrained=True): super(squeezenet, self).__init__() pretrained_features = tv.squeezenet1_1(pretrained=pretrained).features self.sl...
6,507
34.955801
109
py
DiffDVR
DiffDVR-master/pytests/losses/lpips/networks_basic.py
from __future__ import absolute_import import torch import torch.nn as nn from torch.autograd import Variable from . import pretrained_networks as pn from .utils import normalize_tensor, l2, tensor2tensorlab, tensor2np, tensor2im def spatial_average(in_tens, keepdim=True): return in_tens.mean([2,3],keepdim=kee...
7,325
39.032787
134
py
DiffDVR
DiffDVR-master/pytests/losses/lpips/__init__.py
import torch from . import dist_model #Source: https://github.com/richzhang/PerceptualSimilarity class PerceptualLoss(torch.nn.Module): def __init__(self, model='net-lin', net='alex', colorspace='rgb', spatial=False, use_gpu=True, gpu_ids=[0]): # VGG using our perceptually-learned weights (LPIPS metric) #...
1,398
33.975
172
py
DiffDVR
DiffDVR-master/pytests/losses/lpips/dist_model.py
from __future__ import absolute_import import os from collections import OrderedDict import numpy as np import torch from scipy.ndimage import zoom from torch.autograd import Variable from tqdm import tqdm from . import networks_basic as networks from .base_model import BaseModel from .utils import voc_ap, tensor2i...
11,636
40.709677
177
py
MoGPT
MoGPT-main/src/run_trainer_utterance_reordering.py
import datetime import os import pprint from argparse import ArgumentParser from pathlib import Path import pytorch_lightning as pl import torch from huggingface_hub import Repository from pytorch_lightning.loggers import WandbLogger from transformers import AutoTokenizer from transformers.utils import get_full_repo_n...
16,616
39.137681
153
py
MoGPT
MoGPT-main/src/run_trainer_vanilla_gpt2.py
import datetime import os import pprint from argparse import ArgumentParser from pathlib import Path import pytorch_lightning as pl import torch from huggingface_hub import Repository from pytorch_lightning.loggers import WandbLogger from transformers import AutoTokenizer from transformers.utils import get_full_repo_n...
13,800
36.810959
152
py
MoGPT
MoGPT-main/src/run_trainer_utterance_masking.py
import datetime import os import pprint from argparse import ArgumentParser from pathlib import Path import pytorch_lightning as pl import torch import wandb from huggingface_hub import Repository from pytorch_lightning.loggers import WandbLogger from transformers import AutoTokenizer from transformers.utils import ge...
16,784
39.155502
190
py
MoGPT
MoGPT-main/src/data_modules/base.py
import json import os from pathlib import Path from typing import Callable, Dict, Optional, Union import pytorch_lightning as pl # from datasets import Dataset from torch.utils.data import DataLoader, Dataset from transformers import PreTrainedTokenizerBase class LoadDataset(Dataset): def __init__( self...
11,395
36.486842
161
py
MoGPT
MoGPT-main/src/data_modules/token_utterance_reordering.py
import copy from itertools import chain from itertools import repeat from typing import Callable, Optional from typing import Dict, List import numpy as np import torch from torch.nn.utils.rnn import pad_sequence from data_modules.base import TransformerDataModule from data_modules.vanilla_gpt2 import DataCollatorWit...
21,315
41.209901
163
py
MoGPT
MoGPT-main/src/data_modules/vanilla_gpt2.py
from itertools import chain from itertools import repeat from typing import Callable, Optional from typing import Dict, List import torch from torch.nn.utils.rnn import pad_sequence from data_modules.base import TransformerDataModule class DataCollatorWithPadding: def __init__( self, padding_ind...
11,982
37.905844
153
py
MoGPT
MoGPT-main/src/data_modules/binary_utterance_masking.py
import copy import numpy as np import torch from data_modules.base import TransformerDataModule from data_modules.vanilla_gpt2 import DataCollatorWithPadding from itertools import chain from itertools import repeat from nltk.corpus import wordnet from torch.nn.utils.rnn import pad_sequence from transformers import pipe...
26,630
42.729064
176
py
MoGPT
MoGPT-main/src/data_modules/binary_utterance_reordering.py
import copy from itertools import chain from itertools import repeat from typing import Callable, Optional from typing import Dict, List import numpy as np import torch from torch.nn.utils.rnn import pad_sequence from data_modules.base import TransformerDataModule from data_modules.vanilla_gpt2 import DataCollatorWit...
21,490
41.556436
163
py
MoGPT
MoGPT-main/src/data_modules/token_utterance_masking.py
import copy from itertools import chain from itertools import repeat from typing import Callable, Optional from typing import Dict, List import numpy as np import torch from torch.nn.utils.rnn import pad_sequence from data_modules.base import TransformerDataModule from data_modules.vanilla_gpt2 import DataCollatorWit...
24,203
41.537786
176
py
MoGPT
MoGPT-main/src/models/base.py
from pathlib import Path from typing import Any, Callable, Dict, IO, List, Optional, Tuple, Union import pytorch_lightning as pl import torch import transformers from pytorch_lightning.utilities import rank_zero_warn from transformers import AutoConfig from transformers import AutoModel from transformers import PreTra...
8,107
39.338308
127
py
MoGPT
MoGPT-main/src/models/lite_gpt2.py
import math import torch from transformers import AutoModel from transformers import GPT2LMHeadModel from models.base import LiteTransformer class LiteGPT2LMHeadModel(LiteTransformer): def __init__( self, downstream_model_type: AutoModel = GPT2LMHeadModel, *args, **kwargs ) ...
3,182
28.747664
84
py
MoGPT
MoGPT-main/src/models/gpt2_dh.py
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn import torch.utils.checkpoint from torch.nn import CrossEntropyLoss from transformers.activations import gelu from transformers.models.gpt2.modeling_gpt2 import GPT2Model from transformers.models.gpt2.modelin...
8,390
38.21028
119
py
MoGPT
MoGPT-main/src/models/lite_gpt2_dh.py
import math import torch from transformers import AutoModel from models.base import LiteTransformer from models.gpt2_dh import GPT2DoubleHeadsModel class LiteGPT2DoubleHeadsModel(LiteTransformer): def __init__( self, *args, downstream_model_type: AutoModel = GPT2DoubleHeadsModel, ...
4,061
33.423729
94
py
MoGPT
MoGPT-main/src/utils/callbacks.py
import json import os import sys from argparse import Namespace from typing import Optional import pytorch_lightning as pl from huggingface_hub import Repository from pytorch_lightning.callbacks import Callback from pytorch_lightning.loggers import WandbLogger from transformers import PreTrainedTokenizerBase class G...
3,294
38.698795
143
py
MoGPT
MoGPT-main/src/utils/deepspeed.py
# Copyright The PyTorch Lightning team. # # 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 applicable law or agreed to i...
1,176
34.666667
110
py
MoGPT
MoGPT-main/src/utils/__init__.py
import torch from nltk.corpus import wordnet def word_synonym(token, sentence=None, by="None", model=None, tokenizer=None, device="cpu", topk=5): synonyms = [] antonyms = [] if by.upper() == "TRANSFORMER": model = model sent_token = tokenizer.tokenize(sentence) mask_index = sent_t...
928
34.730769
100
py
MoGPT
MoGPT-main/src/utils/imports.py
# Copyright The PyTorch Lightning team. # # 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 applicable law or agreed to i...
1,047
44.565217
113
py
EMSAFormer
EMSAFormer-main/main.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> .. codeauthor:: Mona Koehler <mona.koehler@tu-ilmenau.de> """ from typing import Tuple from copy import deepcopy from datetime import datetime impor...
26,219
37.110465
80
py
EMSAFormer
EMSAFormer-main/inference_dataset.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ from copy import deepcopy from datetime import datetime from functools import partial import getpass import json import os from pprint import pprint import sys from time import time import warnings import cv2 import numpy...
30,738
38.05845
153
py
EMSAFormer
EMSAFormer-main/inference_samples.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Mona Koehler <mona.koehler@tu-ilmenau.de> .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> """ from glob import glob import os import cv2 import matplotlib.pyplot as plt import nump...
8,393
31.534884
96
py
EMSAFormer
EMSAFormer-main/emsaformer/lr_scheduler.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ from torch.optim.lr_scheduler import OneCycleLR KNOWN_LR_SCHEDULERS = ('onecycle', ) LrSchedulerType = OneCycleLR def get_lr_scheduler(args, optimizer) -> LrSchedulerType: name = args.learning_rate_scheduler n_...
818
23.088235
70
py
EMSAFormer
EMSAFormer-main/emsaformer/preprocessing.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ from typing import Optional, Tuple from nicr_mt_scene_analysis.data.preprocessing import CloneEntries from nicr_mt_scene_analysis.data.preproces...
9,116
37.795745
84
py
EMSAFormer
EMSAFormer-main/emsaformer/weights.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ import torch from nicr_scene_analysis_datasets import ScanNet def load_weights(args, model, state_dict, verbose=True): # this function accounts for: # - renamed keys, e.g., fused_encoders.* -> encoder.* # - m...
5,946
47.349593
82
py
EMSAFormer
EMSAFormer-main/emsaformer/args.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> .. codeauthor:: Mona Koehler <mona.koehler@tu-ilmenau.de> """ import argparse as ap import json import os import shlex import shutil import socket f...
60,757
40.930987
93
py
EMSAFormer
EMSAFormer-main/emsaformer/model.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ from typing import Any, Dict from collections import ChainMap from nicr_mt_scene_analysis.model.block import get_block_class from nicr_mt_scene...
9,460
39.431624
96
py
EMSAFormer
EMSAFormer-main/emsaformer/data.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ from typing import Optional, Iterable, Tuple from collections import OrderedDict from copy import deepcopy from dataclasses import asdict from f...
19,253
38.946058
87
py
EMSAFormer
EMSAFormer-main/emsaformer/decoder.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ from typing import Tuple, Union from torch import nn from nicr_mt_scene_analysis.model.activation import get_activation_class from nicr_mt_scen...
9,414
45.608911
96
py
EMSAFormer
EMSAFormer-main/emsaformer/optimizer.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ from typing import Union from torch.optim import Adam from torch.optim import AdamW from torch.optim import RAdam from torch.optim import SGD KNOWN_OPTIMIZERS = ('adam', 'adamw', 'radam', 'sgd') OptimizerType = Union[Ad...
1,424
22.75
63
py
EMSAFormer
EMSAFormer-main/emsaformer/tests/test_interface_emsaformer_model.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> """ import os from nicr_mt_scene_analysis.testing.onnx import export_onnx_model import pytest import torch from emsaformer.args import ArgParserEMS...
6,571
36.554286
105
py
EMSAFormer
EMSAFormer-main/emsaformer/tests/test_interface_emsanet_model.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ import os from nicr_mt_scene_analysis.testing.onnx import export_onnx_model import pytest import torch from emsaformer.args import ArgParserEMSAFormer from emsaformer.data import get_dataset from emsaformer.model import EM...
6,470
35.559322
86
py
EMSAFormer
EMSAFormer-main/emsaformer/tests/test_emsanet_model_weights.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Mona Koehler <mona.koehler@tu-ilmenau.de> """ from nicr_mt_scene_analysis.testing.onnx import export_onnx_model import onnx import torch from emsaformer.args import ArgParserEMSAFormer from emsaformer.data import get_datahelper from emsaformer.model import EMSAFormer def t...
2,485
33.054795
80
py
EMSAFormer
EMSAFormer-main/emsaformer/tests/test_interface_preprocessing.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ from functools import partial from nicr_mt_scene_analysis.data import mt_collate from nicr_mt_scene_analysis.data import CollateIgnoredDict from nicr_mt_scene_analysis.testing.preprocessing import show_results from nicr_mt_...
3,402
35.98913
75
py
EMSAFormer
EMSAFormer-main/emsaformer/tests/test_interface_decoders.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ import os import pytest import torch from nicr_mt_scene_analysis.testing.onnx import export_onnx_model from emsaformer.args import ArgParserE...
8,676
36.240343
79
py
EMSAFormer
EMSAFormer-main/emsaformer/tests/test_semantic_loss.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Mona Koehler <mona.koehler@tu-ilmenau.de> """ import numpy as np import torch from torch import nn from nicr_mt_scene_analysis.loss.ce import CrossEntropyLossSemantic DEVICE = 'cuda:0' if torch.cuda.is_available() else 'cpu' # copied from: https://github.com/TUI-NICR/ESAN...
3,614
33.759615
80
py
EMSAFormer
EMSAFormer-main/emsaformer/tests/test_metrics_with_model.py
# -*- coding: utf-8 -*- """ .. codeauthor:: Soehnke Fischedick <soehnke-benedikt.fischedick@tu-ilmenau.de> """ import json import os import torch import numpy as np import pytest import PIL.Image as Image from tqdm import tqdm from nicr_mt_scene_analysis import metric from nicr_mt_scene_analysis.data import move_batc...
9,468
39.465812
120
py
dilation
dilation-master/test.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, division import argparse import caffe import cv2 import numpy as np import os from os.path import exists, join, split, splitext import network import util __author__ = 'Fisher Yu' __copyright__ = 'Copyright (c) 2016, Fisher Yu' __em...
15,221
37.536709
90
py
dilation
dilation-master/network.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, division from caffe import layers as L from caffe import params as P __author__ = 'Fisher Yu' __copyright__ = 'Copyright (c) 2016, Fisher Yu' __email__ = 'i@yf.io' __license__ = 'MIT' def make_image_label_data(image_list_path, lab...
8,068
40.80829
78
py
dilation
dilation-master/predict.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, division import argparse import caffe import cv2 import json import numba import numpy as np from os.path import dirname, exists, join, splitext import sys import util __author__ = 'Fisher Yu' __copyright__ = 'Copyright (c) 2016, Fi...
5,214
37.91791
80
py
dilation
dilation-master/train.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, division import argparse import caffe from caffe.proto import caffe_pb2 import os from os.path import dirname, exists, join import subprocess import network __author__ = 'Fisher Yu' __copyright__ = 'Copyright (c) 2016, Fisher Yu' _...
9,918
37.898039
79
py
mvgrl
mvgrl-master/utils.py
import numpy as np import networkx as nx import torch from scipy.linalg import fractional_matrix_power, inv import scipy.sparse as sp def compute_ppr(graph: nx.Graph, alpha=0.2, self_loop=True): a = nx.convert_matrix.to_numpy_array(graph) if self_loop: a = a + np.eye(a.shape[0]) ...
2,725
33.948718
97
py
mvgrl
mvgrl-master/node/train.py
import numpy as np import scipy.sparse as sp import torch import torch.nn as nn from utils import sparse_mx_to_torch_sparse_tensor from node.dataset import load # Borrowed from https://github.com/PetarV-/DGI class GCN(nn.Module): def __init__(self, in_ft, out_ft, bias=True): super(GCN, self).__init__() ...
8,554
27.708054
82
py
mvgrl
mvgrl-master/graph/train.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from sklearn.model_selection import GridSearchCV, StratifiedKFold from graph.dataset import load class GCNLayer(nn.Module): def __init__(self, in_ft, out_ft, bias=True): super(GCNLayer, self).__init__() self.fc =...
10,865
30.314121
95
py
MLCVNet
MLCVNet-master/demo.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Demo of using MLCVNet 3D object detector to detect objects from a point cloud. """ import os import sys import numpy as np import argpar...
4,080
40.642857
133
py
MLCVNet
MLCVNet-master/eval.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Evaluation routine for 3D object detection with SUN RGB-D and ScanNet. """ import os import sys import numpy as np from datetime import ...
8,639
44.957447
153
py
MLCVNet
MLCVNet-master/train.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Training routine for 3D object detection with SUN RGB-D or ScanNet. Sample usage: python train.py --dataset sunrgbd --log_dir log_sunrgb...
14,735
43.385542
153
py
MLCVNet
MLCVNet-master/scannet/scannet_detection_dataset.py
# coding: utf-8 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Dataset for object bounding box regression. An axis aligned bounding box is parameterized by (cx,cy,cz) and (dx,dy,dz) wh...
10,395
45.204444
108
py
MLCVNet
MLCVNet-master/models/voting_module.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. ''' Voting module: generate votes from XYZ and features of seed points. Date: July, 2019 Author: Charles R. Qi and Or Litany ''' import tor...
3,026
39.36
93
py
MLCVNet
MLCVNet-master/models/dump_helper.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch import os import sys BASE_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_DIR = os.path.dirname(BASE_DI...
6,654
48.664179
153
py
MLCVNet
MLCVNet-master/models/backbone_module.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F import numpy as np import sys import os BASE_DIR = os.path.dirname(os.pat...
4,912
33.356643
129
py
MLCVNet
MLCVNet-master/models/mlcvnet.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Deep hough voting network for 3D object detection in point clouds. Author: Charles R. Qi and Or Litany """ import torch import torch.nn...
5,057
34.87234
119
py
MLCVNet
MLCVNet-master/models/loss_helper.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import numpy as np import sys import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_DIR = o...
12,245
47.788845
185
py
MLCVNet
MLCVNet-master/models/ap_helper.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Helper functions and class to calculate Average Precisions for 3D object detection. """ import os import sys import numpy as np import to...
14,467
48.547945
177
py
MLCVNet
MLCVNet-master/models/CGNL.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 17 22:59:27 2019 @author: qian """ # Non-local block using embedded gaussian # Code from # https://github.com/AlexHex7/Non-local_pytorch/blob/master/Non-Local_pytorch_0.3.1/lib/non_local_embedded_gaussian.py import math import torch from torch impo...
10,949
29.082418
118
py
MLCVNet
MLCVNet-master/models/proposal_module.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F import numpy as np import os import sys BASE_DIR = os.path.dirname(os.path...
6,740
50.068182
217
py
MLCVNet
MLCVNet-master/pointnet2/setup.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension import glob _ext_src_root = "_ext_src" _ext...
928
28.03125
83
py
MLCVNet
MLCVNet-master/pointnet2/pointnet2_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. ''' Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch ''' from __future__ import ( division, absolute_import, w...
12,071
27.606635
144
py
MLCVNet
MLCVNet-master/pointnet2/pointnet2_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. ''' Testing customized ops. ''' import torch from torch.autograd import gradcheck import numpy as np import os import sys BASE_DIR = os.pat...
1,011
28.764706
83
py
MLCVNet
MLCVNet-master/pointnet2/pointnet2_modules.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. ''' Pointnet2 layers. Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch Extended with the following: 1. Uniform sampling in...
17,609
32.930636
135
py
MLCVNet
MLCVNet-master/pointnet2/pytorch_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. ''' Modified based on Ref: https://github.com/erikwijmans/Pointnet2_PyTorch ''' import torch import torch.nn as nn from typing import List, T...
7,501
24.090301
79
py
MLCVNet
MLCVNet-master/utils/tf_visualizer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. '''Code adapted from https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix''' import os import time BASE_DIR = os.path.dirname(os.path.absp...
1,874
36.5
90
py
MLCVNet
MLCVNet-master/utils/metric_util.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Utility functions for metric evaluation. Author: Or Litany and Charles R. Qi """ import os import sys import torch BASE_DIR = os.path.d...
5,891
33.057803
106
py
MLCVNet
MLCVNet-master/utils/nn_distance.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Chamfer distance in Pytorch. Author: Charles R. Qi """ import torch import torch.nn as nn import numpy as np def huber_loss(error, del...
2,924
29.789474
89
py
pFedGate
pFedGate-main/run_experiment.py
"""Run Experiment This script allows to run one federated learning experiment; the experiment name, the method and the number of clients/tasks should be precised along side with the hyper-parameters of the experiment. The results of the experiment (i.e., training logs) are written to ./logs/ folder. This file can al...
11,307
36.197368
117
py
pFedGate
pFedGate-main/aggregator.py
import logging import os import time import random from abc import ABC, abstractmethod from copy import deepcopy import numpy as np import numpy.linalg as LA import wandb from sklearn.metrics import pairwise_distances from sklearn.cluster import AgglomerativeClustering from utils.torch_utils import * class Aggreg...
28,793
32.716628
122
py
pFedGate
pFedGate-main/datasets.py
import os import pickle import string import torch from torchvision.datasets import CIFAR10, CIFAR100, EMNIST from torchvision.transforms import Compose, ToTensor, Normalize from torch.utils.data import Dataset import numpy as np from PIL import Image class TabularDataset(Dataset): """ Constructs a torch.ut...
11,379
25.588785
120
py
pFedGate
pFedGate-main/client.py
import logging import torch.nn.functional as F from copy import deepcopy import wandb from utils.torch_utils import * class Client(object): r"""Implements one clients Attributes ---------- learners_ensemble n_learners train_iterator val_iterator test_iterator train_loader ...
8,689
30.258993
118
py
pFedGate
pFedGate-main/pFedGate/gated_learner.py
import copy import pickle import torch from torch.nn.functional import gumbel_softmax import numpy as np from learners.learner import Learner from models.knapsack_solver import KnapsackSolver01, KnapsackSolverFractional from utils.sparse_factor_schedule import SparsityReduceLROnPlateauScheduler from utils.torch_utils...
24,477
51.527897
134
py
pFedGate
pFedGate-main/pFedGate/gate_aggregator.py
import copy import logging import os import numpy as np import torch import wandb from aggregator import Aggregator from utils.torch_utils import average_model_of_learners, average_torch_modules, average_torch_state_dict_online, \ mean_torch_state_dict, \ copy_side_info, copy_model class pFedGateAggregator(...
30,279
56.348485
187
py
pFedGate
pFedGate-main/pFedGate/gated_client.py
import logging import torch import wandb from client import Client class pFedGateClient(Client): r""" Implements client for the proposed pFedGate method """ def __init__( self, learners_ensemble, train_iterator, val_iterator, test_iterator...
10,023
42.393939
123
py
pFedGate
pFedGate-main/models/nn_nets.py
import torch.autograd import torch.nn.functional as F import torchvision.models as models import torch from torch import nn from torch.hub import load_state_dict_from_url from models.adapted_op import AdaptedLinear class DifferentiableRoundFun(torch.autograd.Function): @staticmethod def forward(ctx, input...
1,702
25.609375
68
py
pFedGate
pFedGate-main/models/knapsack_solver.py
import numpy as np import torch import itertools from numba import jit class KnapsackSolver01(object): """ A knapsack problem solver implementation for 0-1 Knapsack with large Weights, ref: https://www.geeksforgeeks.org/knapsack-with-large-weights/ time complexity: O(value_sum_max * item_num_max) = O...
8,514
40.536585
118
py
pFedGate
pFedGate-main/models/adapted_op.py
""" Including adapted forward using adapted parameters, such that the gradients can bp to gating layers that change the original model parameters """ from typing import Optional, Callable, List import torch from torch import nn, Tensor from torch.nn import functional as F from torch.nn.modules.utils import _pair fr...
9,275
43.171429
114
py
pFedGate
pFedGate-main/models/switchable_norm.py
# Switchable-Norm from official implementation # https://github.com/switchablenorms/Switchable-Normalization/blob/master/devkit/ops/switchable_norm.py import torch import torch.nn as nn class SwitchNorm1d(nn.Module): def __init__(self, num_features, eps=1e-5, momentum=0.997, using_moving_average=True): s...
8,988
39.129464
104
py