Beispiel #1
0
    def func(self):
        # img = Image.open('Database/waterloo/distorted_images/gblurConv/00001_1.bmp').convert('RGB')
        img = Image.open('Database/waterloo/pristine_images/00001.bmp').convert('RGB')
        img = CenterCrop((224, 224))(img)
        img.save('outPic/src_pristine.bmp', 'bmp', quality=100)
        # img.show()
        # print (img.size)

        img = Variable(ToTensor()(img)).view(1, -1, img.size[1], img.size[0])
        # print(img)

        model = torch.load('%s/gblurConv.pth' %  self.dir)
        model = model.cuda()
        input = img.cuda()

        out_img = model(input)
        out_img = out_img.cpu().data[0]
        out_img.clamp_(0.0, 1.0)
        out_img = ToPILImage()(out_img)
        # out_img.save('outPic/1_1.bmp', 'bmp', quality=100)
        out_img.show()
Beispiel #2
0
    def denoisePatch(self):
        if (self.load == 2):
            model = torch.load('%s/%sF_ALL.pth' % (self.dir, self.typeDir))
        elif (self.load == 1):
            model = torch.load('%s/%sF.pth' % (self.dir, self.typeDir))
        else:
            model = torch.load('%s/%s.pth' % (self.dir, self.typeDir))
        model = model.cuda()
        # img = Image.open('Database/waterloo/pristine_images/00001.bmp').convert('RGB')
        # img = CenterCrop((self.size, self.size))(img)
        # img.save('outPic/0.bmp', 'bmp', quality=100)
        for i in xrange(1, 5):
            img = Image.open(
                'Database/waterloo/distorted_images/%s/00001_%d.bmp' %
                (self.typeDir, i)).convert('RGB')
            # img = Image.open('Database/waterloo/pristine_images/00001.bmp').convert('RGB')
            img = CenterCrop((self.size, self.size))(img)
            # img.save('outPic/%d_0.bmp' % i, 'bmp', quality=100)
            img.show()
            # print (img.size)

            img = Variable(ToTensor()(img)).view(1, -1, img.size[1],
                                                 img.size[0])
            # print(img)
            input = img.cuda()

            out_img = model(input)

            out_img = out_img.cpu()
            out_img = out_img.data[0]

            out_img.clamp_(0.0, 1.0)
            # out_img = self.clip(out_img)
            out_img = ToPILImage()(out_img)
            # out_img.save('outPic/%d.bmp'%i, 'bmp', quality=100)
            out_img.show()