The code below is used as part of my training model to print prediction. I would like to print each image name as well as the prediction. Can anyone advise how to do this please?
filename=CellsDataset(args.data_dir,transform=ToTensor(),return_filenames=True)
for epoch in range(50):
print("Epoch %d" % epoch)
model.train()
for images, paths in tqdm(loader_train):
images = images.to(device)
targets = torch.tensor([metadata['count'][os.path.split(path)[-1]] for path in paths]) # B
targets = targets.float().to(device)
filename=CellsDataset(args.data_dir,transform=ToTensor(),return_filenames=True)
#print(filename.files)
output = model(images) # B x 1 x 9 x 9 (analogous to a heatmap)
#print(output.filename)
preds = output.sum(dim=[1,2,3]) # predicted cell counts (vector of length B)
#filename=output.files
print(preds)