---
title: UG_0CR-V1.4
canonical_url: "https://www.modelscope.cn/models/RUHSI520/UG_0CR-V1.4"
md_url: "https://www.modelscope.cn/models/RUHSI520/UG_0CR-V1.4.md"
repository: RUHSI520/UG_0CR-V1.4
chinese_name: "UG_0CR-V1.4   维语文字识别"
last_updated: 2026-11-17
license: apache-2.0
pipeline_tag: ocr-recognition
tasks:
  - ocr-recognition
model_type:
  - vision-encoder-decoder
library_name:
  - pytorch
  - gguf
frameworks:
  - pytorch
language:
  - ug
downloads: 29
stars: 1
tags:
  - ocr
  - text-recognition
  - trocr
  - vision-encoder-decoder
  - ctc
  - gguf
  - uyghur
---

# UG_0CR-V1.4

> UG_0CR-V1.4 - RUHSI520 在 ModelScope 开源的模型。维语文字识别

RUHSI520/UG_0CR-V1.4 是 ModelScope 魔搭社区上的ocr-recognition模型，采用 apache-2.0 许可。

- **Repository**: RUHSI520/UG_0CR-V1.4
- **License**: apache-2.0
- **Tasks**: ocr-recognition
- **Tags**: ocr, text-recognition, trocr, vision-encoder-decoder, ctc, gguf, uyghur
- **Downloads**: 29
- **Stars**: 1
- **Last updated**: 2026-11-17

Source: https://www.modelscope.cn/models/RUHSI520/UG_0CR-V1.4

---

# UG_0CR-V1.4 · 维语文字识别（ViT Encoder-Decoder + CTC）

面向维吾尔语（阿拉伯字母）印刷体的文字识别模型：ViT 视觉编码器（6 层）+ Transformer 解码器（4 层）+ CTC 辅助分支，参数量 **37.7M**，词表 **197**，单行输入高度 48 px、宽度 64–640 px 自适应，内置二维相对位置编码，支持变宽输入。

权重以**单文件 GGUF v3（F16）**发布，配套 Python 推理实现（页切分 + 行级识别 + 置信度 + 正字法后处理）。

## 文件说明

| 文件 | 说明 |
| --- | --- |
| `models/ug_ocr_v1.4_f16.gguf` | 单文件权重（GGUF v3，F16，72 MB），arch 标识 `ugocr` |
| `vocab.json` | 词表（197，含位置形态） |
| `config.json` | 模型结构配置（6+4 层、d=512、8 头、FFN 2048） |
| `samples/` | 2 张示例页 + 真值 + 期望输出 |
| `usage.md` | 调用方式（页级 CLI / 行级 CLI / Python API） |

> GGUF 只是容器格式，`ugocr` 结构不在 llama.cpp 支持的 architecture 列表内，需要本项目的 Python 运行时加载，不能直接用 `llama-cli`。

## 快速使用

```bash
pip install modelscope
modelscope download --model RUHSI520/UG_0CR-V1.4 --local_dir ./UG_OCR-V1.4
```

推理（需 torch / torchvision / pillow / numpy）：

```python
import sys
sys.path.insert(0, "path/to/UG_OCR-V1.4/demos/_runtime")
import torch
from PIL import Image
from models import load_model_from_checkpoint
from data.transforms import build_transform
from page import recognize_page

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model, vocab, config = load_model_from_checkpoint("UG_OCR-V1.4/models/ug_ocr_v1.4_f16.gguf", device)
transform = build_transform(config, train=False)

lines, rectified_page, skew = recognize_page(
    Image.open("demos/samples/input/demo_page_1.png").convert("L"),
    model, vocab, transform, device, batch_size=8, beam_size=1, threshold=0.85)
for r in lines:
    print(r.line_no, f"{r.confidence:.3f}", r.text)
```

命令行（页级）：

```bash
python -m tools.recognize_pages \
  --checkpoint UG_OCR-V1.4/models/ug_ocr_v1.4_f16.gguf \
  --input demos/samples/input --output out/pages.jsonl --report out/report.json
```

## 输出格式

`pages.jsonl` 一行一个文本行：

```json
{"page":"demo_page_1.png","line_no":1,"text":"...","confidence":0.929,
 "segments":1,"needs_review":false,"fallback_used":false,"box":[42,180,880,206]}
```

- `confidence` 为内容 token 概率的几何平均（0–1），`<0.85` 建议人工复核，`<0.70` 基本确定有错
- 文本已做正字法归一：`,`→`،`、`?`→`؟`、`;`→`؛`、`۔`→`،`

## 评测

完整可视化报告见仓库附件 [`reports/OCR模型对比评测报告.html`](reports/OCR模型对比评测报告.html)（V1.2 vs V1.4 同口径横向对比）。

**口径**：CER = 编辑距离 / 真值字符数；整句准确率 = 编辑距离为 0 的行占比；预测与真值均经同一套正字法归一；行级评测 beam=1、宽度上限 640、不启用页级回退；真实域按页级流水线（切分 + 纠偏 + 低置信回退）。

### 1. 结果总表

| 评测集 | 样本 | V1.2 CER | V1.4 CER | V1.2 整句 | V1.4 整句 |
| --- | --- | --- | --- | --- | --- |
| 真实截图（人工真值） | 150 | 1.07% | **1.00%** | **82.67%** | 81.33% |
| 真实截图（内容级，剔除版式符号） | 150 | 0.71% | **0.63%** | — | — |
| 元音密集合成 | 600 | 1.00% | **0.95%** | 83.50% | **84.33%** |
| 常规合成 | 600 | **0.81%** | 0.83% | **84.83%** | 84.67% |
| 混合验证集 | 4,995 | 3.49% | **3.34%** | 83.84% | **84.40%** |
| 真实扫描件（难集） | 154 | 25.65% | **25.36%** | 69.48% | **70.78%** |

### 2. 整页输出对比（264 页 / 994 行）

| 指标 | V1.2 | V1.4 |
| --- | --- | --- |
| 两版输出完全相同的行 | — | 872 / 994（87.7%） |
| 置信度均值 | 0.9011 | 0.9003 |
| 置信度 < 0.85（潜在错误） | 83 | **76** |
| 置信度 < 0.70（默认复核线） | 40 | 42 |
| beam 回退触发 / 采纳 | 44 / 9 | 46 / 9 |
| 平均行长（字符） | 28.4 | 28.3 |
| 页级耗时（RTX 4090） | 0.217 s | 0.218 s |

### 3. 150 行测试集的逐行变化

- **变好 2 行**：漏词补全（编辑距离 8 → 0）、切段粘连修复（2 → 1）
- **变差 5 行**：句末 `.` 与 `!` 叠加；源文中孤立字符被改成逗号；多出 `ى`；`خ` 误识；引号符号 `x` → `c`
- 其余 **143 行完全一致**

### 4. 错误构成（基线 150 行、51 处编辑操作）

| 类型 | 次数 | 例子 |
| --- | --- | --- |
| 元音字母增删 | 12 | 漏写 `ى`、多写 `ۇ` |
| 辅音/其他替换 | 12 | `ى↔ې`、`ب↔پ` |
| 元音替换 | 7 | `ۇ↔ۈ`、`ې↔ى` |
| 标点/版式 | 5 | 破折号 `ـ` 被认成 `،` |
| 整词增删 | 2 | 整词漏识别 |

### 5. 结论

V1.4 在字符级指标上全面小幅领先：真实域 CER −0.07pp、内容级 −0.08pp、混合验证 −0.15pp、真实扫描 −0.29pp，且低置信行减少 7 行；代价是严格整句匹配略降（26 → 28 行有错，但总编辑距离 51 → 48，错误更碎更浅）。两者差距在 0.1pp 量级，应视为**同代微调**而非换代。

### 6. 速度

行级 9.4 ms（RTX 4090，beam=1），页级 0.22 s/页（含切分与纠偏）。

## 已知限制

1. 多栏海报会被整行切分串行，需要先做栏检测
2. 词表不含 `( ) « »`，括号/引号会丢失；连接号 `ـ` 按排版噪声删除
3. 宽度 > 640 px 的行会切段再拼接，切点处可能丢词间空格
4. 行高 < 18 px 时元音附标区分度明显下降
5. 仅覆盖印刷体，手写体与艺术字未支持

## 许可

代码与权重以 Apache-2.0 发布。训练所用字体仅用于图像渲染，字体文件不在本仓库分发。
