import os | |
os.system('pip3 install muggle-ocr -i https://mirrors.aliyun.com/pypi/simple/') | |
import gradio as gr | |
import muggle_ocr | |
import cv2 | |
captcha_sdk = muggle_ocr.SDK(model_type=muggle_ocr.ModelType.Captcha) | |
def generate(img): | |
success,encoded_image = cv2.imencode(".jpg",img) | |
b_img = encoded_image.tostring() | |
return captcha_sdk.predict(image_bytes=b_img) | |
if __name__ == "__main__": | |
gr.Interface( | |
fn=generate, | |
inputs="image", | |
outputs="text" | |
).launch() |