Code Monkey home page Code Monkey logo

Comments (5)

trongvanhpkt99 avatar trongvanhpkt99 commented on September 18, 2024

I want to train a model for OCR-correcting output in Vietnamese, so at fist I want to know how to use a pre-trained model

from natas.

mikahama avatar mikahama commented on September 18, 2024

We only have a pretrained model for English at the moment, so it will not work with Vietnamese. Natas calls OpenNMT-py on the background, so basically you can use onmt_translate with your own model, pass it -n_best 10 and filter the results with a dictionary.

from natas.

trongvanhpkt99 avatar trongvanhpkt99 commented on September 18, 2024

We only have a pretrained model for English at the moment, so it will not work with Vietnamese. Natas calls OpenNMT-py on the background, so basically you can use onmt_translate with your own model, pass it -n_best 10 and filter the results with a dictionary.

Thank you! Can you give me the English pretrained model and tell me how to use it?

from natas.

mikahama avatar mikahama commented on September 18, 2024

This is how to use it from Natas:

import natas
natas.ocr_correct_words(["paft", "friendlhip"])

To use it with OpenNMT, you must first download the model.

Then you will need to prepare a text file with the words you want to OCR post-correct so that there is one word per line and each word should be split into characters.

So if you have a sentence cat ran avvay you should produce the following text file ocr_errors.txt

c a t
r a n
a v v a y

Then you can run onmt_translate -model ocr.pt -src ocr_errors.txt -output ocr_fixed.txt -replace_unk -verbose. This will produce a text file ocr_fixed.txt with the OCR corrections. OpenNMT lets you do all sorts of things in translate, so please refer to their documentation as well.

from natas.

trongvanhpkt99 avatar trongvanhpkt99 commented on September 18, 2024

This is how to use it from Natas:

import natas
natas.ocr_correct_words(["paft", "friendlhip"])

To use it with OpenNMT, you must first download the model.

Then you will need to prepare a text file with the words you want to OCR post-correct so that there is one word per line and each word should be split into characters.

So if you have a sentence cat ran avvay you should produce the following text file ocr_errors.txt

c a t
r a n
a v v a y

Then you can run onmt_translate -model ocr.pt -src ocr_errors.txt -output ocr_fixed.txt -replace_unk -verbose. This will produce a text file ocr_fixed.txt with the OCR corrections. OpenNMT lets you do all sorts of things in translate, so please refer to their documentation as well.

Thank you! I'll try it

from natas.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.