Update README.md
Browse files
README.md
CHANGED
|
@@ -7,4 +7,56 @@ pipeline_tag: image-to-text
|
|
| 7 |
tags:
|
| 8 |
- ocr
|
| 9 |
- captcha
|
| 10 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
tags:
|
| 8 |
- ocr
|
| 9 |
- captcha
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
## 介绍(Introduction)
|
| 15 |
+
**验证码识别模型(ocr-captcha)**专门识别常见验证码的模型,训练模型有2个:
|
| 16 |
+
1.**small**:训练数据大小为700MB,约8.4万张验证码图片,训练轮次27轮,最终的精度将近100%,推荐下载这个模型;
|
| 17 |
+
2.**big**:训练数据大小为11G,约135万个验证码图片,训练轮次1轮,最终的精度将近93.95%;
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
## 快速使用(Quickstart)
|
| 21 |
+
|
| 22 |
+
```python
|
| 23 |
+
from modelscope.pipelines import pipeline
|
| 24 |
+
from modelscope.utils.constant import Tasks
|
| 25 |
+
import gradio as gr
|
| 26 |
+
import os
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class xiaolv_ocr_model():
|
| 30 |
+
|
| 31 |
+
def __init__(self):
|
| 32 |
+
model_small = r"./output_small"
|
| 33 |
+
model_big = r"./output_big"
|
| 34 |
+
self.ocr_recognition_small = pipeline(Tasks.ocr_recognition, model=model_small)
|
| 35 |
+
self.ocr_recognition1_big = pipeline(Tasks.ocr_recognition, model=model_big)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def run(self,pict_path,moshi = "small", context=[]):
|
| 39 |
+
pict_path = pict_path.name
|
| 40 |
+
context = [pict_path]
|
| 41 |
+
|
| 42 |
+
if moshi == "small":
|
| 43 |
+
result = self.ocr_recognition_small(pict_path)
|
| 44 |
+
else:
|
| 45 |
+
result = self.ocr_recognition1_big(pict_path)
|
| 46 |
+
|
| 47 |
+
context += [str(result['text'][0])]
|
| 48 |
+
responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
|
| 49 |
+
print(f"识别的结果为:{result}")
|
| 50 |
+
os.remove(pict_path)
|
| 51 |
+
return responses,context
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
if __name__ == "__main__":
|
| 57 |
+
pict_path = r"C:\Users\admin\Desktop\图片识别测试\企业微信截图_16895911221007.png"
|
| 58 |
+
ocr_model = xiaolv_ocr_model()
|
| 59 |
+
# ocr_model.run(pict_path)
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
|