Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Zhang authored and Richard Zhang committed Sep 28, 2020
1 parent f5f81bd commit 43da2a5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lpips/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from __future__ import print_function

import numpy as np
from skimage.measure import compare_ssim
import torch
from torch.autograd import Variable
# from torch.autograd import Variable

from lpips.trainer import *
from lpips.lpips import *
Expand Down Expand Up @@ -51,6 +50,7 @@ def psnr(p0, p1, peak=255.):
return 10*np.log10(peak**2/np.mean((1.*p0-1.*p1)**2))

def dssim(p0, p1, range=255.):
from skimage.measure import compare_ssim
return (1 - compare_ssim(p0, p1, data_range=range, multichannel=True)) / 2.

def rgb2lab(in_img,mean_cent=False):
Expand Down
1 change: 0 additions & 1 deletion lpips/lpips.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import torch.nn.init as init
from torch.autograd import Variable
import numpy as np
from IPython import embed
from . import pretrained_networks as pn
import torch.nn

Expand Down
1 change: 0 additions & 1 deletion lpips/pretrained_networks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from collections import namedtuple
import torch
from torchvision import models as tv
from IPython import embed

class squeezenet(torch.nn.Module):
def __init__(self, requires_grad=False, pretrained=True):
Expand Down
1 change: 0 additions & 1 deletion lpips/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from torch.autograd import Variable
from scipy.ndimage import zoom
from tqdm import tqdm
from IPython import embed
import lpips

class Trainer():
Expand Down
5 changes: 3 additions & 2 deletions lpips_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
ref = lpips.im2tensor(lpips.load_image(opt.ref_path))
pred = Variable(lpips.im2tensor(lpips.load_image(opt.pred_path)), requires_grad=True)
if(opt.use_gpu):
ref = ref.cuda()
pred = pred.cuda()
with torch.no_grad():
ref = ref.cuda()
pred = pred.cuda()

optimizer = torch.optim.Adam([pred,], lr=1e-3, betas=(0.9, 0.999))

Expand Down

0 comments on commit 43da2a5

Please sign in to comment.