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 |
|---|---|---|---|---|---|---|
interactive-image2video-synthesis | interactive-image2video-synthesis-main/models/discriminator.py | import torch
from torch import nn
from torch.optim import Adam
import functools
from torch.nn.utils import spectral_norm
import math
import numpy as np
from utils.general import get_member
from models.blocks import SPADE
class GANTrainer(object):
def __init__(self, config, load_fn,logger,spatial_size=128, paral... | 17,349 | 37.988764 | 191 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/models/latent_flow_net.py | import torch
from torch import nn
from torch.nn import functional as F
import numpy as np
import math
from models.blocks import Conv2dBlock, ResBlock, AdaINLinear, NormConv2d,ConvGRU
class OscillatorModel(nn.Module):
def __init__(self,spatial_size,config,n_no_motion=2, logger=None):
super().__init__()
... | 45,992 | 39.274081 | 181 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/models/blocks.py | import torch
from torch import nn
from torch.nn import functional as F
from torch.nn.utils import weight_norm, spectral_norm
from torch.nn import init
class ResBlock(nn.Module):
def __init__(
self,
dim_in,
dim_out,
norm="in",
activation="elu",
pad_type="zero",
... | 17,622 | 33.690945 | 143 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/experiments/experiment.py | from abc import abstractmethod
import torch
import wandb
import os
from os import path
from glob import glob
import numpy as np
from utils.general import get_logger
WANDB_DISABLE_CODE = True
class Experiment:
def __init__(self, config:dict, dirs: dict, device):
self.parallel = isinstance(device, list)
... | 6,865 | 40.361446 | 140 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/experiments/fixed_length_model.py | import torch
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.optim import Adam
from ignite.engine import Engine, Events
from ignite.handlers import ModelCheckpoint
from ignite.contrib.handlers import ProgressBar
from ignite.metrics import Average, MetricUsage
import numpy as np
impo... | 57,839 | 54.776278 | 210 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/experiments/sequence_model.py | import torch
from torch.utils.data import DataLoader
from torch.optim import Adam
from ignite.engine import Engine, Events
from ignite.handlers import ModelCheckpoint
from ignite.contrib.handlers import ProgressBar
from ignite.metrics import Average, MetricUsage
import numpy as np
import wandb
from functools import par... | 58,565 | 53.581547 | 210 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/losses.py | import torch
from torch import nn
from torchvision.models import vgg19
from collections import namedtuple
from operator import mul
from functools import reduce
from utils.general import get_member
VGGOutput = namedtuple(
"VGGOutput",
["input", "relu1_2", "relu2_2", "relu3_2", "relu4_2", "relu5_2"],
)
StyleLay... | 9,190 | 33.423221 | 210 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/metric_fvd.py | import numpy as np
import argparse
from os import path
import torch
import ssl
from glob import glob
from natsort import natsorted
ssl._create_default_https_context = ssl._create_unverified_context
import cv2
from utils.metrics import compute_fvd
from utils.general import get_logger
if __name__ == '__main__':
pa... | 3,569 | 30.59292 | 107 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/testing.py | import numpy as np
import torch
from skimage.metrics import structural_similarity as ssim
import cv2
import math
import imutils
import matplotlib.pyplot as plt
import wandb
from os import path
import math
def make_flow_grid(src, poke, pred, tgt, n_logged, flow=None):
"""
:param src:
:param poke:
:para... | 33,806 | 43.424442 | 204 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/flownet_loader.py | import torch
from torch.nn import functional as F
from PIL import Image
from models.flownet2.models import *
from torchvision import transforms
import matplotlib.pyplot as plt
import argparse
from utils.general import get_gpu_id_with_lowest_memory
class FlownetPipeline:
def __init__(self):
super(Flownet... | 4,882 | 37.753968 | 151 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/metrics.py | import torch
from torch import nn
from torch.nn import functional as F
from torchvision.models import inception_v3
import numpy as np
from scipy import linalg
from skimage.metrics import peak_signal_noise_ratio as compare_psnr
from skimage.metrics import structural_similarity as ssim
from pytorch_lightning.metrics impo... | 12,279 | 33.985755 | 153 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/general.py | import torch
import os
import subprocess
import logging
import yaml
import logging.config
import inspect
from os import walk
import numpy as np
import coloredlogs
import multiprocessing as mp
from threading import Thread
from queue import Queue
from collections import abc
import cv2
from torch import nn
# import kornia... | 10,061 | 33.108475 | 139 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/data/flow_dataset.py | from os import path
import numpy as np
import pickle
from copy import deepcopy
import torch
from torch.nn import functional as F
from torch.utils.data import Dataset
from torchvision import transforms as tt
from tqdm import tqdm
import cv2
from natsort import natsorted
import os
from glob import glob
from utils.gener... | 32,596 | 41.947299 | 192 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/data/base_dataset.py | from functools import partial
from itertools import chain
import torch
from torch.nn import functional as F
from torch.utils.data import Dataset
from torchvision import transforms as T
from torchvision.transforms import functional as FT
from PIL import Image
import numpy as np
from abc import abstractmethod
import cv2
... | 36,611 | 46.119691 | 255 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/data/__init__.py | from data.base_dataset import BaseDataset
from torchvision import transforms as tt
from data.flow_dataset import PlantDataset, IperDataset,Human36mDataset, VegetationDataset, LargeVegetationDataset, TaichiDataset
# add key value pair for datasets here, all datasets should inherit from base_dataset
__datasets__ = {"Ip... | 2,041 | 29.029412 | 129 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/data/prepare_dataset.py | import os
import cv2
import re
import argparse
import torch
import numpy as np
from os import path, makedirs
import pickle
from tqdm import tqdm
from glob import glob
from natsort import natsorted
import yaml
import multiprocessing as mp
from multiprocessing import Process
from functools import partial
from dotmap impo... | 23,809 | 36.974482 | 185 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/data/samplers.py | import numpy as np
from torch.utils.data import BatchSampler,RandomSampler,SequentialSampler, WeightedRandomSampler
from data.base_dataset import BaseDataset
from data.flow_dataset import PlantDataset
class SequenceSampler(BatchSampler):
def __init__(self, dataset:BaseDataset, batch_size, shuffle, drop_last):
... | 5,888 | 38.26 | 158 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/tacotron2/train_tacotron2.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 18,412 | 33.807183 | 96 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/multiband_melgan_hf/train_multiband_melgan_hf.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 19,162 | 33.40395 | 137 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/fastspeech/train_fastspeech.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 13,591 | 33.762148 | 95 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/fastspeech2_libritts/train_fastspeech2.py | # -*- coding: utf-8 -*-
# Copyright 2020 TensorFlowTTS 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 applicab... | 17,059 | 33.816327 | 96 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/melgan/train_melgan.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 16,989 | 31.48566 | 98 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/melgan_stft/train_melgan_stft.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 13,562 | 32.655087 | 98 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/multiband_melgan/train_multiband_melgan.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 18,014 | 33.379771 | 112 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/fastspeech2/train_fastspeech2.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 14,446 | 33.562201 | 96 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/hifigan/train_hifigan.py | # -*- coding: utf-8 -*-
# Copyright 2020 TensorFlowTTS 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 applicabl... | 10,464 | 31.101227 | 88 | py |
TensorFlowTTS | TensorFlowTTS-master/examples/parallel_wavegan/train_parallel_wavegan.py | # -*- coding: utf-8 -*-
# Copyright 2020 TensorFlowTTS 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 applicab... | 15,699 | 32.052632 | 126 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/models/base_model.py | # -*- coding: utf-8 -*-
# Copyright 2020 TensorFlowTTS 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 applicab... | 1,131 | 32.294118 | 74 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/models/parallel_wavegan.py | # -*- coding: utf-8 -*-
# Copyright 2020 The TensorFlowTTS Team and Tomoki Hayashi (@kan-bayashi)
#
# 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/LICENS... | 18,663 | 32.508079 | 112 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/models/melgan.py | # -*- coding: utf-8 -*-
# Copyright 2020 The MelGAN Authors and Minh Nguyen (@dathudeptrai)
#
# 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
... | 17,807 | 34.687375 | 106 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/models/tacotron2.py | # -*- coding: utf-8 -*-
# Copyright 2020 The Tacotron-2 Authors, Minh Nguyen (@dathudeptrai), Eren Gölge (@erogol) and Jae Yoo (@jaeyoo)
#
# 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
#
# ... | 37,180 | 34.716619 | 112 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/models/mb_melgan.py | # -*- coding: utf-8 -*-
# Copyright 2020 The Multi-band MelGAN Authors , Minh Nguyen (@dathudeptrai) and Tomoki Hayashi (@kan-bayashi)
#
# 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
#
# ... | 6,890 | 34.704663 | 110 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/models/hifigan.py | # -*- coding: utf-8 -*-
# Copyright 2020 The Hifigan Authors and TensorflowTTS 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
#
# Unl... | 13,272 | 33.928947 | 91 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/models/fastspeech2.py | # -*- coding: utf-8 -*-
# Copyright 2020 The FastSpeech2 Authors and Minh Nguyen (@dathudeptrai)
#
# 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... | 12,399 | 38.616613 | 100 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/models/fastspeech.py | # -*- coding: utf-8 -*-
# Copyright 2020 The FastSpeech Authors, The HuggingFace Inc. team and Minh Nguyen (@dathudeptrai)
#
# 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.a... | 33,971 | 36.372937 | 102 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/optimizers/adamweightdecay.py | # -*- coding: utf-8 -*-
# Copyright 2019 The TensorFlow 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://www.apache.org/licenses/LICENSE-2.0
#
# Un... | 6,854 | 37.511236 | 88 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/utils/utils.py | # -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi
# MIT License (https://opensource.org/licenses/MIT)
"""Utility functions."""
import fnmatch
import os
import re
import tempfile
from pathlib import Path
import tensorflow as tf
MODEL_FILE_NAME = "model.h5"
CONFIG_FILE_NAME = "config.yml"
PROCESSOR_FILE_NAME =... | 3,053 | 30.163265 | 80 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/utils/group_conv.py | # -*- coding: utf-8 -*-
# This code is copy from https://github.com/tensorflow/tensorflow/pull/36773.
"""Group Convolution Modules."""
from tensorflow.python.framework import tensor_shape
from tensorflow.python.keras import activations, constraints, initializers, regularizers
from tensorflow.python.keras.engine.base_l... | 23,944 | 41.989228 | 88 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/utils/griffin_lim.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 6,824 | 39.868263 | 88 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/utils/weight_norm.py | # -*- coding: utf-8 -*-
# Copyright 2019 The TensorFlow Probability Authors and Minh Nguyen (@dathudeptrai)
#
# 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/licen... | 7,216 | 38.010811 | 102 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/losses/stft.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 5,179 | 33.533333 | 97 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/losses/spectrogram.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 2,697 | 31.902439 | 83 | py |
TensorFlowTTS | TensorFlowTTS-master/tensorflow_tts/trainers/base_trainer.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 36,562 | 35.165183 | 113 | py |
TensorFlowTTS | TensorFlowTTS-master/test/test_fastspeech.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 2,995 | 34.247059 | 86 | py |
TensorFlowTTS | TensorFlowTTS-master/test/test_tacotron2.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 5,329 | 34.533333 | 87 | py |
TensorFlowTTS | TensorFlowTTS-master/test/test_melgan_layers.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 2,965 | 30.892473 | 113 | py |
TensorFlowTTS | TensorFlowTTS-master/test/test_fastspeech2.py | # -*- coding: utf-8 -*-
# Copyright 2020 Minh Nguyen (@dathudeptrai)
#
# 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 ... | 4,805 | 35.969231 | 88 | py |
sgmcmc_ssm_code | sgmcmc_ssm_code-master/sgmcmc_ssm/sgmcmc_sampler.py | import numpy as np
import pandas as pd
import time
from datetime import timedelta
import logging
from .evaluator import BaseEvaluator
logger = logging.getLogger(name=__name__)
NOISE_NUGGET=1e-9
# SGMCMCSampler
class SGMCMCSampler(object):
""" Base Class for SGMCMC with Time Series """
def __init__(self, **kwa... | 82,434 | 39.789213 | 86 | py |
CCasGNN | CCasGNN-main/layers.py | #encoding: utf-8
import torch
from torch_geometric.nn import GCNConv, GATConv
from math import sqrt
class Positional_GAT(torch.nn.Module):
def __init__(self, in_channels, out_channels, n_heads, location_embedding_dim, filters_1, filters_2, dropout):
super(Positional_GAT, self).__init__()
self.in... | 6,309 | 41.635135 | 180 | py |
CCasGNN | CCasGNN-main/CCasGNN.py | #encoding: utf-8
import torch
import json
import numpy as np
import copy
import time
import sys
import math
from layers import Positional_GCN, MultiHeadGraphAttention, dens_Net, Positional_GAT, fuse_gate
import scipy.stats as sci
class CCasGNN(torch.nn.Module):
def __init__(self, args):
super(CCasGNN, se... | 13,767 | 50.373134 | 136 | py |
pyEPR | pyEPR-master/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or module... | 7,220 | 33.716346 | 242 | py |
FUNIT | FUNIT-master/test_k_shot.py | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license
(https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import os
import numpy as np
from PIL import Image
import torch
import torch.backends.cudnn as cudnn
from torchvision import transforms
from ut... | 2,618 | 31.7375 | 80 | py |
FUNIT | FUNIT-master/utils.py | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license
(https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import os
import yaml
import time
import torch
from torch.utils.data import DataLoader
from torchvision import transforms
import torchvision.uti... | 7,743 | 32.37931 | 77 | py |
FUNIT | FUNIT-master/data.py | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license
(https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import os.path
from PIL import Image
import torch.utils.data as data
def default_loader(path):
return Image.open(path).convert('RGB')
de... | 1,913 | 29.870968 | 76 | py |
FUNIT | FUNIT-master/networks.py | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license
(https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import numpy as np
import torch
from torch import nn
from torch import autograd
from blocks import LinearBlock, Conv2dBlock, ResBlocks, ActFirs... | 10,860 | 39.830827 | 78 | py |
FUNIT | FUNIT-master/funit_model.py | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license
(https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import copy
import torch
import torch.nn as nn
from networks import FewShotGen, GPPatchMcResDis
def recon_criterion(predict, target):
ret... | 5,659 | 41.238806 | 85 | py |
FUNIT | FUNIT-master/train.py | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license
(https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import torch
import os
import sys
import argparse
import shutil
from tensorboardX import SummaryWriter
from utils import get_config, get_train_... | 5,178 | 37.93985 | 78 | py |
FUNIT | FUNIT-master/trainer.py | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license
(https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import copy
import os
import math
import torch
import torch.nn as nn
import torch.nn.init as init
from torch.optim import lr_scheduler
from fun... | 6,871 | 39.662722 | 79 | py |
FUNIT | FUNIT-master/blocks.py | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license
(https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import torch
import torch.nn.functional as F
from torch import nn
class ResBlocks(nn.Module):
def __init__(self, num_blocks, dim, norm, act... | 6,986 | 34.647959 | 79 | py |
SimSiam-91.9-top1-acc-on-CIFAR10 | SimSiam-91.9-top1-acc-on-CIFAR10-main/main.py | import argparse
import time
import math
from os import path, makedirs
import torch
from torch import optim
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter
from torch.backends import cudnn
from torchvision import datasets
from torchvision import transforms
from simsiam.loader ... | 9,087 | 33.687023 | 99 | py |
SimSiam-91.9-top1-acc-on-CIFAR10 | SimSiam-91.9-top1-acc-on-CIFAR10-main/main_lincls.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import builtins
import os
import random
import shutil
import time
import warnings
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dis... | 20,587 | 38.066414 | 95 | py |
SimSiam-91.9-top1-acc-on-CIFAR10 | SimSiam-91.9-top1-acc-on-CIFAR10-main/simsiam/model_factory.py | from torch import nn
from .resnet_cifar import ResNet18, ResNet34, ResNet50, ResNet101, ResNet152
class projection_MLP(nn.Module):
def __init__(self, in_dim, out_dim, num_layers=2):
super().__init__()
hidden_dim = out_dim
self.num_layers = num_layers
self.layer1 = nn.Sequential(
... | 2,575 | 24.76 | 76 | py |
SimSiam-91.9-top1-acc-on-CIFAR10 | SimSiam-91.9-top1-acc-on-CIFAR10-main/simsiam/validation.py | # https://github.com/zhirongw/lemniscate.pytorch/blob/master/test.py
import torch
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision import datasets
from torch import nn
class KNNValidation(object):
def __init__(self, args, model, K=1):
self.model = model
s... | 3,662 | 38.815217 | 113 | py |
SimSiam-91.9-top1-acc-on-CIFAR10 | SimSiam-91.9-top1-acc-on-CIFAR10-main/simsiam/resnet_cifar.py | '''ResNet in PyTorch.
For Pre-activation ResNet, see 'preact_resnet.py'.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. arXiv:1512.03385
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
# from lib.normalize import Normalize
fro... | 4,245 | 32.433071 | 102 | py |
SimSiam-91.9-top1-acc-on-CIFAR10 | SimSiam-91.9-top1-acc-on-CIFAR10-main/simsiam/criterion.py | from torch import nn
class SimSiamLoss(nn.Module):
def __init__(self, version='simplified'):
super().__init__()
self.ver = version
def asymmetric_loss(self, p, z):
if self.ver == 'original':
z = z.detach() # stop gradient
p = nn.functional.normalize(p, dim=1)... | 751 | 24.066667 | 73 | py |
mIOHMM | mIOHMM-main/src/utils.py | import numpy as np
import pickle
import torch
def save_pickle(data, filename):
with open(filename, "wb") as f:
pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
def load_pickle(filepath):
with open(filepath, "rb") as handle:
data = pickle.load(handle)
return data
def normalize(A, axis=None... | 586 | 19.964286 | 53 | py |
mIOHMM | mIOHMM-main/src/piomhmm.py | from scipy.special import gamma as gamma_fn
from sklearn.cluster import KMeans
from src.utils import normalize_exp
import math
import numpy as np
import pickle
import torch
torch.set_default_dtype(torch.float64)
class mHMM:
def __init__(
self,
data,
ins=None,
K=2,
k=5,
... | 89,160 | 37.867044 | 136 | py |
mIOHMM | mIOHMM-main/experiments/synthetic.py | from src.piomhmm import mHMM
from src.utils import save_pickle
import matplotlib.pyplot as plt
import numpy as np
import torch
def pred(model_name, model, params, b_hat):
model_mps = model.predict_sequence(params, n_sample=b_hat)
xhat = np.zeros((n, t))
xvar = np.zeros((n, t))
for i in range(n):
... | 8,235 | 28 | 110 | py |
mIOHMM | mIOHMM-main/experiments/real.py | from src.piomhmm import mHMM
import numpy as np
import random
import torch
from src.utils import save_pickle, load_pickle
RANDOM_SEED = 0
torch.manual_seed(RANDOM_SEED)
random.seed(RANDOM_SEED)
np.random.seed(RANDOM_SEED)
torch.set_default_dtype(torch.float64)
torch.set_printoptions(precision=2)
def preprocess(x, d)... | 2,760 | 26.61 | 85 | py |
MostAccurableMNIST_keras | MostAccurableMNIST_keras-master/DeepCNN.py | import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, pooling, Input
from keras.layers.convolutional import Conv2D, ZeroPadding2D
from keras.layers.pooling import MaxPooling2D
from keras.utils import np_utils
from keras.datasets import mnist
from ke... | 2,673 | 32.012346 | 87 | py |
EDGY | EDGY-master/DDF.py | import hydra
import hydra.utils as utils
import json
from pathlib import Path
import torch
import numpy as np
import librosa
from tqdm import tqdm
import pyloudnorm
from preprocess import preemphasis
from model import Encoder, Decoder
@hydra.main(config_path="Training/VQ-VAE/Configuration_files/DDF.yaml")
def DDF(cfg... | 6,913 | 43.320513 | 111 | py |
EDGY | EDGY-master/Training/VQ-VAE/dataset.py | import numpy as np
import torch
from torch.utils.data import Dataset
import json
from random import randint
from pathlib import Path
class SpeechDataset(Dataset):
def __init__(self, root, hop_length, sr, sample_frames):
self.root = Path(root)
self.hop_length = hop_length
self.sample_frames... | 1,381 | 31.139535 | 93 | py |
EDGY | EDGY-master/Training/VQ-VAE/models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from tqdm import tqdm
import numpy as np
from preprocess import mulaw_decode
def get_gru_cell(gru):
gru_cell = nn.GRUCell(gru.input_size, gru.hidden_size)
gru_cell.weight_hh.data = gru.weight_hh_l0.... | 7,998 | 35.861751 | 105 | py |
EDGY | EDGY-master/Training/VQ-VAE/train_VQ.py | import hydra
from hydra import utils
from itertools import chain
from pathlib import Path
from tqdm import tqdm
import apex.amp as amp
import torch
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter
from dataset import Sp... | 4,714 | 37.647541 | 97 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/utils_incremental/incremental_train_and_eval_AMR_LF.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 8,384 | 45.071429 | 121 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/utils_incremental/compute_confusion_matrix.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 3,725 | 43.357143 | 122 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/utils_incremental/incremental_train_and_eval_MS.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 5,759 | 41.666667 | 107 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/utils_incremental/incremental_train_and_eval.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 5,014 | 41.5 | 107 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/utils_incremental/compute_accuracy.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 3,097 | 40.306667 | 116 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/utils_incremental/compute_features.py | #!/usr/bin/env python
# coding=utf-8
#!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import... | 1,503 | 33.181818 | 99 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/utils_incremental/incremental_train_and_eval_LF.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 5,489 | 39.970149 | 107 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/utils_incremental/incremental_train_and_eval_MR_LF.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 8,171 | 44.149171 | 107 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/gen_imagenet_subset.py | #!/usr/bin/env python
# coding=utf-8
import argparse
import os
import random
import shutil
import time
import warnings
import numpy as np
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.utils.data
import t... | 1,499 | 26.777778 | 79 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/resnet.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pytorch.org/models/r... | 6,582 | 29.906103 | 90 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/utils_pytorch.py | #!/usr/bin/env python
# coding=utf-8
from __future__ import print_function, division
import torch
import torch.nn as nn
import torch.nn.init as init
from collections import OrderedDict
import numpy as np
import os
import os.path as osp
import sys
import time
import math
import subprocess
try:
import cPickle as pi... | 4,102 | 26.172185 | 96 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/eval_cumul_acc.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 6,830 | 45.469388 | 128 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/class_incremental_imagenet.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 22,015 | 52.307506 | 132 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/modified_resnet.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import modified_linear
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, bias=False)
class BasicBloc... | 3,850 | 32.198276 | 88 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/cbf_class_incremental_cosine_imagenet.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 47,336 | 60.08 | 136 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/class_incremental_cosine_imagenet.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 30,418 | 53.809009 | 132 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/gen_resized_imagenet.py | #!/usr/bin/env python
# coding=utf-8
import argparse
import os
import random
import shutil
import time
import warnings
import numpy as np
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.utils.data
import t... | 1,507 | 28 | 75 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/modified_linear.py | import math
import torch
from torch.nn.parameter import Parameter
from torch.nn import functional as F
from torch.nn import Module
class CosineLinear(Module):
def __init__(self, in_features, out_features, sigma=True):
super(CosineLinear, self).__init__()
self.in_features = in_features
self... | 2,235 | 36.898305 | 78 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/utils_imagenet/train_and_eval.py | import argparse
import os
import shutil
import time
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torchvision.transforms as transforms
import torchvi... | 2,629 | 30.309524 | 75 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/imagenet-class-incremental/utils_imagenet/utils_train.py | import argparse
import os
import shutil
import time
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torchvision.transforms as transforms
import torchvi... | 2,897 | 29.505263 | 78 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/cifar100-class-incremental/utils_pytorch.py | #!/usr/bin/env python
# coding=utf-8
from __future__ import print_function, division
import torch
import torch.nn as nn
import torch.nn.init as init
from collections import OrderedDict
import numpy as np
import os
import os.path as osp
import sys
import time
import math
import subprocess
try:
import cPickle as pi... | 4,102 | 26.172185 | 96 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/cifar100-class-incremental/eval_cumul_acc.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 5,687 | 43.4375 | 128 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/cifar100-class-incremental/class_incremental_cifar100.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 18,765 | 51.565826 | 130 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/cifar100-class-incremental/resnet_cifar.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, bias=False)
class BasicBlock(nn.Module):
expans... | 4,525 | 29.375839 | 90 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/cifar100-class-incremental/modified_resnet_cifar.py | #remove ReLU in the last layer, and use cosine layer to replace nn.Linear
import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import modified_linear
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, st... | 3,716 | 31.893805 | 87 | py |
CVPR19_Incremental_Learning | CVPR19_Incremental_Learning-master/cifar100-class-incremental/class_incremental_cosine_cifar100.py | #!/usr/bin/env python
# coding=utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision
from torchvision import datasets, models, transforms
from torch.autograd import Variable
import numpy as np
import time
import os
im... | 26,967 | 53.370968 | 131 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.