Downloads · 30 days
19
2% of all-time downloads
powow/nougat-swe
nougat-swe is a image-text-to-text model from powow. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for transformers.
Fine-tuned version of facebook/nougat-small. Primarily trained on mathematical expressions and Swedish text.
Downloads · 30 days
19
2% of all-time downloads
All-time downloads
974
Public
Parameters
247M
15.8 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors990 MB · 100%
How the weights are stored.
F32247M · 100%
From the Hugging Face model README
Fine-tuned version of facebook/nougat-small. Primarily trained on mathematical expressions and Swedish text.
Related code at: https://github.com/will-berg/nougat-swe
Code for inference on a pdf is in the GitHub repo, but can be done quickly on a provided image (of a pdf page) using the following code:
from PIL import Image
from transformers import NougatProcessor, VisionEncoderDecoderModel
import torch
processor = NougatProcessor.from_pretrained("powow/nougat-swe")
model = VisionEncoderDecoderModel.from_pretrained("powow/nougat-swe")
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
image = Image.open(image_path)
pixel_values = processor(image, return_tensors="pt").pixel_values
outputs = model.generate(
pixel_values.to(device),
min_length=1,
max_new_tokens=3584,
bad_words_ids=[[processor.tokenizer.unk_token_id]],
)
sequence = processor.batch_decode(outputs, skip_special_tokens=True)[0]
sequence = processor.post_process_generation(sequence, fix_markdown=False)
print(sequence)