Upload infer_gradio.py
Browse files- infer_gradio.py +25 -0
infer_gradio.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from manga_ocr import MangaOcr
|
2 |
+
from PIL import Image
|
3 |
+
import time, random, io, base64
|
4 |
+
import gradio as gr
|
5 |
+
import spaces
|
6 |
+
|
7 |
+
mocr = MangaOcr()
|
8 |
+
|
9 |
+
@spaces.GPU
|
10 |
+
def ocr_text(image):
|
11 |
+
start = time.time()
|
12 |
+
text = mocr(image)
|
13 |
+
print(time.time() - start)
|
14 |
+
return text
|
15 |
+
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=ocr_text,
|
18 |
+
inputs=gr.Image(type='pil'),
|
19 |
+
outputs="text",
|
20 |
+
title="Manga OCR",
|
21 |
+
description="Extrait le texte d'une image de manga.",
|
22 |
+
)
|
23 |
+
|
24 |
+
if __name__ == '__main__':
|
25 |
+
iface.launch(server_name="0.0.0.0", server_port=9999)
|