muggle_ocr / app.py
chenjg's picture
Update app.py
497cbba
import os
os.system('pip3 install muggle_ocr -i https://pypi.douban.com/simple/')
import gradio as gr
import muggle_ocr
import cv2
captcha_sdk = muggle_ocr.SDK(model_type=muggle_ocr.ModelType.OCR)
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()