Skip to content

Commit

Permalink
Updated copyright notice
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Pidhorskyi committed Apr 15, 2020
1 parent 56c959c commit 41674f3
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 96 deletions.
1 change: 0 additions & 1 deletion ImageSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import time
import random
import os
from model import Model
from net import *
from checkpointer import Checkpointer
from scheduler import ComboMultiStepLR
Expand Down
2 changes: 1 addition & 1 deletion checkpointer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Stanislav Pidhorskyi
# Copyright 2019-2020 Stanislav Pidhorskyi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
16 changes: 16 additions & 0 deletions custom_adam.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2019-2020 Stanislav Pidhorskyi
# lr_equalization_coef was added for LREQ

# Copyright (c) 2016- Facebook, Inc (Adam Paszke)
# Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
# Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
# Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
# Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
# Copyright (c) 2011-2013 NYU (Clement Farabet)
# Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
# Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
# Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)

# https://github.com/pytorch/pytorch/blob/master/LICENSE


import math
import torch
from torch.optim.optimizer import Optimizer
Expand Down
10 changes: 1 addition & 9 deletions dataloader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Stanislav Pidhorskyi
# Copyright 2019-2020 Stanislav Pidhorskyi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,25 +13,17 @@
# limitations under the License.
# ==============================================================================

import pickle
import dareblopy as db
from threading import Thread, Lock, Event
import random
import threading

import numpy as np
import torch
import torch.tensor
import torch.utils
import torch.utils.data
import time
import torchvision.transforms.functional as vF
from torchvision import transforms
import math

from dlutils.batch_provider import batch_provider
from dlutils.shuffle import shuffle_ndarray

cpu = torch.device('cpu')


Expand Down
2 changes: 1 addition & 1 deletion defaults.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Stanislav Pidhorskyi
# Copyright 2019-2020 Stanislav Pidhorskyi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
15 changes: 2 additions & 13 deletions fid.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright 2019-2020 Stanislav Pidhorskyi
#
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
Expand All @@ -10,31 +12,18 @@
import numpy as np
import tensorflow as tf
import torch
import dnnlib
import dnnlib.tflib
import dnnlib.tflib as tflib
import pickle
from net import *
from checkpointer import Checkpointer
from scheduler import ComboMultiStepLR
from model_z_gan import Model
from launcher import run
from defaults import get_cfg_defaults
import lod_driver
from dataloader import *
import scipy.linalg

from checkpointer import Checkpointer
from scheduler import ComboMultiStepLR

from dlutils import batch_provider
from dlutils.pytorch.cuda_helper import *
from dlutils.pytorch import count_parameters
from defaults import get_cfg_defaults
import argparse
import logging
import sys
import lreq
from skimage.transform import resize
from tqdm import tqdm

Expand Down
17 changes: 3 additions & 14 deletions fid_rec.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright 2019-2020 Stanislav Pidhorskyi
#
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
Expand All @@ -10,31 +12,18 @@
import numpy as np
import tensorflow as tf
import torch
import dnnlib
import dnnlib.tflib
import dnnlib.tflib as tflib
import pickle
from net import *
from checkpointer import Checkpointer
from scheduler import ComboMultiStepLR
from model_z_gan import Model
from launcher import run
from defaults import get_cfg_defaults
import lod_driver
from dataloader import *
import scipy.linalg

from checkpointer import Checkpointer
from scheduler import ComboMultiStepLR

from dlutils import batch_provider
from dlutils.pytorch.cuda_helper import *
from dlutils.pytorch import count_parameters
from defaults import get_cfg_defaults
import argparse
import logging
import sys
import lreq
from skimage.transform import resize
from tqdm import tqdm

Expand All @@ -43,7 +32,7 @@
import utils

dnnlib.tflib.init_tf()
tf_config = {'rnd.np_random_seed': 1000}
tf_config = {'rnd.np_random_seed': 1000}


class FID:
Expand Down
1 change: 0 additions & 1 deletion make_recon_figure_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import time
import random
import os
from model import Model
from net import *
from checkpointer import Checkpointer
from scheduler import ComboMultiStepLR
Expand Down
40 changes: 1 addition & 39 deletions net.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Stanislav Pidhorskyi
# Copyright 2019-2020 Stanislav Pidhorskyi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,30 +20,11 @@
from torch.nn import init
from torch.nn.parameter import Parameter
import numpy as np
from dlutils.pytorch import count_parameters
import lreq as ln
import math
from registry import *


if False:
def lerp(s, e, x):
return s + (e - s) * x


def rsqrt(x):
return 1.0 / x ** 0.5


def addcmul(x, value, tensor1, tensor2):
return x + value * tensor1 * tensor2


torch.lerp = lerp
torch.rsqrt = rsqrt
torch.addcmul = addcmul


def pixel_norm(x, epsilon=1e-8):
return x * torch.rsqrt(torch.mean(x.pow(2.0), dim=1, keepdim=True) + epsilon)

Expand Down Expand Up @@ -110,9 +91,6 @@ def __init__(self, inputs, outputs, latent_size, last=False, fused_scale=True):
self.bias_2.zero_()

def forward(self, x):
# if self.last:
# x = minibatch_stddev_layer(x)

x = self.conv_1(x) + self.bias_1
x = F.leaky_relu(x, 0.2)

Expand Down Expand Up @@ -795,18 +773,6 @@ def get_statistics(self, lod):
return rgb_std / rgb_std_c, layers


def minibatch_stddev_layer(x, group_size=4):
group_size = min(group_size, x.shape[0])
size = x.shape[0]
if x.shape[0] % group_size != 0:
x = torch.cat([x, x[:(group_size - (x.shape[0] % group_size)) % group_size]])
y = x.view(group_size, -1, x.shape[1], x.shape[2], x.shape[3])
y = y - y.mean(dim=0, keepdim=True)
y = torch.sqrt((y ** 2).mean(dim=0) + 1e-8).mean(dim=[1, 2, 3], keepdim=True)
y = y.repeat(group_size, 1, x.shape[2], x.shape[3])
return torch.cat([x, y], dim=1)[:size]


image_size = 64

# Number of channels in the training images. For color images this is 3
Expand Down Expand Up @@ -1003,8 +969,6 @@ def encode(self, x, lod):
x = F.interpolate(x, 28)
x = x.view(x.shape[0], 28 * 28)

# styles = torch.zeros(x.shape[0], 1, self.latent_size)

x = self.fc_1(x)
x = F.leaky_relu(x, 0.2)
x = self.fc_2(x)
Expand Down Expand Up @@ -1039,8 +1003,6 @@ def decode(self, x, lod, blend_factor, noise):
x = x[:, 0] # no styles
x.view(x.shape[0], self.latent_size)

# styles = torch.zeros(x.shape[0], 1, self.latent_size)

x = self.fc_1(x)
x = F.leaky_relu(x, 0.2)
x = self.fc_2(x)
Expand Down
20 changes: 3 additions & 17 deletions ppl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright 2019 Stanislav Pidhorskyi
#
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
Expand All @@ -10,39 +12,23 @@
import numpy as np
import tensorflow as tf
import torch
import dnnlib
import dnnlib.tflib
import dnnlib.tflib as tflib
import pickle
from net import *
from checkpointer import Checkpointer
from scheduler import ComboMultiStepLR
#from model_z_gan import Model
from model_z_gan import Model
from launcher import run
from defaults import get_cfg_defaults
import lod_driver


from checkpointer import Checkpointer
from scheduler import ComboMultiStepLR

from dlutils import batch_provider
from dlutils.pytorch.cuda_helper import *
from dlutils.pytorch import count_parameters
from defaults import get_cfg_defaults
import argparse
import logging
import sys
import lreq
from skimage.transform import resize
import tqdm

from PIL import Image
from matplotlib import pyplot as plt

dnnlib.tflib.init_tf()
tf_config = {'rnd.np_random_seed': 1000}
tf_config = {'rnd.np_random_seed': 1000}


# Normalize batch of vectors.
Expand Down

0 comments on commit 41674f3

Please sign in to comment.