🚀 模型卡片:qwen-for-jawi-v1
本模型是专门用于识别以爪夷文(为马来语改编的阿拉伯文字)书写的历史马来语文本的光学字符识别(OCR)模型。它基于Qwen/Qwen2-VL-7B-Instruct进行微调,在处理特定的历史文本方面具有出色的性能。
🚀 快速开始
本模型是Qwen/Qwen2-VL-7B-Instruct的微调版本,专门用于对以爪夷文(为马来语改编的阿拉伯文字)书写的历史马来语文本进行光学字符识别(OCR)。
✨ 主要特性
- 针对性强:专为爪夷文书写的历史马来语文本OCR设计。
- 文化传承:有助于马来文化遗产的数字保存。
- 计算分析:支持对历史马来语文本进行计算分析。
📦 安装指南
暂未提及安装相关内容,可参考transformers
库的安装方式。
💻 使用示例
基础用法
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
import torch
from qwen_vl_utils import process_vision_info
from PIL import Image
model_name = 'mevsg/qwen-for-jawi-v1'
model = Qwen2VLForConditionalGeneration.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map='auto'
)
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct")
image_path = 'path/to/image'
image = Image.open(image_path).convert('RGB')
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": image,
},
{"type": "text", "text": "Convert this image to text"},
],
}
]
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=128)
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
)
print(output_text)
📚 详细文档
模型架构
预期用途
主要预期用途
- 对以爪夷文书写的历史马来文手稿进行OCR识别。
- 对马来文化遗产进行数字保存。
- 对历史马来语文本进行计算分析。
非预期用途
- 通用阿拉伯文本识别。
- 现代马来语文本处理。
- 实时OCR应用。
训练数据
数据集描述
本模型使用特定数据集进行训练和评估,但文档未详细说明数据集内容。
训练过程
性能和局限性
性能指标
- 字符错误率(CER):8.66
- 单词错误率(WER):25.50
与其他模型的比较
我们将该模型与https://github.com/VikParuchuri/surya进行了比较,后者在阿拉伯文识别方面报告了较高的准确率,但在我们的爪夷文数据上表现较差:
- 字符错误率(CER):70.89%
- 单词错误率(WER):91.73%
📄 许可证
文档未提及许可证信息。
📚 引用
@misc{qwen-for-jawi-v1,
title = {Qwen for Jawi v1: a model for Jawi OCR},
author = {[Miguel Escobar Varela]},
year = {2024},
publisher = {HuggingFace},
url = {[https://huggingface.co/mevsg/qwen-for-Jawi-v1]},
note = {Model created at National University of Singapore }
}
🙏 致谢
特别感谢William Mattingly,其微调脚本是我们微调方法的基础:https://github.com/wjbmattingly/qwen2-vl-finetune-huggingface