ImageCaptioning.pytorch
ImageCaptioning.pytorch copied to clipboard
Model predicts 10 captions even when there is only 1 image in the folder
Why does the model do 10 predictions even when there is only 1 image in the folder. How do i change this? Which script do I need to refer to.
Same here, anyone has the solution please
Hard to tell without seeing your code, but if they all are similar, it's probably because you are getting the 10 results of beam search with beam size 10. You can pick the first one or specify that you only want one result when calling your model:
caption = model.decode_sequence(model(feats_mean, feats, mode='sample',
opt={'beam_size': 10,
'sample_method': 'beam_search',
'sample_n': 1})
Note that sample_n can only be equal to 1 or beam_size You can also reduce beam size to 1 or change it to anything else to increase inference speed (at the cost of possibly worst result)
Another reason maybe the default batch size is 10? The dataloader in this repo will automatically cycle the dataset to reach the desired batch size. Change batch size to 1 may solve this issue.