Downloads · 30 days
18
8% of all-time downloads
JulioSnchezD/granite-vision-3.2-2b-table2html
granite-vision-3.2-2b-table2html is a image-text-to-text model from JulioSnchezD. 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. The card lists the license as apache-2.0.
granite-vision-3.2-2b-table2html is a fine-tuned multimodal model based on granite-vision-3.2-2b. It specializes in extracting HTML <table structures from images of tables.
Downloads · 30 days
18
8% of all-time downloads
All-time downloads
240
Public
Parameters
3B
11.9 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors11.9 GB · 100%
From the Hugging Face model README
granite-vision-3.2-2b-table2html is a fine-tuned multimodal model based on granite-vision-3.2-2b. It specializes in extracting HTML <table> structures from images of tables.
<table>...</table> content that structurally and semantically represents the table in the image.This model was fine-tuned using PEFT with LoRA (Low-Rank Adaptation) to reduce memory footprint and improve training efficiency.
apoidea/pubtabnet-html"Convert table to HTML (<table> ... </table>)"adamw_torch_fusedtarget_modules = []
for layer_type in layers_to_tune:
target_modules.extend(
name for name, _ in model.named_modules()
if (layer_type in name)
and '_proj' in name
)
LoraConfig(
r=16,
lora_alpha=32,
lora_dropout=0.1,
target_modules=target_modules,
use_dora=True,
init_lora_weights="gaussian"
)
0.01180.770
These metrics indicate that the model not only converged well during training but also performs accurately on semantic table reconstruction tasks.from transformers import AutoProcessor, AutoModelForVision2Seq
from huggingface_hub import hf_hub_download
import torch
model_path = "ibm-granite/granite-vision-3.2-2b"
processor = AutoProcessor.from_pretrained(model_path, use_fast=True)
model = AutoModelForVision2Seq.from_pretrained(
model_path,
device_map="auto",
torch_dtype=torch.bfloat16,
_attn_implementation="flash_attention_2"
)
def predict(img):
# Prepare prompt
conversation = [
{
"role": "system",
"content": [
{"type": "text", "text": "Convert table to HTML (<table> ... </table>)"}
]
},
{
"role": "user",
"content": [
{"type": "image"}
],
},
]
text = processor.apply_chat_template(conversation,
add_generation_prompt=True,
)
inputs = processor(images=[img], text=text, return_tensors="pt").to(device)
output = model.generate(**inputs, max_new_tokens=1500)
output = processor.decode(output[0], skip_special_tokens=True)
return output.split('<|assistant|>')[-1].strip()
# Load image
ds = load_dataset('apoidea/pubtabnet-html', streaming=True)['validation']
sample = next(iter(ds))
# autoregressively complete prompt
table = predict(sample['image'])
display(HTML(table)
👉 Read the full story behind this project: "Fine-Tuning Granite-Vision 2B to Outperform 90B Giants (Table Extraction Task)"
If you use this model, please cite the work:
@misc{granite2025table2html,
title={granite-vision-3.2-2b-table2html: Table HTML extraction from images},
author={Julio Sánchez},
year={2025},
howpublished={\url{https://huggingface.co/JulioSnchezD/granite-vision-3.2-2b-table2html}},
}