Hi All,
I have an evaluate
function that performs testing after training the model. The function runs very well without any errors however I want to link the function to a button so that when the button is pressed, the testing can be done. I have created the button and fed the function to the command argument of the button but when I press the button, the model.eval()
throws this error module 'pyexpat.model' has no attribute 'eval'
. Below is my code for demostration:
def evaluate(model, dataloader, data_min, data_max, label_max, label_min):
model.eval()
for i in range(1):
data, label =iter(dataloader).next()
pred = model(data)
def main(args):
global data_max, data_min, label_max, label_min, model, dataloader_valid
data_min = -20
data_max = 38
label_min = 1500
label_max = 4500
dataset_valid = torch.load(args.val_anno)
dataloader_valid = torch.utils.data.DataLoader(
dataset_valid, batch_size=args.batch_size, shuffle=True)
model = network.model_dict[args.model]()
chkpnt = torch.load(args.resume, map_location='cpu')
model.load_state_dict(chkpnt['model'])
evaluate(model, dataloader_valid, data_min, data_max, label_min, label_max)
def parse_args():
import argparse
parser = argparse.ArgumentParser(description='Testing')
args = parser.parse_args()
return args
def combineFunc(*funcs):
def combinedFunc(*args, **kwargs):
for f in funcs:
f(*args, **kwargs)
return combinedFunc
model_button = customtkinter.CTkButton(master=root, image = Inv, text="", corner_radius=1, fg_color="white",
command = combineFunc(lambda: evaluate(model, dataloader_valid, data_min, data_max, label_min, label_max),
lambda: args,
lambda: main(args)))