Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
os.system('pip3 install muggle_ocr -i https://pypi.douban.com/simple/')
|
3 |
+
import gradio as gr
|
4 |
+
import muggle_ocr
|
5 |
+
import cv2
|
6 |
+
|
7 |
+
captcha_sdk = muggle_ocr.SDK(model_type=muggle_ocr.ModelType.OCR)
|
8 |
+
|
9 |
+
def generate(img):
|
10 |
+
success,encoded_image = cv2.imencode(".jpg",img)
|
11 |
+
b_img = encoded_image.tostring()
|
12 |
+
return captcha_sdk.predict(image_bytes=b_img)
|
13 |
+
|
14 |
+
if __name__ == "__main__":
|
15 |
+
|
16 |
+
gr.Interface(
|
17 |
+
fn=generate,
|
18 |
+
inputs="image",
|
19 |
+
outputs="text"
|
20 |
+
).launch()
|