7e786cbaa2af5a666a3957b11d9621ae9f34a883,test.py,,,#,16

Before Change


        image = Image.open(data_path + image_name)
        image = Variable(ToTensor()(image))
        target = Image.open(target_path + image_name)
        target = Variable(ToTensor()(target))
        if torch.cuda.is_available():
            image = image.unsqueeze(0).cuda()
            target = target.unsqueeze(0).cuda()

        out = model(image)
        mse = ((target - out) ** 2).mean()
        psnr = 10 * log10(1 / mse.data.cpu().numpy())
        ssim = pytorch_ssim.ssim(out, target).data.cpu().numpy()
        out_img = ToPILImage()(out[0].data.cpu())
        out_img.save(out_path + "psnr_%.4f_ssim_%.4f_" % (psnr, ssim) + image_name)

After Change


        image = Image.open(data_path + image_name)
        image = Variable(ToTensor()(image)).unsqueeze(0)
        target = Image.open(target_path + image_name)
        target = Variable(ToTensor()(target)).unsqueeze(0)
        if torch.cuda.is_available():
            image.cuda()
            target.cuda()

        out = model(image)
        mse = ((target - out) ** 2).mean()
        psnr = 10 * log10(1 / mse.data.cpu().numpy())
        ssim = pytorch_ssim.ssim(out, target).data.cpu().numpy()
        out_img = ToPILImage()(out[0].data.cpu())
        out_img.save(out_path + "psnr_%.4f_ssim_%.4f_" % (psnr, ssim) + image_name)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: leftthomas/SRGAN
Commit Name: 7e786cbaa2af5a666a3957b11d9621ae9f34a883
Time: 2017-11-21
Author: leftthomas@qq.com
File Name: test.py
Class Name:
Method Name:


Project Name: keon/seq2seq
Commit Name: 55268ace0817879ace07b73e223c3a6db79a3180
Time: 2017-12-06
Author: kwk236@gmail.com
File Name: model.py
Class Name: Seq2Seq
Method Name: forward