Description
Ocr small model for recognise printed text based on TrOcr architecture. The TrOCR model was proposed in TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang, Zhoujun Li, Furu Wei. TrOCR consists of an image Transformer encoder and an autoregressive text Transformer decoder to perform optical character recognition (OCR). The abstract from the paper is the following: Text recognition is a long-standing research problem for document digitalization. Existing approaches for text recognition are usually built based on CNN for image understanding and RNN for char-level text generation. In addition, another language model is usually needed to improve the overall accuracy as a post-processing step. In this paper, we propose an end-to-end text recognition approach with pre-trained image Transformer and text Transformer models, namely TrOCR, which leverages the Transformer architecture for both image understanding and wordpiece-level text generation. The TrOCR model is simple but effective, and can be pre-trained with large-scale synthetic data and fine-tuned with human-labeled datasets. Experiments show that the TrOCR model outperforms the current state-of-the-art models on both printed and handwritten text recognition tasks.
Predicted Entities
How to use
ocr = ImageToTextv2().pretrained(“ocr_small_printed”, “en”, “clinical/ocr”) ocr.setInputCols([“image”]) ocr.setOutputCol(“text”)
result = ocr.transform(image_text_lines_df).collect() print(result[0].text)
ocr = ImageToTextv2().pretrained("ocr_base_printed", "en", "clinical/ocr")
ocr.setInputCols(["image"])
ocr.setOutputCol("text")
result = ocr.transform(image_text_lines_df).collect()
print(result[0].text)
<div class="tabs-box" markdown="1">
<div class="tabs-model-aproach-head"><button class="tab-li-model-aproach tabheader_active">Python<strong>Healthcare NLP</strong></button><button class="tab-li-model-aproach tab-li-jsl">Python<strong>JohnSnowLabs</strong></button><button class="tab-li-model-aproach">Scala</button><button class="tab-li-model-aproach tab-li-nlu">NLU</button></div>
```python
ocr = ImageToTextv2().pretrained("ocr_small_printed", "en", "clinical/ocr")
ocr.setInputCols(["image"])
ocr.setOutputCol("text")
result = ocr.transform(image_text_lines_df).collect()
print(result[0].text)
<div class="tabs-box" markdown="1">
<div class="tabs-model-aproach-head"><button class="tab-li-model-aproach tabheader_active">Python<strong>Healthcare NLP</strong></button><button class="tab-li-model-aproach tab-li-jsl">Python<strong>JohnSnowLabs</strong></button><button class="tab-li-model-aproach">Scala</button><button class="tab-li-model-aproach tab-li-nlu">NLU</button></div>
```python
ocr = ImageToTextv2().pretrained("ocr_base_printed", "en", "clinical/ocr")
ocr.setInputCols(["image"])
ocr.setOutputCol("text")
result = ocr.transform(image_text_lines_df).collect()
print(result[0].text)
Model Information
Model Name: | ocr_small_printed |
Type: | ocr |
Compatibility: | Visual NLP 3.3.3+ |
License: | Licensed |
Edition: | Official |
Language: | en |
Size: | 146.7 MB |