Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always missing one character in the output #134

Open
manhcuogntin4 opened this issue Jul 6, 2017 · 3 comments
Open

Always missing one character in the output #134

manhcuogntin4 opened this issue Jul 6, 2017 · 3 comments

Comments

@manhcuogntin4
Copy link

I used pyclstm for trainning my dataset on date but the output always missing the character 9. All the rest character is Ok. Hope for help !

@kba
Copy link
Collaborator

kba commented Jul 6, 2017

Can you provide sample images, sample output, what data you trained on, parameters used for training / recognition?

@manhcuogntin4
Copy link
Author

manhcuogntin4 commented Jul 6, 2017

@kba thank for your answer !
10 bin
the output of test is 24/07/16
59 bin
the output of test is 0/0/166

And here is my code:

all_imgs = [Image.open(p) for p in sorted(glob.glob("./book/*/*.png"))]
all_texts = [open(p).read().strip() for p in sorted(glob.glob("./book/*/*.gt.txt"))]
if sys.version_info <= (3,): 
 all_texts = [t.decode('utf8', "replace") for t in all_texts]

all_data = list(zip(all_imgs, all_texts))
train_data = all_data[:5500]
test_data = all_data[5500:]
len(all_data)
ocr = pyclstm.ClstmOcr()
graphemes = set(chain.from_iterable(all_texts))
#graphemes=('0','1','2','3','4','5','6','7','8','9', '/','*')
ocr.prepare_training(graphemes)

for i in range(100000):
    best_error = 1.
    img, txt = random.choice(train_data)
    out = ocr.train(img, txt)
    if not i % 10:
        aligned = ocr.aligned()
        print("Truth:   {}".format(txt))
        print("Aligned: {}".format(aligned))
        print("Output:  {}".format(out))
    if not i % 1000:
        errors = 0
        chars = 0
        for img, txt in test_data:
            out = ocr.recognize(img)
            errors += pyclstm.levenshtein(txt, out)
            chars += len(txt)
        error = errors / chars
        print ("=== Test set error after {} iterations: {:.2f}"
               .format(i, error))
        if error < best_error:
            print("=== New best error, saving model to model_date_permis.clstm")
            ocr.save("./model_date_permis.clstm")

@lomograb
Copy link

lomograb commented Jul 6, 2017

Train more = Better result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants