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 |
|---|---|---|---|---|---|---|
ADFNet | ADFNet-main/ADFNet_RGB/utils.py | import math
import cv2
import torch
import numpy as np
from skimage import img_as_ubyte
from skimage.measure.simple_metrics import compare_psnr
import logging
import os
import os.path as osp
def logger(name, filepath):
dir_path = osp.dirname(filepath)
if not osp.exists(dir_path):
os.mkdir(dir_path)
... | 8,329 | 33.279835 | 122 | py |
ADFNet | ADFNet-main/ADFNet_RGB/trainer.py | import os
import math
from decimal import Decimal
import numpy as np
import utility
import torch
from torch.autograd import Variable
from tqdm import tqdm
class Trainer():
def __init__(self, args, loader, my_model, my_loss, ckp):
self.args = args
self.scale = args.scale
self.ckp = ckp
... | 7,091 | 39.99422 | 189 | py |
ADFNet | ADFNet-main/ADFNet_RGB/loss/adversarial.py | import utility
from model import common
from loss import discriminator
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
class Adversarial(nn.Module):
def __init__(self, args, gan_type):
super(Adversarial, self).__init__()
... | 3,320 | 36.738636 | 78 | py |
ADFNet | ADFNet-main/ADFNet_RGB/loss/discriminator.py | from model import common
import torch.nn as nn
class Discriminator(nn.Module):
def __init__(self, args, gan_type='GAN'):
super(Discriminator, self).__init__()
in_channels = 3
out_channels = 64
depth = 7
#bn = not gan_type == 'WGAN_GP'
bn = True
act = nn.Lea... | 1,287 | 27 | 77 | py |
ADFNet | ADFNet-main/ADFNet_RGB/loss/vgg.py | from model import common
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
from torch.autograd import Variable
class VGG(nn.Module):
def __init__(self, conv_index, rgb_range=1):
super(VGG, self).__init__()
vgg_features = models.vgg19(pretrained=... | 1,093 | 28.567568 | 75 | py |
ADFNet | ADFNet-main/ADFNet_RGB/loss/__init__.py | import os
from importlib import import_module
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class Loss(nn.modules.loss._Loss):
def __init__(self, args, ckp):
super(Loss, self).__init__()
... | 4,833 | 31.884354 | 80 | py |
ADFNet | ADFNet-main/ADFNet_RGB/data/srdata.py | import os
import numpy as np
import imageio
import torch
import torch.utils.data as data
from data import common
'''
只输入HQ 图像, LQ图像直接在HQ图像上加入噪声
'''
class SRData(data.Dataset):
def __init__(self, args, train=True, benchmark=False):
self.args = args
self.train = train
self.split = 'train' if ... | 2,615 | 26.829787 | 67 | py |
ADFNet | ADFNet-main/ADFNet_RGB/data/myimage.py | import os
from data import common
import imageio
import torch.utils.data as data
# 测试的时候输入HQ图片,直接进行测试PSNR和SSIM的值
class MyImage(data.Dataset):
def __init__(self, args, train=False):
self.args = args
self.name = 'MyImage'
self.scale = args.scale
self.idx_scale = 0
self.train =... | 1,296 | 28.477273 | 70 | py |
ADFNet | ADFNet-main/ADFNet_RGB/data/common.py | import random
import numpy as np
import skimage.io as sio
import skimage.color as sc
import torch
from torchvision import transforms
def get_patch(img_tar, patch_size):
h, w = img_tar.shape[:2]
x = random.randrange(0, w - patch_size + 1)
y = random.randrange(0, h - patch_size + 1)
img_tar = img_tar... | 1,569 | 23.920635 | 69 | py |
ADFNet | ADFNet-main/ADFNet_RGB/data/__init__.py | from importlib import import_module
from dataloader import MSDataLoader
from torch.utils.data.dataloader import default_collate
class Data:
def __init__(self, args):
kwargs = {}
if not args.cpu:
kwargs['collate_fn'] = default_collate
kwargs['pin_memory'] = True
else... | 1,657 | 32.16 | 78 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/adfnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import sys
import os
sys.path.append(os.pardir)
from model.dcn.modules.modulated_deform_conv import ModulatedDeformConvPack as DCN
def make_model(args):
return Net()
# 促进特征全方位的融合
class Attention(nn.Module):
def __init__(self):
super(A... | 10,734 | 34.664452 | 131 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/__init__.py | import os
import numpy as np
import torch
import torch.nn as nn
from importlib import import_module
class Model(nn.Module):
def __init__(self, args, ckp):
super(Model, self).__init__()
print('Making model...')
self.scale = args.scale
self.idx_scale = 0
self.self_ensemble =... | 7,374 | 34.287081 | 97 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/adfnet-L.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import sys
import os
sys.path.append(os.pardir)
from model.dcn.modules.modulated_deform_conv import ModulatedDeformConvPack as DCN
def make_model(args):
return Net()
# 促进特征全方位的融合
class Attention(nn.Module):
def __init__(self):
super(A... | 10,736 | 34.671096 | 131 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/test.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import time
import torch
import torch.nn as nn
from torch.autograd import gradcheck
from modules.deform_conv import DeformConv, _DeformConv, DeformConvPack
from modules.modulated_deform_c... | 21,977 | 33.775316 | 154 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/setup.py | #!/usr/bin/env python
import os
import glob
import torch
from torch.utils.cpp_extension import CUDA_HOME
from torch.utils.cpp_extension import CppExtension
from torch.utils.cpp_extension import CUDAExtension
from setuptools import find_packages
from setuptools import setup
requirements = ["torch", "torchvision"]
... | 2,028 | 28.838235 | 73 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/functions/deform_conv_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,398 | 41.087719 | 82 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/functions/deform_psroi_pooling_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,654 | 39.846154 | 85 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/functions/modulated_deform_conv_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,484 | 42.596491 | 83 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/modules/deform_conv.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import torch
import math
from torch import nn
from torch.nn import init
from torch.nn.modules.utils import _pair
from functions.deform_conv_func import DeformConvFunction
class DeformCon... | 4,282 | 41.83 | 119 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/modules/deform_psroi_pooling.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import torch
import math
from torch import nn
from torch.nn.modules.utils import _pair
from functions.deform_psroi_pooling_func import DeformRoIPoolingFunction
class DeformRoIPooling(nn.... | 5,586 | 41.648855 | 72 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/modules/modulated_deform_conv.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import logging
import torch
import math
from torch import nn
from torch.nn import init
from torch.nn.modules.utils import _pair
from functions.modulated_deform_conv_func import ModulatedD... | 7,544 | 44.451807 | 147 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.7/functions/deform_conv_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,398 | 41.087719 | 82 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.7/functions/deform_psroi_pooling_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,654 | 39.846154 | 85 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.7/functions/modulated_deform_conv_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,484 | 42.596491 | 83 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.7/modules/deform_conv.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import torch
import math
from torch import nn
from torch.nn import init
from torch.nn.modules.utils import _pair
from functions.deform_conv_func import DeformConvFunction
class DeformCon... | 4,282 | 41.83 | 119 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.7/modules/deform_psroi_pooling.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import torch
import math
from torch import nn
from torch.nn.modules.utils import _pair
from functions.deform_psroi_pooling_func import DeformRoIPoolingFunction
class DeformRoIPooling(nn.... | 5,586 | 41.648855 | 72 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.7/modules/modulated_deform_conv.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import logging
import torch
import math
from torch import nn
from torch.nn import init
from torch.nn.modules.utils import _pair
from functions.modulated_deform_conv_func import ModulatedD... | 7,199 | 42.902439 | 119 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.6/functions/deform_conv_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,398 | 41.087719 | 82 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.6/functions/deform_psroi_pooling_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,654 | 39.846154 | 85 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.6/functions/modulated_deform_conv_func.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import math
import torch
from torch import nn
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from torch.autograd.function import once_differentiable
import D... | 2,484 | 42.596491 | 83 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.6/modules/deform_conv.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import torch
import math
from torch import nn
from torch.nn import init
from torch.nn.modules.utils import _pair
from functions.deform_conv_func import DeformConvFunction
class DeformCon... | 4,282 | 41.83 | 119 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.6/modules/deform_psroi_pooling.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import torch
import math
from torch import nn
from torch.nn.modules.utils import _pair
from functions.deform_psroi_pooling_func import DeformRoIPoolingFunction
class DeformRoIPooling(nn.... | 5,586 | 41.648855 | 72 | py |
ADFNet | ADFNet-main/ADFNet_RGB/model/dcn/build/lib.linux-x86_64-3.6/modules/modulated_deform_conv.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import logging
import torch
import math
from torch import nn
from torch.nn import init
from torch.nn.modules.utils import _pair
from functions.modulated_deform_conv_func import ModulatedD... | 7,544 | 44.451807 | 147 | py |
EGSDE | EGSDE-master/run_EGSDE_multi_domain.py | import os
from tool.utils import available_devices,format_devices
#set device
device = available_devices(threshold=10000,n_devices=4)
os.environ["CUDA_VISIBLE_DEVICES"] = format_devices(device)
from tool.reproducibility import set_seed
from tool.utils import dict2namespace
import yaml
import torch
from runners.egsde im... | 1,387 | 22.525424 | 94 | py |
EGSDE | EGSDE-master/run_train_dse.py | import os
from tool.utils import available_devices,format_devices
#set device
device = available_devices(threshold=10000,n_devices=5)
os.environ["CUDA_VISIBLE_DEVICES"] = format_devices(device)
import argparse
import torch as th
import torch.nn.functional as F
from torch.optim import AdamW
from guided_diffusion import ... | 7,859 | 33.933333 | 97 | py |
EGSDE | EGSDE-master/run_EGSDE.py | import os
from tool.utils import available_devices,format_devices
#set device
device = available_devices(threshold=10000,n_devices=4)
os.environ["CUDA_VISIBLE_DEVICES"] = format_devices(device)
from tool.reproducibility import set_seed
from tool.utils import dict2namespace
import yaml
import torch
from runners.egsde im... | 1,186 | 22.74 | 94 | py |
EGSDE | EGSDE-master/functions/denoising.py | import torch
import torch.nn.functional as F
from tool.utils import RequiresGradContext
import torch.autograd as autograd
def extract(a, t, x_shape):
"""Extract coefficients from a based on t and reshape to make it
broadcastable with x_shape."""
bs, = t.shape
assert x_shape[0] == bs
out = torch.ga... | 2,758 | 30.712644 | 113 | py |
EGSDE | EGSDE-master/functions/resizer.py | # This code was taken from: https://github.com/assafshocher/resizer by Assaf Shocher
import numpy as np
import torch
from math import pi
from torch import nn
class Resizer(nn.Module):
def __init__(self, in_shape, scale_factor=None, output_shape=None, kernel='linear', antialiasing=True):
super(Resizer, sel... | 12,123 | 53.612613 | 141 | py |
EGSDE | EGSDE-master/functions/__init__.py | import torch.optim as optim
def get_optimizer(config, parameters):
if config.optim.optimizer == 'Adam':
return optim.Adam(parameters, lr=config.optim.lr, weight_decay=config.optim.weight_decay,
betas=(config.optim.beta1, 0.999), amsgrad=config.optim.amsgrad,
... | 727 | 44.5 | 100 | py |
EGSDE | EGSDE-master/models/ddpm.py | import math
import torch
import torch.nn as nn
def get_timestep_embedding(timesteps, embedding_dim):
"""
This matches the implementation in Denoising Diffusion Probabilistic Models:
From Fairseq.
Build sinusoidal embeddings.
This matches the implementation in tensor2tensor, but differs slightly
... | 12,845 | 36.671554 | 95 | py |
EGSDE | EGSDE-master/datasets/basedataset.py | import torch
import os
from PIL import Image
IMG_EXTENSIONS = [
'.jpg', '.JPG', '.jpeg', '.JPEG',
'.png', '.PNG', '.ppm', '.PPM', '.bmp', '.BMP',
'.tif', '.TIF', '.tiff', '.TIFF',
]
def is_image_file(filename):
return any(filename.endswith(extension) for extension in IMG_EXTENSIONS)
def make_dataset(... | 2,990 | 31.16129 | 76 | py |
EGSDE | EGSDE-master/datasets/__init__.py | import torch
import torchvision.transforms as transforms
from .basedataset import namedataset,labeldataset
from PIL import Image
def get_dataset(phase,image_size,data_path):
train_transform = transforms.Compose(
[
transforms.Resize(image_size,interpolation=Image.BICUBIC),
transforms... | 1,286 | 25.8125 | 90 | py |
EGSDE | EGSDE-master/runners/egsde.py | import os
import logging
import numpy as np
import torch
import torch.utils.data as data
from models.ddpm import Model
from datasets import get_dataset,rescale,inverse_rescale
import torchvision.utils as tvu
from functions.denoising import egsde_sample
from guided_diffusion.script_util import create_model,create_dse
fr... | 8,393 | 43.887701 | 138 | py |
EGSDE | EGSDE-master/guided_diffusion/resample.py | from abc import ABC, abstractmethod
import numpy as np
import torch as th
import torch.distributed as dist
def create_named_schedule_sampler(name, diffusion):
"""
Create a ScheduleSampler from a library of pre-defined samplers.
:param name: the name of the sampler.
:param diffusion: the diffusion ob... | 5,689 | 35.709677 | 87 | py |
EGSDE | EGSDE-master/guided_diffusion/losses.py | """
Helpers for various likelihood-based losses. These are ported from the original
Ho et al. diffusion models codebase:
https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/utils.py
"""
import numpy as np
import torch as th
def normal_kl(mean1, logvar1, mean2, logvar... | 2,534 | 31.5 | 109 | py |
EGSDE | EGSDE-master/guided_diffusion/image_datasets.py | import math
import random
from PIL import Image
import blobfile as bf
from mpi4py import MPI
import numpy as np
from torch.utils.data import DataLoader, Dataset
def load_data(
*,
data_dir,
batch_size,
image_size,
class_cond=False,
deterministic=False,
random_crop=False,
random_flip=Tr... | 5,930 | 34.303571 | 88 | py |
EGSDE | EGSDE-master/guided_diffusion/nn.py | """
Various utilities for neural networks.
"""
import math
import torch as th
import torch.nn as nn
# PyTorch 1.7 has SiLU, but we support PyTorch 1.5.
class SiLU(nn.Module):
def forward(self, x):
return x * th.sigmoid(x)
class GroupNorm32(nn.GroupNorm):
def forward(self, x):
return super(... | 5,020 | 28.362573 | 88 | py |
EGSDE | EGSDE-master/guided_diffusion/fp16_util.py | """
Helpers to train with 16-bit precision.
"""
import numpy as np
import torch as th
import torch.nn as nn
from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
from . import logger
INITIAL_LOG_LOSS_SCALE = 20.0
def convert_module_to_f16(l):
"""
Convert primitive modules to float16.
... | 7,941 | 32.510549 | 114 | py |
EGSDE | EGSDE-master/guided_diffusion/unet.py | from abc import abstractmethod
import math
import numpy as np
import torch as th
import torch.nn as nn
import torch.nn.functional as F
from .fp16_util import convert_module_to_f16, convert_module_to_f32
from .nn import (
checkpoint,
conv_nd,
linear,
avg_pool_nd,
zero_module,
normalization,
... | 36,191 | 33.867052 | 124 | py |
EGSDE | EGSDE-master/guided_diffusion/gaussian_diffusion.py | """
This code started out as a PyTorch port of Ho et al's diffusion models:
https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/diffusion_utils_2.py
Docstrings have been added, as well as DDIM sampling and a new collection of beta schedules.
"""
import enum
import math... | 34,335 | 36.773377 | 129 | py |
EGSDE | EGSDE-master/guided_diffusion/train_util.py | import copy
import functools
import os
import blobfile as bf
import torch as th
import torch.distributed as dist
from torch.nn.parallel.distributed import DistributedDataParallel as DDP
from torch.optim import AdamW
from . import dist_util, logger
from .fp16_util import MixedPrecisionTrainer
from .nn import update_em... | 10,604 | 34.115894 | 88 | py |
EGSDE | EGSDE-master/guided_diffusion/respace.py | import numpy as np
import torch as th
from .gaussian_diffusion import GaussianDiffusion
def space_timesteps(num_timesteps, section_counts):
"""
Create a list of timesteps to use from an original diffusion process,
given the number of timesteps we want to take from equally-sized portions
of the origin... | 5,193 | 39.263566 | 85 | py |
EGSDE | EGSDE-master/guided_diffusion/dist_util.py | """
Helpers for distributed training.
"""
import io
import os
import socket
import blobfile as bf
from mpi4py import MPI
import torch as th
import torch.distributed as dist
# Change this to reflect your cluster layout.
# The GPU for a given rank is (rank % GPUS_PER_NODE).
GPUS_PER_NODE = 8
SETUP_RETRY_COUNT = 3
d... | 2,424 | 24.797872 | 87 | py |
EGSDE | EGSDE-master/tool/eval_score.py | import torch
from tool.interact import set_logger
import os
from tool.fid import calculate_fid_given_paths
import logging
from tool.mse_psnr_ssim_mssim import calculate_ssim,calculate_msssim,calculate_psnr,calculate_mse
from datasets import image2tensor,imageresize2tensor
def calculate_l2_given_paths(path1,path2):
... | 1,249 | 25.595745 | 97 | py |
EGSDE | EGSDE-master/tool/reproducibility.py | import torch
import numpy as np
import os
import datetime
import shutil
import pprint
def set_seed(seed=1234):
torch.manual_seed(seed)
np.random.seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
def backup_codes(path):
... | 1,282 | 32.763158 | 109 | py |
EGSDE | EGSDE-master/tool/inception.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
import os
try:
from torchvision.models.utils import load_state_dict_from_url
except ImportError:
from torch.utils.model_zoo import load_url as load_state_dict_from_url
# Inception weights ported to Pytorch from
# http://downl... | 12,354 | 36.213855 | 140 | py |
EGSDE | EGSDE-master/tool/utils.py | import os
import torch
import torch.nn as nn
def judge_requires_grad(obj):
if isinstance(obj, torch.Tensor):
return obj.requires_grad
elif isinstance(obj, nn.Module):
return next(obj.parameters()).requires_grad
else:
raise TypeError
class RequiresGradContext(object):
def __init__... | 1,834 | 31.767857 | 95 | py |
EGSDE | EGSDE-master/tool/fid.py | """Calculates the Frechet Inception Distance (FID) to evalulate GANs
The FID metric calculates the distance between two distributions of images.
Typically, we have summary statistics (mean & covariance matrix) of one
of these distributions, while the 2nd distribution is given by a GAN.
When run as a stand-alone progr... | 10,252 | 34.975439 | 115 | py |
EGSDE | EGSDE-master/tool/mse_psnr_ssim_mssim.py | import warnings
import numpy as np
import torch
import torch.nn.functional as F
import os
IMG_EXTENSIONS = [
'.jpg', '.JPG', '.jpeg', '.JPEG',
'.png', '.PNG', '.ppm', '.PPM', '.bmp', '.BMP',
'.tif', '.TIF', '.tiff', '.TIFF',
]
def is_image_file(filename):
return any(filename.endswith(extension) for e... | 15,817 | 33.238095 | 141 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/models/distributions.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 5,410 | 36.839161 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/models/bijectors.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 2,641 | 35.191781 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/models/embeddings.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 1,862 | 34.150943 | 76 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/models/utils.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 1,128 | 27.225 | 74 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/models/coupling_flows.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 6,658 | 34.801075 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/models/particle_models.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 24,104 | 37.879032 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/models/attention.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 6,301 | 35.853801 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/systems/monatomic_water.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 6,008 | 37.519231 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/systems/lennard_jones.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 4,758 | 41.115044 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/systems/energies.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 12,271 | 37.591195 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/experiments/utils.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 2,528 | 33.643836 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/experiments/lennard_jones_config.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 3,618 | 30.469565 | 76 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/experiments/monatomic_water_config.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 4,094 | 30.744186 | 80 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/experiments/train.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 5,783 | 29.930481 | 79 | py |
flows_for_atomic_solids | flows_for_atomic_solids-main/utils/observable_utils.py | #!/usr/bin/python
#
# Copyright 2022 DeepMind Technologies Limited
#
# 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 a... | 11,337 | 37.564626 | 80 | py |
RPCF | RPCF-master/caffe/tools/extra/parse_log.py | #!/usr/bin/env python
"""
Parse training log
Evolved from parse_log.sh
"""
import os
import re
import extract_seconds
import argparse
import csv
from collections import OrderedDict
def parse_log(path_to_log):
"""Parse log file
Returns (train_dict_list, train_dict_names, test_dict_list, test_dict_names)
... | 6,700 | 33.015228 | 86 | py |
RPCF | RPCF-master/caffe/examples/web_demo/app.py | import os
import time
import cPickle
import datetime
import logging
import flask
import werkzeug
import optparse
import tornado.wsgi
import tornado.httpserver
import numpy as np
import pandas as pd
from PIL import Image
import cStringIO as StringIO
import urllib
import exifutil
import caffe
REPO_DIRNAME = os.path.abs... | 7,793 | 33.184211 | 105 | py |
RPCF | RPCF-master/caffe/examples/pycaffe/caffenet.py | from __future__ import print_function
from caffe import layers as L, params as P, to_proto
from caffe.proto import caffe_pb2
# helper function for common structures
def conv_relu(bottom, ks, nout, stride=1, pad=0, group=1):
conv = L.Convolution(bottom, kernel_size=ks, stride=stride,
... | 2,112 | 36.732143 | 91 | py |
RPCF | RPCF-master/caffe/examples/pycaffe/layers/pyloss.py | import caffe
import numpy as np
class EuclideanLossLayer(caffe.Layer):
"""
Compute the Euclidean Loss in the same manner as the C++ EuclideanLossLayer
to demonstrate the class interface for developing layers in Python.
"""
def setup(self, bottom, top):
# check input pair
if len(bo... | 1,223 | 31.210526 | 79 | py |
RPCF | RPCF-master/caffe/examples/finetune_flickr_style/assemble_data.py | #!/usr/bin/env python
"""
Form a subset of the Flickr Style data, download images to dirname, and write
Caffe ImagesDataLayer training file.
"""
import os
import urllib
import hashlib
import argparse
import numpy as np
import pandas as pd
from skimage import io
import multiprocessing
# Flickr returns a special image i... | 3,636 | 35.737374 | 94 | py |
RPCF | RPCF-master/caffe/examples/coco_caption/captioner.py | #!/usr/bin/env python
from collections import OrderedDict
import h5py
import math
import matplotlib.pyplot as plt
import numpy as np
import os
import random
import sys
sys.path.append('./python/')
import caffe
class Captioner():
def __init__(self, weights_path, image_net_proto, lstm_net_proto,
vocab... | 16,658 | 40.337469 | 88 | py |
RPCF | RPCF-master/caffe/examples/coco_caption/retrieval_experiment.py | #!/usr/bin/env python
from collections import OrderedDict
import json
import numpy as np
import pprint
import cPickle as pickle
import string
import sys
# seed the RNG so we evaluate on the same subset each time
np.random.seed(seed=0)
from coco_to_hdf5_data import *
from captioner import Captioner
COCO_EVAL_PATH = ... | 15,281 | 41.099174 | 89 | py |
RPCF | RPCF-master/caffe/python/draw_net.py | #!/usr/bin/env python
"""
Draw a graph of the net architecture.
"""
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from google.protobuf import text_format
import caffe
import caffe.draw
from caffe.proto import caffe_pb2
def parse_args():
"""Parse input arguments
"""
parser = Argument... | 1,389 | 29.217391 | 78 | py |
RPCF | RPCF-master/caffe/python/detect.py | #!/usr/bin/env python
"""
detector.py is an out-of-the-box windowed detector
callable from the command line.
By default it configures and runs the Caffe reference ImageNet model.
Note that this model was trained for image classification and not detection,
and finetuning for detection can be expected to improve results... | 5,743 | 32.011494 | 88 | py |
RPCF | RPCF-master/caffe/python/classify.py | #!/usr/bin/env python
"""
classify.py is an out-of-the-box image classifer callable from the command line.
By default it configures and runs the Caffe reference ImageNet model.
"""
import numpy as np
import os
import sys
import argparse
import glob
import time
import caffe
def main(argv):
pycaffe_dir = os.path.... | 4,262 | 29.669065 | 88 | py |
RPCF | RPCF-master/caffe/python/caffe/net_spec.py | """Python net specification.
This module provides a way to write nets directly in Python, using a natural,
functional style. See examples/pycaffe/caffenet.py for an example.
Currently this works as a thin wrapper around the Python protobuf interface,
with layers and parameters automatically generated for the "layers"... | 7,876 | 34.642534 | 82 | py |
RPCF | RPCF-master/caffe/python/caffe/classifier.py | #!/usr/bin/env python
"""
Classifier is an image classifier specialization of Net.
"""
import numpy as np
import caffe
class Classifier(caffe.Net):
"""
Classifier extends Net for image class prediction
by scaling, center cropping, or oversampling.
Parameters
----------
image_dims : dimensio... | 3,501 | 34.734694 | 78 | py |
RPCF | RPCF-master/caffe/python/caffe/detector.py | #!/usr/bin/env python
"""
Do windowed detection by classifying a number of images/crops at once,
optionally using the selective search window proposal method.
This implementation follows ideas in
Ross Girshick, Jeff Donahue, Trevor Darrell, Jitendra Malik.
Rich feature hierarchies for accurate object detection... | 8,562 | 38.460829 | 80 | py |
RPCF | RPCF-master/caffe/python/caffe/__init__.py | from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list
from .proto.caffe_pb2 import TRAIN, TEST
from .classifier import Classifier
from .detector import Detector
from . i... | 385 | 47.25 | 109 | py |
RPCF | RPCF-master/caffe/python/caffe/pycaffe.py | """
Wrap the internal caffe C++ module (_caffe.so) with a clean, Pythonic
interface.
"""
from collections import OrderedDict
try:
from itertools import izip_longest
except:
from itertools import zip_longest as izip_longest
import numpy as np
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \... | 9,706 | 32.129693 | 80 | py |
RPCF | RPCF-master/caffe/python/caffe/draw.py | """
Caffe network visualization: draw the NetParameter protobuffer.
.. note::
This requires pydot>=1.0.2, which is not included in requirements.txt since
it requires graphviz and other prerequisites outside the scope of the
Caffe.
"""
from caffe.proto import caffe_pb2
import pydot
# Internal layer and ... | 7,216 | 32.724299 | 79 | py |
RPCF | RPCF-master/caffe/python/caffe/io.py | import numpy as np
import skimage.io
from scipy.ndimage import zoom
from skimage.transform import resize
try:
# Python3 will most likely not be able to load protobuf
from caffe.proto import caffe_pb2
except:
import sys
if sys.version_info >= (3, 0):
print("Failed to include caffe_pb2, things mi... | 12,575 | 32.094737 | 79 | py |
RPCF | RPCF-master/caffe/python/caffe/test/test_python_layer_with_param_str.py | import unittest
import tempfile
import os
import six
import caffe
class SimpleParamLayer(caffe.Layer):
"""A layer that just multiplies by the numeric value of its param string"""
def setup(self, bottom, top):
try:
self.value = float(self.param_str)
except ValueError:
... | 1,925 | 31.1 | 79 | py |
RPCF | RPCF-master/caffe/python/caffe/test/test_solver.py | import unittest
import tempfile
import os
import numpy as np
import six
import caffe
from test_net import simple_net_file
class TestSolver(unittest.TestCase):
def setUp(self):
self.num_output = 13
net_f = simple_net_file(self.num_output)
f = tempfile.NamedTemporaryFile(mode='w+', delete=F... | 1,849 | 33.259259 | 76 | py |
RPCF | RPCF-master/caffe/python/caffe/test/test_layer_type_list.py | import unittest
import caffe
class TestLayerTypeList(unittest.TestCase):
def test_standard_types(self):
for type_name in ['Data', 'Convolution', 'InnerProduct']:
self.assertIn(type_name, caffe.layer_type_list(),
'%s not in layer_type_list()' % type_name)
| 302 | 26.545455 | 65 | py |
RPCF | RPCF-master/caffe/python/caffe/test/test_net.py | import unittest
import tempfile
import os
import numpy as np
import six
import caffe
def simple_net_file(num_output):
"""Make a simple net prototxt, based on test_net.cpp, returning the name
of the (temporary) file."""
f = tempfile.NamedTemporaryFile(mode='w+', delete=False)
f.write("""name: 'testne... | 2,927 | 34.707317 | 78 | py |
RPCF | RPCF-master/caffe/python/caffe/test/test_net_spec.py | import unittest
import tempfile
import caffe
from caffe import layers as L
from caffe import params as P
def lenet(batch_size):
n = caffe.NetSpec()
n.data, n.label = L.DummyData(shape=[dict(dim=[batch_size, 1, 28, 28]),
dict(dim=[batch_size, 1, 1, 1])],
... | 3,287 | 39.097561 | 77 | py |
RPCF | RPCF-master/caffe/python/caffe/test/test_python_layer.py | import unittest
import tempfile
import os
import six
import caffe
class SimpleLayer(caffe.Layer):
"""A layer that just multiplies by ten"""
def setup(self, bottom, top):
pass
def reshape(self, bottom, top):
top[0].reshape(*bottom[0].data.shape)
def forward(self, bottom, top):
... | 4,604 | 31.659574 | 81 | py |
RPCF | RPCF-master/caffe/scripts/cpp_lint.py | #!/usr/bin/python2
#
# Copyright (c) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... | 187,464 | 37.501746 | 93 | py |
RPCF | RPCF-master/caffe/scripts/download_model_binary.py | #!/usr/bin/env python
import os
import sys
import time
import yaml
import urllib
import hashlib
import argparse
required_keys = ['caffemodel', 'caffemodel_url', 'sha1']
def reporthook(count, block_size, total_size):
"""
From http://blog.moleculea.com/2012/10/04/urlretrieve-progres-indicator/
"""
glob... | 2,496 | 31.428571 | 78 | py |
ELLA | ELLA-main/babyai/setup.py | from setuptools import setup
setup(
name='babyai',
version='0.1.0',
license='BSD 3-clause',
keywords='memory, environment, agent, rl, openaigym, openai-gym, gym',
packages=['babyai', 'babyai.levels', 'babyai.utils'],
install_requires=[
'gym>=0.9.6',
'numpy>=1.17.0',
"tor... | 450 | 25.529412 | 84 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.