Downloads · 30 days
63
12% of all-time downloads
psyka-101/GLM-OCR-Manga-LoRA
GLM-OCR-Manga-LoRA is a image-text-to-text model from psyka-101. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as mit.
A LoRA adapter for GLM-OCR fine-tuned on manga text recognition.
Downloads · 30 days
63
12% of all-time downloads
All-time downloads
544
Public
Repo size
2.4 GB
Likes
10
Public
Click a slice to open those files.
.safetensors15 MB · 65%
From the Hugging Face model README
A LoRA adapter for GLM-OCR fine-tuned on manga text recognition.
This adapter significantly improves GLM-OCR's performance on Japanese manga speech bubbles, vertical text, and complex typographic styles by training on ~143k image-text pairs from Manga109-s and manga-synthetic datasets.
| Metric | Baseline | Fine-Tuned | Improvement |
|---|---|---|---|
| Character Error Rate | 111.43% | 26.02% | ↓ 76.6% |
| Exact Match Accuracy | 12.72% | 55.91% | ↑ 339.4% |
The baseline CER exceeding 100% is due to severe hallucination — the base model would frequently output hundreds of repetitive characters for short inputs. The LoRA adapter nearly eliminates this failure mode.
| Property | Value |
|---|---|
| Base Model | zai-org/GLM-OCR (0.9B params) |
| Method | LoRA (Low-Rank Adaptation) |
| LoRA Rank | 8 |
| LoRA Target | All linear layers |
| Precision | BFloat16 |
| Training Hardware | NVIDIA RTX 3060 (12GB VRAM) |
| Training Data | ~143k samples (90/10 train/val split) |
| Epochs | 3 |
The training corpus was assembled from two complementary sources:
All samples were formatted in ShareGPT conversational structure for LLaMA-Factory compatibility.
import torch
from transformers import AutoProcessor, AutoModelForImageTextToText
from peft import PeftModel
from PIL import Image
# Load base model + LoRA adapter
processor = AutoProcessor.from_pretrained("zai-org/GLM-OCR", trust_remote_code=True)
base_model = AutoModelForImageTextToText.from_pretrained(
"zai-org/GLM-OCR",
torch_dtype=torch.float16,
device_map="cuda",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(base_model, "YOUR_HF_USERNAME/GLM-OCR-Manga-LoRA")
model.eval()
# Run inference
image = Image.open("manga_crop.png").convert("RGB")
messages = [{"role": "user", "content": [
{"type": "image", "image": image},
{"type": "text", "text": "Text Recognition:"},
]}]
inputs = processor.apply_chat_template(
messages, tokenize=True, add_generation_prompt=True,
return_dict=True, return_tensors="pt",
).to(model.device)
inputs.pop("token_type_ids", None)
with torch.inference_mode():
output = model.generate(**inputs, max_new_tokens=512)
result = processor.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(result)
pip install -r requirements.txt
python web_ui.py --lora-path ./path/to/adapter
Training was performed using LLaMA-Factory with the following configuration:
| Parameter | Value |
|---|---|
| Learning Rate | 1e-4 |
| LR Scheduler | Cosine |
| Warmup Ratio | 0.1 |
| Batch Size | 4 |
| Gradient Accumulation | 4 steps (effective batch = 16) |
| Gradient Checkpointing | Enabled |
| Cutoff Length | 1024 tokens |
| Total Steps | ~26,856 |
The model demonstrated stable convergence throughout training:
@misc{glm-ocr-manga-lora,
title = {GLM-OCR-Manga-LoRA: Fine-tuning GLM-OCR for Manga Text Recognition},
author = {Psyka},
year = {2026},
url = {https://github.com/Psyka/glm-ocr-manga-finetune},
}