Downloads · 30 days
30
9% of all-time downloads
lamco-development/granite-docling-258M-onnx
granite-docling-258M-onnx is a image-to-text model from lamco-development. Use it when you need a caption or text from an image. It is set up for onnxruntime. The card lists the license as apache-2.0.
The first and only ONNX conversion of IBM's granite-docling-258M - enabling high-performance document AI in Rust applications.
Downloads · 30 days
30
9% of all-time downloads
All-time downloads
336
Public
Repo size
1.3 GB
Likes
7
Public
Click a slice to open those files.
.onnx1.3 GB · 99%
From the Hugging Face model README
The first and only ONNX conversion of IBM's granite-docling-258M - enabling high-performance document AI in Rust applications.
<div align="center">
| Feature | Capability |
|---|---|
| Architecture | Idefics3-based VLM (SigLIP2 + Granite 165M) |
| Input | Document images (512×512) + text prompts |
| Output | DocTags structured markup |
| Performance | 2-5x faster than PyTorch inference |
| Memory | 60-80% less RAM usage |
| Hardware | CPU, CUDA, DirectML, TensorRT |
import onnxruntime as ort
import numpy as np
from PIL import Image
# Load the ONNX model
session = ort.InferenceSession('model.onnx')
# Prepare document image
image = Image.open('document.png').resize((512, 512))
pixel_values = np.array(image).astype(np.float32) / 255.0
pixel_values = pixel_values.transpose(2, 0, 1)[np.newaxis, :]
# Prepare text input
input_ids = np.array([[1, 2, 3, 4, 5]], dtype=np.int64)
attention_mask = np.ones((1, 5), dtype=np.int64)
# Run inference
outputs = session.run(None, {
'pixel_values': pixel_values,
'input_ids': input_ids,
'attention_mask': attention_mask
})
print(f"Generated DocTags logits: {outputs[0].shape}")
use ort::{Session, inputs, execution_providers::ExecutionProvider};
// Load granite-docling ONNX model
let session = Session::builder()?
.with_optimization_level(GraphOptimizationLevel::Level3)?
.with_execution_providers([
ExecutionProvider::DirectML, // Windows acceleration
ExecutionProvider::CUDA, // NVIDIA acceleration
ExecutionProvider::CPU, // Universal fallback
])?
.commit_from_file("model.onnx")?;
// Process document
let document_tensor = preprocess_document_image("document.pdf")?;
let outputs = session.run(inputs![document_tensor])?;
let doctags = decode_doctags_markup(outputs)?;
| Metric | PyTorch | ONNX Runtime | Improvement |
|---|---|---|---|
| Inference Time | 2.5s | 0.8s | 3.1x faster |
| Memory Usage | 4.2GB | 1.8GB | 57% reduction |
| CPU Utilization | 85% | 62% | 27% more efficient |
| Model Loading | 8.5s | 3.2s | 2.7x faster |
Benchmarks on Intel i7-12700K, 32GB RAM, NVIDIA RTX 4080
Revolutionary structured markup format designed for AI processing:
<doctag>
<title><loc_50><loc_20><loc_450><loc_60>Document Title</title>
<text><loc_50><loc_80><loc_450><loc_200>Main content paragraph...</text>
<otsl>
<ched>Header 1<ched>Header 2<nl>
<fcel>Cell 1<fcel>Cell 2<nl>
</otsl>
<formula><loc_100><loc_300><loc_400><loc_350>E = mc^2</formula>
</doctag>
Features:
This model was converted using IBM's experimental Idefics3Support branch:
[dependencies]
ort = { version = "2.0.0-rc.10", features = ["directml", "cuda"] }
pip install onnxruntime-gpu # or onnxruntime for CPU
npm install onnxruntime-web
We welcome contributions! Areas of interest:
This ONNX model is a derivative work of IBM Research's granite-docling-258M, distributed under Apache 2.0 license with full attribution to the original creators.
Original Work: IBM Research granite-docling-258M ONNX Conversion: lamco-development License: Apache License 2.0
Built with ❤️ by lamco-development
Advancing AI infrastructure for document processing
</div>