You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey Hi,
I am writing to you as a user of your paper's pretrained model, specifically the model described in the code you provided. First of all, I would like to express my appreciation for your work and the effort you have put into developing this model.
Recently, I have been utilizing your pretrained model for a specific task in my research project. While I acknowledge the potential and effectiveness of the model, I must inform you that I am not getting correct output.
I have attached my code and the output, please look into it and let me know if there are changes needed in the code
`from future import print_function
import argparse
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from PIL import Image, ImageOps
from torchvision.transforms.functional import to_pil_image
from models import InpaintingModel
import lpips
import os
from skimage.metrics import peak_signal_noise_ratio as compare_psnr
from skimage.metrics import structural_similarity as compare_ssim
loss_fn_alex = lpips.LPIPS(net='alex')
Training settings
parser = argparse.ArgumentParser(description='PyTorch Video Inpainting with Background Auxiliary')
parser.add_argument('--bs', type=int, default=256, help='training batch size')
parser.add_argument('--lr', type=float, default=0.001, help='Learning Rate. Default=0.001')
parser.add_argument('--cpu', default=False, action='store_true', help='Use CPU to test')
parser.add_argument('--threads', type=int, default=1, help='number of threads for data loader to use')
parser.add_argument('--seed', type=int, default=67454, help='random seed to use. Default=123')
parser.add_argument('--gpus', default=0, type=int, help='number of GPUs')
parser.add_argument('--threshold', type=float, default=0.8)
parser.add_argument('--img_path', type=str, default="D:/FYP/input_image/input.jpg")
parser.add_argument('--mask_path', type=str, default="D:/FYP/input_mask/00015.png")
parser.add_argument('--model', default='C:/FYP/RN-master/pretrained_model/x_admin.cluster.localRN-0.8RN-Net_bs_14_epoch_3.pth', help='pretrained base model')
parser.add_argument('--save', default=True, action='store_true', help='If save test images')
parser.add_argument('--save_path', type=str, default='C:/FYP/RN-master/output')
parser.add_argument('--input_size', type=int, default=512, help='input image size')
parser.add_argument('--l1_weight', type=float, default=1.0)
parser.add_argument('--gan_weight', type=float, default=.1)
opt = parser.parse_args()
def evaluate_single_image(image_path, mask_path, save=False, save_path=None):
# Load the model
device = torch.device('cpu' if opt.cpu else 'cuda')
model = InpaintingModel(g_lr=opt.lr, d_lr=(0.1 * opt.lr), l1_weight=opt.l1_weight, gan_weight=opt.gan_weight, iter=0, threshold=opt.threshold)
model.load_state_dict(torch.load(opt.model, map_location=device), strict=False)
Hey Hi,
I am writing to you as a user of your paper's pretrained model, specifically the model described in the code you provided. First of all, I would like to express my appreciation for your work and the effort you have put into developing this model.
Recently, I have been utilizing your pretrained model for a specific task in my research project. While I acknowledge the potential and effectiveness of the model, I must inform you that I am not getting correct output.
I have attached my code and the output, please look into it and let me know if there are changes needed in the code
`from future import print_function
import argparse
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from PIL import Image, ImageOps
from torchvision.transforms.functional import to_pil_image
from models import InpaintingModel
import lpips
import os
from skimage.metrics import peak_signal_noise_ratio as compare_psnr
from skimage.metrics import structural_similarity as compare_ssim
loss_fn_alex = lpips.LPIPS(net='alex')
Training settings
parser = argparse.ArgumentParser(description='PyTorch Video Inpainting with Background Auxiliary')
parser.add_argument('--bs', type=int, default=256, help='training batch size')
parser.add_argument('--lr', type=float, default=0.001, help='Learning Rate. Default=0.001')
parser.add_argument('--cpu', default=False, action='store_true', help='Use CPU to test')
parser.add_argument('--threads', type=int, default=1, help='number of threads for data loader to use')
parser.add_argument('--seed', type=int, default=67454, help='random seed to use. Default=123')
parser.add_argument('--gpus', default=0, type=int, help='number of GPUs')
parser.add_argument('--threshold', type=float, default=0.8)
parser.add_argument('--img_path', type=str, default="D:/FYP/input_image/input.jpg")
parser.add_argument('--mask_path', type=str, default="D:/FYP/input_mask/00015.png")
parser.add_argument('--model', default='C:/FYP/RN-master/pretrained_model/x_admin.cluster.localRN-0.8RN-Net_bs_14_epoch_3.pth', help='pretrained base model')
parser.add_argument('--save', default=True, action='store_true', help='If save test images')
parser.add_argument('--save_path', type=str, default='C:/FYP/RN-master/output')
parser.add_argument('--input_size', type=int, default=512, help='input image size')
parser.add_argument('--l1_weight', type=float, default=1.0)
parser.add_argument('--gan_weight', type=float, default=.1)
opt = parser.parse_args()
def evaluate_single_image(image_path, mask_path, save=False, save_path=None):
# Load the model
device = torch.device('cpu' if opt.cpu else 'cuda')
model = InpaintingModel(g_lr=opt.lr, d_lr=(0.1 * opt.lr), l1_weight=opt.l1_weight, gan_weight=opt.gan_weight, iter=0, threshold=opt.threshold)
model.load_state_dict(torch.load(opt.model, map_location=device), strict=False)
def eval_single_image(image_path, mask_path, model):
model.eval()
model.generator.eval()
avg_lpips = 0.
def save_img(path, name, img):
# img (H,W,C) or (H,W) np.uint8 or torch tensor
if isinstance(img, torch.Tensor):
img = to_pil_image(img.squeeze().cpu())
img.save(os.path.join(path, name + '.png'))
def main():
torch.manual_seed(opt.seed)
if name == 'main':
main()
`
The text was updated successfully, but these errors were encountered: