Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
VOCAB= ascii_uppercase+digits+punctuation+" \t\n"
#Change to CUDA to run using GPU
device = 'cpu'
def get_test_data(etfo):
text = etfo
text_tensor = torch.zeros(len(text), 1, dtype=torch.long)
text_tensor[:, 0] = torch.LongTensor([VOCAB.find(c) for c in text])
return text_tensor.to(device)
etfo = get_info('invoice.png')
# etfo = get_info('X51005621482.jpeg')
etfo = etfo.upper()
text_tensor = get_test_data(etfo)
temp = []
for i in range(len(text_tensor)):
if text_tensor[i]>=0 and text_tensor[i]<=70:
temp.append([int(text_tensor[i])])
text_tensor = torch.LongTensor(temp)
#model initialization
hidden_size = 256
device= torch.device('cpu')
model = ExtractLSTM(len(VOCAB), 16, hidden_size).to(device)
model.load_state_dict(torch.load('model.pth'))
result = test(model)
print(result)
@ttchengab
Copy link
Author

ttchengab commented Oct 29, 2020

Hi,
Can you tell me what is the pre trained model you have used in place of 'model.pth' in line 26

I used the checkpoint from the solution I talked about in this blog:
https://nanonets.com/blog/key-value-pair-extraction-from-documents-using-ocr-and-deep-learning/

@yasmineChelly-95
Copy link

yasmineChelly-95 commented Nov 11, 2020

Hi, thank you for sharing this implementation code. I read your blog and I followed the steps correctly now I have the code running. However I think I chose the wrong model because I have poor results. I generated the 'model.pth' from this repo https://github.com/zzzDavid/ICDAR-2019-SROIE/tree/master/task3 please correct if I'm wrong and if not did you use different data that gave you these good results ?

@Vibha111094
Copy link

Vibha111094 commented Dec 13, 2020

I am facing the same issue that yasmineChelly-95 has.
I am getting very poor results.
Can you please let us know if you used any different data or something?

@luisguareschi
Copy link

luisguareschi commented Oct 15, 2021

Hi, thank you for sharing this implementation code. I read your blog and I followed the steps correctly now I have the code running. However I think I chose the wrong model because I have poor results. I generated the 'model.pth' from this repo https://github.com/zzzDavid/ICDAR-2019-SROIE/tree/master/task3 please correct if I'm wrong and if not did you use different data that gave you these good results ?

Hello, could you share me your code so I could take a look at it?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment