ECCV2018_CrossNet_RefSR icon indicating copy to clipboard operation
ECCV2018_CrossNet_RefSR copied to clipboard

How to test(how to edit code for testing)

Open iamheejae opened this issue 5 years ago • 3 comments

Hi, I am really interested with your network. I already trained your network with several datasets, and now i want to test the image with checkpoint file. However, i am not sure how to test image. I found that there are some lines for testing in 'train_multi_warping.py' and I tried to uncomment such lines, but i don't know which lines should or should not be uncommented for testing. I really appreciate if you guide me how to test image with trained model.

iamheejae avatar May 29 '19 20:05 iamheejae

Really sorry for the late reply! You could load the checkpoint file by net.load_state_dict(torch.load('your_checkpint_name.pth')) then call the model forward function for predicting output. output1, output2, ... = model(input1, input2,...)

Some reference can be found here https://github.com/htzheng/ECCV2018_CrossNet_RefSR/issues/1

htzheng avatar Jun 21 '19 09:06 htzheng

Hi,can you tell me how to test an image? I have loaded the pth.THANKS.

jxingm avatar Jul 12 '19 08:07 jxingm

I'm really appreciate with your reply. thanks . but i'm still confused...

you mean modify code like this?

net.load_state_dict(torch.load('/mnt/ECCV2018_CrossNet_RefSR/checkpoints_charbonnier_3/CP65000.pth')) #Then call the model forward function for predicting output... output1= MultiscaleWarpingNet(input1)

i'm confused about following part

then call the model forward function for predicting output. output1, output2, ... = model(input1, input2,...)

What should i put in the input1? the buff? buff_val? In addition, you uncomment some lines like below, but i don't know what to uncomment if i want to test image.

        #buff_val = dataset_test.nextBatch_new(batchsize=config['batch_size'], shuffle=True, view_mode = 'Random', augmentation = False, offset_augmentation=config['data_displacement_augmentation'], crop_shape = config['train_data_crop_shape'])
        
        #val_img1_LR = buff_val['input_img1_LR']
        #val_img2_HR = buff_val['input_img2_HR']

        #val_img = np.concatenate((val_img1_LR,val_img2_HR),axis = 1)
        #val_label_img = buff['input_img1_HR']

        #val_img = torch.from_numpy(val_img)
        #val_img = val_img.cuda()
        #with torch.no_grad():
        #    val_pred = net(val_img) 
        #    val_pred_npy = val_pred.cpu().numpy()
        #    psnr_ = 0
        #    for i in range(val_pred_npy.shape[0]):
        #        psnr_ += psnr(val_pred_npy[i],val_label_img[i]) / val_pred_npy.shape[0]
                #print (i,psnr(val_pred_npy[i],val_label_img[i]))
   

Or can you give me the example of testing code?

iamheejae avatar Aug 16 '19 02:08 iamheejae