Spaces:
Runtime error
Runtime error
test
Browse files
app.py
CHANGED
@@ -12,12 +12,11 @@ import gradio as gr
|
|
12 |
import torch
|
13 |
|
14 |
|
15 |
-
from mmocr.apis import MMOCRInferencer
|
16 |
-
ocr = MMOCRInferencer(det='TextSnake', rec='ABINet_Vision')
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
path_input = "./example1.jpg"
|
22 |
urllib.request.urlretrieve(url, filename=path_input)
|
23 |
|
@@ -27,23 +26,25 @@ urllib.request.urlretrieve(url, filename=path_input)
|
|
27 |
|
28 |
|
29 |
path_img_output_folder = "./demo-out"
|
30 |
-
if not os.path.exists(path_img_output_folder):
|
31 |
-
|
32 |
|
33 |
path_img_input_folder = "./demo-input"
|
34 |
-
if not os.path.exists(path_img_input_folder):
|
35 |
-
|
|
|
36 |
|
37 |
def do_process(img):
|
38 |
-
img_name =
|
39 |
path_input = os.path.join(path_img_input_folder, img_name)
|
40 |
-
path_output = os.path.join(path_img_output_folder,
|
41 |
img.save(path_input)
|
42 |
img.save(path_output)
|
43 |
# result = ocr(path_input, out_dir=path_img_output_folder, save_vis=True)
|
44 |
img_res = Image(filename=path_output)
|
45 |
return img_res
|
46 |
|
|
|
47 |
input_im = gr.inputs.Image(
|
48 |
shape=None, image_mode="RGB", invert_colors=False, source="upload", type="pil"
|
49 |
)
|
@@ -53,7 +54,9 @@ output_img = gr.outputs.Image(label="Output of Integrated Gradients", type="pil"
|
|
53 |
# output_label = gr.outputs.Label(label="Classification results", num_top_classes=3)
|
54 |
|
55 |
title = "Reading draught marks"
|
56 |
-
description =
|
|
|
|
|
57 |
examples = [["./example1.jpg"], ["./example2.jpg"]]
|
58 |
article = "<p style='text-align: center'><a href='https://github.com/mawady' target='_blank'>By Dr. Mohamed Elawady</a></p>"
|
59 |
iface = gr.Interface(
|
|
|
12 |
import torch
|
13 |
|
14 |
|
15 |
+
# from mmocr.apis import MMOCRInferencer
|
|
|
16 |
|
17 |
+
# ocr = MMOCRInferencer(det="TextSnake", rec="ABINet_Vision")
|
18 |
+
|
19 |
+
url = "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/Draft_Marks_on_the_Bow_of_Kruzenshtern_Port_of_Tallinn_16_July_2011.jpg/1600px-Draft_Marks_on_the_Bow_of_Kruzenshtern_Port_of_Tallinn_16_July_2011.jpg"
|
20 |
path_input = "./example1.jpg"
|
21 |
urllib.request.urlretrieve(url, filename=path_input)
|
22 |
|
|
|
26 |
|
27 |
|
28 |
path_img_output_folder = "./demo-out"
|
29 |
+
# if not os.path.exists(path_img_output_folder):
|
30 |
+
# os.makedirs(path_img_output_folder)
|
31 |
|
32 |
path_img_input_folder = "./demo-input"
|
33 |
+
# if not os.path.exists(path_img_input_folder):
|
34 |
+
# os.makedirs(path_img_input_folder)
|
35 |
+
|
36 |
|
37 |
def do_process(img):
|
38 |
+
img_name = "tmp.jpg"
|
39 |
path_input = os.path.join(path_img_input_folder, img_name)
|
40 |
+
path_output = os.path.join(path_img_output_folder, "vis", img_name)
|
41 |
img.save(path_input)
|
42 |
img.save(path_output)
|
43 |
# result = ocr(path_input, out_dir=path_img_output_folder, save_vis=True)
|
44 |
img_res = Image(filename=path_output)
|
45 |
return img_res
|
46 |
|
47 |
+
|
48 |
input_im = gr.inputs.Image(
|
49 |
shape=None, image_mode="RGB", invert_colors=False, source="upload", type="pil"
|
50 |
)
|
|
|
54 |
# output_label = gr.outputs.Label(label="Classification results", num_top_classes=3)
|
55 |
|
56 |
title = "Reading draught marks"
|
57 |
+
description = (
|
58 |
+
"Playground: Reading draught marks using pre-trained models. Tools: MMOCR, Gradio."
|
59 |
+
)
|
60 |
examples = [["./example1.jpg"], ["./example2.jpg"]]
|
61 |
article = "<p style='text-align: center'><a href='https://github.com/mawady' target='_blank'>By Dr. Mohamed Elawady</a></p>"
|
62 |
iface = gr.Interface(
|