How to Extract Probabilities CTC

How to extract -Top(K-10 )- probabilities and labels from CTC layer , I’m trying to get the final top k-10 -words with the associated probabilities.
The code is based on
any hint or help ?
I added this code to extract the top k but I’m getting an error
AssertionError: text with length: 260 does not match declared length: 26

my code
model .eval()
output = model(image)
_, predicted = output.topk(10)
cl =[0][0]
print (cl)
predicted = predicted.transpose(1, 0).contiguous().view(-1)
predicted_size = Variable(torch.IntTensor([preds.size(0)])) sim_predicted = converter.decode(,, raw=True)


I think this is an issue with the demo code and not pytorch:

I found this related issue, hopefully it helps.

Thank you for pointing that out, still I’m not able to get the top k even after changing the index. Any hint/help to point me into the right direction.
Thanks in advance.

Can you post the full script that you’re running?

So Sorry for the late reply… Still, I’m not able to run that with extract multiple words, 2,3 words, and its associated probabilities.

Not sure where to start, from my understanding, CTC has softmax, and score. from where we could extract the sum of probabilities for each word1, word2

CTC code

Thanks for your help in advance!