Qaari 0.1 Urdu OCR VL 2B Instruct
Qaari 0.1 Urdu是一款专门为乌尔都语文本的光学字符识别(OCR)优化的模型,基于Qwen/Qwen2-VL-2B进行微调,在乌尔都语OCR能力上有显著提升。
下载量 257
发布时间 : 3/10/2025
模型简介
该模型专注于乌尔都语文本的光学字符识别,具有高精度和卓越性能,大幅超越了基础模型和传统OCR解决方案。
模型特点
专为乌尔都语OCR设计
针对乌尔都语脚本识别进行了优化,具有高精度。
卓越性能
与基础模型相比,单词错误率(WER)降低了97.35%。
高精度
WER为0.048,字符错误率(CER)为0.029,BLEU分数为0.916。
输出长度均衡
长度比率接近完美,为0.978(理想值为1.0)。
模型能力
乌尔都语文本识别
高精度OCR
图像文本提取
使用案例
文档处理
乌尔都语文档数字化
将乌尔都语印刷文档转换为可编辑的电子文本。
高精度转换,错误率极低。
多语言OCR
多语言文本识别
支持多种乌尔都语字体和字体大小的识别。
在多种字体和大小下保持高精度。
🚀 Qaari 0.1 Urdu:乌尔都语OCR模型
Qaari 0.1 Urdu是一款专门为乌尔都语文本的光学字符识别(OCR)优化的模型。它基于Qwen/Qwen2-VL-2B进行微调,在乌尔都语OCR能力上有显著提升,大幅超越了基础模型和传统OCR解决方案(如Tesseract)。
🚀 快速开始
你可以使用transformers
和qwen_vl_utils
库来加载这个模型:
!pip install transformers qwen_vl_utils accelerate>=0.26.0 PEFT -U
!pip install -U bitsandbytes
from PIL import Image
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
import torch
import os
from qwen_vl_utils import process_vision_info
model_name = "oddadmix/Qaari-0.1-Urdu-OCR-VL-2B-Instruct"
model = Qwen2VLForConditionalGeneration.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_name)
max_tokens = 2000
prompt = "Below is the image of one page of a document, as well as some raw textual content that was previously extracted for it. Just return the plain text representation of this document as if you were reading it naturally. Do not hallucinate."
image.save("image.png")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": f"file://{src}"},
{"type": "text", "text": prompt},
],
}
]
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
generated_ids = model.generate(**inputs, max_new_tokens=max_tokens)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)[0]
os.remove(src)
print(output_text)
✨ 主要特性
- 专为乌尔都语OCR设计:针对乌尔都语脚本识别进行了优化,具有高精度。
- 卓越性能:与基础模型相比,单词错误率(WER)降低了97.35%。
- 高精度:WER为0.048,字符错误率(CER)为0.029,BLEU分数为0.916。
- 输出长度均衡:长度比率接近完美,为0.978(理想值为1.0)。
📦 安装指南
!pip install transformers qwen_vl_utils accelerate>=0.26.0 PEFT -U
!pip install -U bitsandbytes
💻 使用示例
基础用法
from PIL import Image
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
import torch
import os
from qwen_vl_utils import process_vision_info
model_name = "oddadmix/Qaari-0.1-Urdu-OCR-VL-2B-Instruct"
model = Qwen2VLForConditionalGeneration.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_name)
max_tokens = 2000
prompt = "Below is the image of one page of a document, as well as some raw textual content that was previously extracted for it. Just return the plain text representation of this document as if you were reading it naturally. Do not hallucinate."
image.save("image.png")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": f"file://{src}"},
{"type": "text", "text": prompt},
],
}
]
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
generated_ids = model.generate(**inputs, max_new_tokens=max_tokens)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)[0]
os.remove(src)
print(output_text)
📚 详细文档
性能指标
模型 | 单词错误率(WER)↓ | 字符错误率(CER)↓ | BLEU分数↑ | 长度比率 |
---|---|---|---|---|
Qaari 0.1 Urdu | 0.048 | 0.029 | 0.916 | 0.978 |
Tesseract | 0.352 | 0.227 | 0.518 | 0.770 |
Qwen Base | 1.823 | 1.739 | 0.009 | 1.288 |
改进百分比
对比对象 | WER改进 | CER改进 | BLEU改进 |
---|---|---|---|
与Qwen Base对比 | 97.35% | 98.32% | 91.55% |
与Tesseract对比 | 86.25% | 87.11% | 82.60% |
支持的字体
- AlQalam Taj Nastaleeq Regular
- Alvi Nastaleeq Regular
- Gandhara Suls Regular
- Jameel Noori Nastaleeq Regular
- NotoNastaliqUrdu-Regular
支持的字体大小
- 14pt
- 16pt
- 18pt
- 20pt
- 24pt
- 32pt
- 40pt
局限性
- 使用微调数据集中未包含的字体时,性能可能会下降。
- 超出支持范围的字体大小可能会导致渲染效果不佳。
- 该模型可能无法有效处理非纳斯塔利克字体中的复杂连字。
- 在纯数字显示设备上的性能尚未完全优化。
- 低分辨率打印环境可能会出现质量下降的情况。
- 自定义字体修改或非标准的纳斯塔利克变体可能无法按预期渲染。
训练详情
训练数据集
- 数据集类型:带有配对转录的乌尔都语文本图像
- 大小:10,000
- 来源:合成数据集
训练配置
- 基础模型:Qwen/Qwen2-VL-2B
- 硬件:A6000 GPU
- 训练时间:24小时
🔧 技术细节
该模型基于Qwen2-VL-2B进行微调,使用了包含乌尔都语文本图像和配对转录的数据集。训练过程着重于优化乌尔都语字符的准确识别和自然语言理解。
📄 许可证
该模型遵循基础模型Qwen2-VL-2B的许可条款。
引用
如果你在研究中使用了这个模型,请引用:
@misc{qaari-0.1-urdu,
author = {Ahmed Wasfy},
title = {Qaari 0.1 Urdu: OCR Model for Urdu Language},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/oddadmix/Qaari-0.1-Urdu-OCR-VL-2B-Instruct}}
}
Table Transformer Structure Recognition
MIT
基于PubTables1M数据集训练的表格变换器模型,用于从非结构化文档中提取表格结构
文字识别
Transformers

T
microsoft
1.2M
186
Trocr Small Handwritten
TrOCR是一个基于Transformer的光学字符识别模型,专门用于手写文本图像的识别。
文字识别
Transformers

T
microsoft
517.96k
45
Table Transformer Structure Recognition V1.1 All
MIT
基于Transformer的表格结构识别模型,用于检测文档中的表格结构
文字识别
Transformers

T
microsoft
395.03k
70
Trocr Large Printed
基于Transformer的光学字符识别模型,适用于单行印刷体文本识别
文字识别
Transformers

T
microsoft
295.59k
162
Texify
Texify 是一个 OCR 工具,专门用于将公式图片和文本转换为 LaTeX 格式。
文字识别
Transformers

T
vikp
206.53k
15
Trocr Base Printed
TrOCR是基于Transformer的光学字符识别模型,专为单行文本图像识别设计,采用编码器-解码器架构
文字识别
Transformers

T
microsoft
184.84k
169
Manga Ocr Base
Apache-2.0
专为日语文本设计的光学字符识别工具,主要针对日本漫画场景优化。
文字识别
Transformers 日语

M
kha-white
130.36k
145
Tiny Random Internvl2
专注于将图像中的文本信息提取并转化为可编辑的文本内容
文字识别
Safetensors
T
katuni4ka
73.27k
0
Trocr Large Handwritten
TrOCR是基于Transformer的光学字符识别模型,专为手写文本识别设计,在IAM数据集上进行了微调。
文字识别
Transformers

T
microsoft
59.17k
115
Trocr Small Printed
TrOCR是一个基于Transformer的光学字符识别模型,适用于单行文本图像的OCR任务。
文字识别
Transformers

T
microsoft
20.88k
40
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98