When I tried to use your pre trained model, I have face this error.
results/CSNLN_x3/best.pth.tar
Build CSNLN model successfully.
Traceback (most recent call last):
File "validate.py", line 95, in <module>
main()
File "validate.py", line 34, in main
model.load_state_dict(checkpoint["state_dict"])
KeyError: 'state_dict'
import random
from traceback import print_tb
import numpy as np
import torch
from torch.backends import cudnn
# Random seed to maintain reproducible results
random.seed(0)
torch.manual_seed(0)
np.random.seed(0)
# Use GPU for training by default
device = torch.device("cuda", 0)
# Turning on when the image size does not change during training can speed up training
cudnn.benchmark = True
# Image magnification factor
upscale_factor = 3
# Current configuration parameter method
mode = "valid"
# Experiment name, easy to save weights and log files
exp_name = "CSNLN_x" + str(upscale_factor)
if mode == "train":
# Dataset
train_image_dir = f"data/DIV2K/CSNLN/train"
valid_image_dir = f"data/DIV2K/CSNLN/valid"
test_lr_image_dir = f"data/Set5/LRbicx{upscale_factor}"
test_hr_image_dir = f"data/Set5/GTmod12"
image_size = int(upscale_factor * 48)
batch_size = 16
num_workers = 4
# Incremental training and migration training
start_epoch = 0
resume = ""
# Total num epochs
epochs = 50
# Adam optimizer parameter
model_lr = 1e-4
model_betas = (0.9, 0.999)
# StepLR scheduler parameter
lr_scheduler_step_size = 15
lr_scheduler_gamma = 0.5
print_frequency = 100
if mode == "valid":
print("validation mode")
# Test data address
lr_dir = f"data/Set5/LRbicx{upscale_factor}"
sr_dir = f"results/test/{exp_name}"
hr_dir = f"data/Set5/GTmod12"
model_path = f"results/{exp_name}/best.pth.tar"
print(model_path)