I am trying to load a model saved in a location as .pt file. I am trying to read the model as but it is giving me an AttributeError and/or a TypeError stating “missing 1 required positional argument: ‘self’” at .cuda() and .eval() lines.
import sys
sys.path.insert(0, '/home/nkaushal/network/models')
sys.path.insert(0, '/home/nkaushal/network/utils')
import yadoc
from   utils     import *
from   libraries import *
torch.cuda.empty_cache()
from model_3 import UNet

param_file  = sys.argv[1]
params      = yadoc.parameters('/home/nkaushal/network/params/test_params_{}.yml'.format(param_file))

test_set     = high_dimensional_dataset(params.data, params.target, params.test.lIndex, params.test.hIndex, params.test.aug)
test_loader  = DataLoader(test_set, batch_size=params.test.batch_size, shuffle=True, num_workers=params.test.num_workers)


def test_prediction(path, model, test_loader):
    net = torch.load(model)
    net.cuda()
    net.eval()

    for test_batch, test_data in enumerate(test_loader, 0):
        print(test_batch)
        inputs, labels = test_data
        NetInput = torch.autograd.Variable(inputs,requires_grad=False).cuda()
        Y_pred = net(NetInput)
    np.save(path+'test_'+str(test_batch)+'.npy',np.concatenate((np.squeeze(Y_pred.data.cpu().numpy()$

return None


if params.test.is_test:
    test_prediction(params.out_path, params.model_path, test_loader)