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?
for epoch in range(50):
print("Epoch %d" % epoch)
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)
output = model(images) # B x 1 x 9 x 9 (analogous to a heatmap)
preds = output.sum(dim=[1,2,3]) # predicted cell counts (vector of length B)
Yes. paths contain the image names. How can i extract the image name against the prediction please? If I try to call path in this way fd.write( ‘,’.join(map(str, paths + ‘\n’))) i get an error message I think i need to transform it somehow. Many Thanks for your help.