alibaba-damo / mgp-str-base

huggingface.co
Total runs: 50.7K
24-hour runs: -1.6K
7-day runs: -27.6K
30-day runs: -55.8K
Model's Last Updated: December 11 2023
image-to-text

Introduction of mgp-str-base

Model Details of mgp-str-base

MGP-STR (base-sized model)

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}
}

Runs of alibaba-damo mgp-str-base on huggingface.co

50.7K
Total runs
-1.6K
24-hour runs
-8.1K
3-day runs
-27.6K
7-day runs
-55.8K
30-day runs

More Information About mgp-str-base huggingface.co Model

mgp-str-base huggingface.co

mgp-str-base huggingface.co is an AI model on huggingface.co that provides mgp-str-base's model effect (), which can be used instantly with this alibaba-damo mgp-str-base model. huggingface.co supports a free trial of the mgp-str-base model, and also provides paid use of the mgp-str-base. Support call mgp-str-base model through api, including Node.js, Python, http.

alibaba-damo mgp-str-base online free

mgp-str-base huggingface.co is an online trial and call api platform, which integrates mgp-str-base's modeling effects, including api services, and provides a free online trial of mgp-str-base, you can try mgp-str-base online for free by clicking the link below.

alibaba-damo mgp-str-base online free url in huggingface.co:

https://huggingface.co/alibaba-damo/mgp-str-base

mgp-str-base install

mgp-str-base is an open source model from GitHub that offers a free installation service, and any user can find mgp-str-base on GitHub to install. At the same time, huggingface.co provides the effect of mgp-str-base install, users can directly use mgp-str-base installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

mgp-str-base install url in huggingface.co:

https://huggingface.co/alibaba-damo/mgp-str-base

Url of mgp-str-base

Provider of mgp-str-base huggingface.co

alibaba-damo
ORGANIZATIONS

Other API from alibaba-damo