Model reference · open weights

mgp-str

LLMs alibaba-damo Image→text 1 build Licence not stated 104k dl/mo

mgp-str is an open-weight language model from alibaba-damo. mgp-str-base (FP32) weighs 296 MB; the smallest configuration that runs it is RTX 3060 12 GB.

  • MGP-STR is a 148M parameter image-to-text model developed by alibaba-damo for scene text recognition.
  • It uses a ViT architecture initialized from DeiT-base and A^3 modules to process 32x128 images, predicting characters, subwords, and words.
  • The model was trained on MJSynth and SynthText datasets and is available as alibaba-damo/mgp-str-base.

Summary of the alibaba-damo/mgp-str-base model card, 2026-10-01

What it is

Released byalibaba-damo
Released2022-11-23
Parameters148M
VRAM296 MB for the weights

What it runs on

Memory and cards for mgp-str-base (FP32)

296 MBweights, file size
37 MBcache per 1K tokens
598 MBruntime overhead, at least
CardRequests at onceContext maxMemory
8K each32K each
RTX 3060 12 GB358128K11.6 GB
RTX 4060 Ti 16 GB4812128K15.4 GB
RTX 3090 24 GB7418128K23.4 GB
RTX 4090 24 GB7418128K23.4 GB
RTX 5090 32 GB9924128K31.0 GB
L40S 48 GB14235128K44.0 GB
A100 80 GB25563128K78.2 GB
H100 80 GB24360128K78.1 GB
RTX PRO 6000 Blackwell 96 GB29573128K93.8 GB
DGX Spark (GB10) 128 GB unified34085128K107 GB
H200 141 GB441110128K138 GB
B200 180 GB567141128K176 GB
Memory needed at each load
Requests at once8K tokens each32K tokens each
11.2 GB2.1 GB
52.4 GB6.9 GB
83.3 GB10.6 GB
165.7 GB20.2 GB
3210.6 GB39.5 GB
6420.2 GB78.2 GB

One card, with vLLM's small-card settings.

From the model card

What alibaba-damo says about mgp-str

Read the model card

MGP-STR base-sized model is trained on MJSynth and SynthText. It was introduced in the paper Multi-Granularity Prediction for Scene Text Recognition and first released in this repository.

Model description

MGP-STR is pure vision STR model, consisting of ViT and specially designed A^3 modules. The ViT module was initialized from the weights of DeiT-base, except the patch embedding model, due to the inconsistent input size.

Images (32x128) are presented to the model as a sequence of fixed-size patches (resolution 4x4), which are linearly embedded. One also adds absolute position embeddings before feeding the sequence to the layers of the ViT module. Next, A^3 module selects a meaningful combination from the tokens of ViT output and integrates them into one output token corresponding to a specific character. Moreover, subword classification heads based on BPE A^3 module and WordPiece A^3 module are devised for subword predictions, so that the language information can be implicitly modeled. Finally, these multi-granularity predictions (character, subword and even word) are merged via a simple and effective fusion strategy.

Intended uses & limitations

You can use the raw model for optical character recognition (OCR) on text images. See the model hub to look for fine-tuned versions on a task that interests you.

How to use

Here is how to use this model in PyTorch:

from transformers import MgpstrProcessor, MgpstrForSceneTextRecognition
import requests
from PIL import Image

processor = MgpstrProcessor.from_pretrained('alibaba-damo/mgp-str-base')
model = MgpstrForSceneTextRecognition.from_pretrained('alibaba-damo/mgp-str-base')

# load image from the IIIT-5k dataset
url = "https://i.postimg.cc/ZKwLg2Gw/367-14.png"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")

pixel_values = processor(images=image, return_tensors="pt").pixel_values
outputs = model(pixel_values)

generated_text = processor.batch_decode(outputs.logits)['generated_text']

BibTeX entry and citation info

@inproceedings{ECCV2022mgp_str,
  title={Multi-Granularity Prediction for Scene Text Recognition},
  author={Peng Wang, Cheng Da, and Cong Yao},
  booktitle = {ECCV},
  year={2022}
}

Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.

© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms