Downloads · 30 days
241
5% of all-time downloads
viklofg/swedish-ocr-correction
swedish-ocr-correction is a machine learning model from viklofg. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This model corrects OCR errors in Swedish text.
Downloads · 30 days
241
5% of all-time downloads
All-time downloads
4.7K
Public
Repo size
2.4 GB
Likes
5
Public
Click a slice to open those files.
.bin1.2 GB · 100%
From the Hugging Face model README
This model corrects OCR errors in Swedish text.
This model is a fine-tuned version of byt5-small, a character-level multilingual transformer. The fine-tuning data consists of OCR samples from Swedish newspapers and historical documents. The model works on texts up to 128 UTF-8 bytes (see Length limit).
<!-- ### Model Description--> <!-- Provide a longer summary of what this model is. - **Developed by:** [More Information Needed] - **Funded by [optional]:** [More Information Needed] - **Shared by [optional]:** [More Information Needed] - **Model type:** [More Information Needed] - **Language(s) (NLP):** [More Information Needed] - **License:** [More Information Needed] - **Finetuned from model [optional]:** [More Information Needed] ### Model Sources [optional] - **Repository:** [More Information Needed] - **Paper [optional]:** [More Information Needed] - **Demo [optional]:** [More Information Needed]-->The base model byt5 is pre-trained on mc4. This fine-tuned version is further trained on:
This data includes characters not used in Swedish today, such as the long s (ſ) and the esszett ligature (ß), which means that the model should be able to handle texts with these characters. See for example the example titled Long-s piano ad in the inference widget to the right.
Use the code below to get started with the model.
from transformers import pipeline, T5ForConditionalGeneration, AutoTokenizer
model = T5ForConditionalGeneration.from_pretrained('viklofg/swedish-ocr-correction')
tokenizer = AutoTokenizer.from_pretrained('google/byt5-small')
pipe = pipeline('text2text-generation', model=model, tokenizer=tokenizer)
ocr = 'Den i HandelstidniDgens g&rdagsnnmmer omtalade hvalfisken, sorn fångats i Frölnndaviken'
output = pipe(ocr)
print(output)
The model accepts input sequences of at most 128 UTF-8 bytes, longer sequences are truncated to this limit. 128 UTF-8 bytes corresponds to slightly less than 128 characters of Swedish text since most characters are encoded as one byte, but non-ASCII characters such as Å, Ä, and Ö are encoded as two (or more) bytes.