---
title: ocr_small
canonical_url: "https://www.modelscope.cn/models/xiaolv/ocr_small"
md_url: "https://www.modelscope.cn/models/xiaolv/ocr_small.md"
repository: xiaolv/ocr_small
chinese_name: "验证码识别模型（小）"
last_updated: 2025-11-17
license: "Apache License 2.0"
pipeline_tag: ocr-recognition
tasks:
  - ocr-recognition
library_name:
  - pytorch
frameworks:
  - pytorch
language:
  - en
  - zh
domain:
  - cv
downloads: 22118
stars: 13
tags:
  - OCR
  - Alibaba
  - "文字识别"
  - "读光"
---

# ocr_small

> ocr_small - xiaolv 在 ModelScope 开源的模型。验证码识别模型 ocr-captcha专门识别常见验证码的模型，训练模型有2个： 1.ocrsmall:训练数据大小为700MB，约8.4万张验证码图片，训练轮次27轮，最终的精度将近100%，推荐下载这个模型； 2.ocrbig:训练数据大小为11G，约135万个验证码图片，训练轮次1轮，最终的精度将近93.95%(由于资源问题，无法训练太久)；

xiaolv/ocr_small 是 ModelScope 魔搭社区上的ocr-recognition模型，采用 Apache License 2.0 许可。

- **Repository**: xiaolv/ocr_small
- **License**: Apache License 2.0
- **Tasks**: ocr-recognition
- **Tags**: OCR, Alibaba, 文字识别, 读光
- **Downloads**: 22118
- **Stars**: 13
- **Last updated**: 2025-11-17

Source: https://www.modelscope.cn/models/xiaolv/ocr_small

---

## 介绍（Introduction）

**验证码识别模型  ocr-captcha**专门识别常见验证码的模型，训练模型有2个：
  
  1.**[ocr_small](https://modelscope.cn/models/xiaolv/ocr_small/summary)**:训练数据大小为700MB，约8.4万张验证码图片，训练轮次27轮，最终的精度将近100%，推荐下载这个模型；
  
  2.**[ocr_big](https://modelscope.cn/models/xiaolv/ocr_big/summary)**:训练数据大小为11G，约135万个验证码图片，训练轮次1轮，最终的精度将近93.95%(由于资源问题，无法训练太久)；

## 数据分布

  1.**类型**：1. 纯数字型；2. 数字+字母型；3.纯字母型（大小写）
  
  2.**长度**：4位、5位、6位

## 数据微调

  1.**基座模型**：基座模型参考达摩院发布的[读光-文字识别-行识别模型-中英-通用领域](https://www.modelscope.cn/models/damo/cv_convnextTiny_ocr-recognition-general_damo/summary)
  
  2.**具体微调参考以上链接**

## 模型体验链接

modelscope：[验证码识别模型（ocr-captcha）](https://modelscope.cn/studios/xiaolv/ocr/summary)


## 模型能力
通过后续的测试可以发现：
1. 模型对于数字的0无法识别，原因很简单，数据集训练的时候，对应数字的识别，是生成了1-9的，排除了0，所以。这对于所有的数字0，基本会识别成字母的O。


## 快速使用（Quickstart）

代码提供web网页版：```myself_train_model.py```

详细数据参考huggingface代码：[xiaolv/ocr-captcha](https://huggingface.co/xiaolv/ocr-captcha)

```python
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
import gradio as gr
import os


class xiaolv_ocr_model():

    def __init__(self):
        model_small = r"./output_small"
        model_big = r"./output_big"
        self.ocr_recognition_small = pipeline(Tasks.ocr_recognition, model=model_small)
        self.ocr_recognition1_big = pipeline(Tasks.ocr_recognition, model=model_big)


    def run(self,pict_path,moshi = "small", context=[]):
        pict_path = pict_path.name
        context = [pict_path]

        if moshi == "small":
            result = self.ocr_recognition_small(pict_path)
        else:
            result = self.ocr_recognition1_big(pict_path)

        context += [str(result['text'][0])]
        responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
        print(f"识别的结果为：{result}")
        os.remove(pict_path)
        return responses,context




if __name__ == "__main__":
    pict_path = r"C:\Users\admin\Desktop\图片识别测试\企业微信截图_16895911221007.png"
    ocr_model = xiaolv_ocr_model()
    # ocr_model.run(pict_path)
```

## 联系我们（Contact Us）

如果你想给我们的研发团队和产品团队留言，请通过邮件（2240560729@qq.com）联系我们。
