Instructions to use Remidesbois/LightonOCR-2-1b-poneglyph with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Remidesbois/LightonOCR-2-1b-poneglyph with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Remidesbois/LightonOCR-2-1b-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/LightonOCR-2-1b-poneglyph") model = AutoModelForMultimodalLM.from_pretrained("Remidesbois/LightonOCR-2-1b-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/LightonOCR-2-1b-poneglyph with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Remidesbois/LightonOCR-2-1b-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/LightonOCR-2-1b-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/LightonOCR-2-1b-poneglyph
- SGLang
How to use Remidesbois/LightonOCR-2-1b-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/LightonOCR-2-1b-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/LightonOCR-2-1b-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/LightonOCR-2-1b-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/LightonOCR-2-1b-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/LightonOCR-2-1b-poneglyph with Docker Model Runner:
docker model run hf.co/Remidesbois/LightonOCR-2-1b-poneglyph
LightOnOCR-2-1B Poneglyph
Version fine-tunée de lightonai/LightOnOCR-2-1B-base, spécialisée dans la transcription OCR de bulles de manga françaises recadrées.
Ce modèle est entraîné directement depuis le modèle de base. Il ne reprend pas les poids d’un ancien fine-tune Poneglyph.
Résultats
Évaluation held-out sur 1 128 crops, avec une séparation stricte par page :
| Métrique | Résultat |
|---|---|
| CER | 0,329 % |
| WER | 1,200 % |
| Exact match | 93,00 % |
| Blank rate | 0 % |
| Multiline rate | 0 % |
| Token-limit rate | 0 % |
Les détails complets, les erreurs les plus difficiles et la comparaison au modèle publié sont disponibles dans benchmark_test.json. Le gate de qualité est conservé dans quality_gate.json.
Utilisation
from PIL import Image
from transformers import AutoProcessor, AutoModelForImageTextToText
import torch
model_id = "Remidesbois/LightonOCR-2-1b-poneglyph"
processor = AutoProcessor.from_pretrained(model_id, fix_mistral_regex=True)
model = AutoModelForImageTextToText.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
image = Image.open("bubble.png").convert("RGB")
prompt = "Transcription OCR (uniquement le texte de la bulle, pas de suite) :"
messages = [{
"role": "user",
"content": [{"type": "image"}, {"type": "text", "text": prompt}],
}]
text = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
with torch.inference_mode():
output = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(processor.batch_decode(output[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0].strip())
Pour une RTX 3090, torch.bfloat16 est recommandé. Le modèle attend principalement un crop de bulle unique ; la détection et le découpage des bulles doivent être effectués en amont.
Fine-tuning
La recette rtx3090-base-dora-v5 utilise un entraînement LoRA/DoRA depuis le modèle de base : rang 65, alpha 130, cibles attention/MLP et lm_head, BF16, SDPA, AdamW fusionné, longueur d’image maximale 700 px et longueur de génération maximale 128 tokens. Les transcriptions d’un seul caractère sont conservées.
Les paramètres exacts sont archivés dans training_recipe.json. Les fichiers de benchmark sont fournis pour rendre les chiffres reproductibles.
Limites
Les métriques sont mesurées sur le jeu de test du corpus Poneglyph et ne constituent pas une garantie de performance sur d’autres mangas, langues, polices ou mises en page. Le modèle ne réalise pas la détection de bulles et ne fournit pas de bounding boxes.
- Downloads last month
- 13
Model tree for Remidesbois/LightonOCR-2-1b-poneglyph
Base model
lightonai/LightOnOCR-2-1B-base