python图片验证码识别最新模块muggle_ocr
一.官方文档
https://pypi.org/project/muggle-ocr/
二模块安装
pip install muggle-ocr
# 因模块过新,阿里/清华等第三方源可能尚未更新镜像,因此手动指定使用境外源,为了提高依赖的安装速度,可预先自行安装依赖:tensorflow/numpy/opencv-python/pillow/pyyaml
三.使用代码
# 导入包
import muggle_ocr
# 初始化;model_type 包含了 ModelType.OCR/ModelType.Captcha 两种,OCR能识别中文
sdk = muggle_ocr.SDK(model_type=muggle_ocr.ModelType.OCR)
with open(r"test1.png", "rb") as f:
b = f.read()
text = sdk.predict(image_bytes=b)
print(text)
# ModelType.Captcha 可识别4-6位验证码
sdk = muggle_ocr.SDK(model_type=muggle_ocr.ModelType.Captcha)
with open(r"test1.png", "rb") as f:
b = f.read()
text = sdk.predict(image_bytes=b)
print(text)