Downloads · 30 days
11
5% of all-time downloads
NirajRajai/dots_table
dots_table is a image-to-text model from NirajRajai. Use it when you need a caption or text from an image. The card lists the license as apache-2.0.
This is a fine-tuned version of DotsOCR, optimized for document OCR tasks.
Downloads · 30 days
11
5% of all-time downloads
All-time downloads
230
Public
Parameters
3B
6.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors6.1 GB · 100%
From the Hugging Face model README
This is a fine-tuned version of DotsOCR, optimized for document OCR tasks.
from transformers import AutoModelForCausalLM, AutoProcessor
import torch
from PIL import Image
# Load model and processor
model = AutoModelForCausalLM.from_pretrained(
"NirajRajai/dots_table",
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
attn_implementation="flash_attention_2"
)
processor = AutoProcessor.from_pretrained(
"NirajRajai/dots_table",
trust_remote_code=True
)
# Process image
image = Image.open("document.png")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Extract the text content from this image."}
]
}
]
# Generate text
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt"
).to(model.device)
generated_ids = model.generate(**inputs, max_new_tokens=2048)
generated_ids_trimmed = [
out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)[0]
print(output_text)
Apache 2.0
If you use this model, please cite the original DotsOCR paper and this fine-tuned version.