Instructions to use Remidesbois/surya-bubble-ocr-poneglyph with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Remidesbois/surya-bubble-ocr-poneglyph with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Remidesbois/surya-bubble-ocr-poneglyph") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Remidesbois/surya-bubble-ocr-poneglyph") model = AutoModelForMultimodalLM.from_pretrained("Remidesbois/surya-bubble-ocr-poneglyph", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Remidesbois/surya-bubble-ocr-poneglyph with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Remidesbois/surya-bubble-ocr-poneglyph" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Remidesbois/surya-bubble-ocr-poneglyph", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Remidesbois/surya-bubble-ocr-poneglyph
- SGLang
How to use Remidesbois/surya-bubble-ocr-poneglyph with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Remidesbois/surya-bubble-ocr-poneglyph" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Remidesbois/surya-bubble-ocr-poneglyph", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Remidesbois/surya-bubble-ocr-poneglyph" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Remidesbois/surya-bubble-ocr-poneglyph", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Remidesbois/surya-bubble-ocr-poneglyph with Docker Model Runner:
docker model run hf.co/Remidesbois/surya-bubble-ocr-poneglyph
Surya Bubble OCR Poneglyph
Fine-tune de datalab-to/surya-ocr-2
pour la transcription exacte de bulles de manga francophones recadrées.
Ce modèle transcrit une bulle à la fois ; il ne détecte pas les bulles et ne
renvoie pas de bounding boxes.
Résultats
Entraînement local sur une NVIDIA RTX 3090. Le split est effectué par page : aucune page source n'est partagée entre train, validation et test.
| Split | Pages | Bulles |
|---|---|---|
| Train | 749 | 6 793 |
| Validation | 161 | 1 311 |
| Test held-out | 161 | 1 423 |
Benchmark final exhaustif sur les 1 423 bulles du test held-out :
| Métrique | Résultat |
|---|---|
| CER | 0,451 % |
| WER | 1,656 % |
| Exact match | 90,65 % |
| Levenshtein moyen | 0,1595 caractère |
| Sorties vides | 0 / 1 423 |
| Hallucinations sur références vides | 0 |
| Limite de génération atteinte | 0 / 1 423 |
Les textes très courts de 1 à 2 caractères atteignent 100 % d'exact match sur 98 exemples. Les erreurs restantes se concentrent principalement sur les onomatopées ambiguës, la casse et les répétitions de rires.
Le fichier benchmark_test.json contient les métriques,
les tranches par longueur et les prédictions de chaque échantillon.
Utilisation
import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "Remidesbois/surya-bubble-ocr-poneglyph"
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map="cuda",
trust_remote_code=True,
).eval()
image = Image.open("bulle.png").convert("RGB")
messages = [{
"role": "user",
"content": [
{"type": "image", "image": "bulle.png"},
{
"type": "text",
"text": "Transcris exactement le texte visible dans cette bulle. Ne rajoute rien.",
},
],
}]
prompt = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=False,
)
inputs = processor(text=[prompt], images=[image], return_tensors="pt").to("cuda")
with torch.inference_mode():
output_ids = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
)
prompt_tokens = inputs["input_ids"].shape[1]
text = processor.batch_decode(
output_ids[:, prompt_tokens:],
skip_special_tokens=True,
)[0].strip()
print(text)
Entraînement
- 665,7 M paramètres, dont 606,0 M entraînables ;
- modèle langage complet, merger multimodal et 4 derniers blocs vision ;
- BF16 et TF32 ;
- batch physique 16, accumulation de gradient 2 ;
- 5 époques, sélection du meilleur checkpoint sur le CER génératif ;
- budget de génération de 256 tokens.
Le pipeline reproductible se trouve dans le dossier
docker_scripts/finetune_surya_bubble_ocr du projet Poneglyph.
Limites
- Le test est un holdout par page issu du même projet et du même processus de validation que le train ; il ne mesure pas une généralisation universelle à tous les mangas, langues ou styles d'impression.
- Le modèle attend un crop contenant une seule zone de texte.
- Les onomatopées rares ou très stylisées restent la principale source d'erreurs.
- La licence
openrailest héritée du modèle de base.
- Downloads last month
- 24
Model tree for Remidesbois/surya-bubble-ocr-poneglyph
Base model
datalab-to/surya-ocr-2Evaluation results
- CER on Poneglyph held-out bubble OCRtest set self-reported0.005
- WER on Poneglyph held-out bubble OCRtest set self-reported0.017
- Exact match on Poneglyph held-out bubble OCRtest set self-reported0.907