Downloads · 30 days
7
33% of all-time downloads
lucasoc/sci-image-markdown-qwen2.5-vl-3b
sci-image-markdown-qwen2.5-vl-3b is a image-to-text model from lucasoc. Use it when you need a caption or text from an image. It is set up for peft. The card lists the license as apache-2.0.
Fine-tuned PEFT LoRA adapter for Qwen2.5-VL-3B-Instruct designed to extract quantitative plotted data from scientific figure panels directly into clean, structured Markdown tables.
Downloads · 30 days
7
33% of all-time downloads
All-time downloads
21
Public
Repo size
26.2 MB
Likes
0
Public
Click a slice to open those files.
.safetensors14.8 MB · 56%
From the Hugging Face model README
Fine-tuned PEFT LoRA adapter for Qwen2.5-VL-3B-Instruct designed to extract quantitative plotted data from scientific figure panels directly into clean, structured Markdown tables.
This model was trained using an ICDAR Metric-Aware Loss (combining Differentiable Token-Weighted Numerical & Structural loss with fast in-VRAM GPU rewards for Table Edit Distance and Cell RMS Error).
| Metric | Base Model (Zero-Shot) | Standard SFT (Cross-Entropy) | Our LoRA (ICDAR Metric Loss) |
|---|---|---|---|
| Valid Markdown Table | 88.74% | 99.73% | 99.73% |
| Cell Precision | 21.08% | 21.37% | 39.58% (+85.2%) |
| Cell F1-Score | 18.42% | 20.60% | 34.67% (+68.3%) |
| TEDS (Tree Edit Distance) | 23.16% | 23.16% | 36.24% (+56.5%) |
| ICDAR Numerical RMS | 48.12% | 48.12% | 51.66% (+7.4%) |
| ICDAR Composite Score | 35.64% | 35.64% | 43.95% (+23.3%) |
pip install torch transformers peft qwen-vl-utils pillow torchvision bitsandbytes
import torch
from PIL import Image
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration, BitsAndBytesConfig
from peft import PeftModel
from qwen_vl_utils import process_vision_info
model_id = "Qwen/Qwen2.5-VL-3B-Instruct"
adapter_id = "lucasoc/sci-image-markdown-qwen2.5-vl-3b"
# 1. Load processor
processor = AutoProcessor.from_pretrained(adapter_id)
# 2. Load 4-bit base model
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
base_model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
model_id,
quantization_config=bnb_config,
torch_dtype=torch.float16,
device_map="auto"
)
# 3. Load trained LoRA adapter
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
# 4. Extract table from figure
image_path = "figure.png"
image = Image.open(image_path).convert("RGB")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Extract the plotted quantitative data into a clean Markdown table with column headers."}
]
}
]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, _ = process_vision_info(messages)
inputs = processor(text=[text], images=image_inputs, padding=True, return_tensors="pt").to("cuda")
with torch.inference_mode():
generated_ids = model.generate(**inputs, max_new_tokens=1024, temperature=0.0)
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("--- Extracted Markdown Table ---")
print(output_text)
Qwen2.5-VL-3B-Instruct