Spaces:
Runtime error
Runtime error
Commit
•
8a2ee58
1
Parent(s):
69d5d3c
Update app.py
Browse files
app.py
CHANGED
@@ -43,10 +43,6 @@ def draw_mask(img, bounds):
|
|
43 |
img = cv.inpaint(img, mask, 3, cv.INPAINT_TELEA)
|
44 |
|
45 |
return(img)
|
46 |
-
|
47 |
-
def masking(img, mask):
|
48 |
-
#img = cv.inpaint(img, mask, 3, cv.INPAINT_TELEA)
|
49 |
-
return img
|
50 |
|
51 |
def inference(img, lang):
|
52 |
if lang == "english":
|
@@ -60,38 +56,18 @@ def inference(img, lang):
|
|
60 |
reader = easyocr.Reader(lang)
|
61 |
bounds = reader.readtext(img.name)
|
62 |
im = PIL.Image.open(img.name)
|
63 |
-
|
64 |
img_array = np.array(im)
|
65 |
-
|
66 |
-
#mask = PIL.Image.open(img.name)
|
67 |
-
#mask = Image.new("L", im.size, 0)
|
68 |
im = draw_mask(img_array, bounds)
|
69 |
im = Image.fromarray(im, 'RGB')
|
70 |
-
#
|
71 |
-
#masking(img_array, mask)
|
72 |
-
#img_inpainted = cv.inpaint(img_array, mask, 7, cv.INPAINT_NS)
|
73 |
-
#remove_text(im, mask, bounds)
|
74 |
lang = ""
|
75 |
-
#cv.imshow('dst', dst)
|
76 |
im.save('result.jpg')
|
77 |
-
#mask.save('mask.png')
|
78 |
-
|
79 |
-
#img = cv.imread('result.jpg')
|
80 |
-
#mask = cv.imread('mask2.png',0)
|
81 |
-
#dst = cv.inpaint(img,mask,3,cv.INPAINT_TELEA)
|
82 |
|
83 |
-
#final.save('final.png')
|
84 |
-
#img_inpainted.save('inpaint.jpg')
|
85 |
-
#dst = cv2.inpaint(np.float32(img),np.float32(mask),3,cv2.INPAINT_TELEA)
|
86 |
-
#img_inpainted = cv2.inpaint(im, mask, 7, cv2.INPAINT_TELEA)
|
87 |
-
#cv2.imwrite('dst.png', dst)
|
88 |
-
#cv.imwrite('result.jpg',dst)
|
89 |
return ['result.jpg', pd.DataFrame(bounds). iloc[: , 1:2]]
|
90 |
|
91 |
title = 'EasyOCR'
|
92 |
description = 'Gradio demo for EasyOCR. EasyOCR demo supports 80+ languages.To use it, simply upload your image and choose a language from the dropdown menu, or click one of the examples to load them. Read more at the links below.'
|
93 |
article = "<p style='text-align: center'><a href='https://www.jaided.ai/easyocr/'>Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.</a> | <a href='https://github.com/JaidedAI/EasyOCR'>Github Repo</a></p>"
|
94 |
-
css = ".output_image, .input_image {height:
|
95 |
examples = [['korean.jpg',"korean"]]
|
96 |
choices = [
|
97 |
"chinese",
|
@@ -101,7 +77,7 @@ choices = [
|
|
101 |
]
|
102 |
gr.Interface(
|
103 |
inference,
|
104 |
-
[gr.inputs.Image(type='
|
105 |
[gr.outputs.Image(type='file', label='Output'),
|
106 |
#gr.outputs.Image(type='file', label='Output'),
|
107 |
#gr.outputs.Image(type='file', label='Output'),
|
|
|
43 |
img = cv.inpaint(img, mask, 3, cv.INPAINT_TELEA)
|
44 |
|
45 |
return(img)
|
|
|
|
|
|
|
|
|
46 |
|
47 |
def inference(img, lang):
|
48 |
if lang == "english":
|
|
|
56 |
reader = easyocr.Reader(lang)
|
57 |
bounds = reader.readtext(img.name)
|
58 |
im = PIL.Image.open(img.name)
|
|
|
59 |
img_array = np.array(im)
|
|
|
|
|
|
|
60 |
im = draw_mask(img_array, bounds)
|
61 |
im = Image.fromarray(im, 'RGB')
|
|
|
|
|
|
|
|
|
62 |
lang = ""
|
|
|
63 |
im.save('result.jpg')
|
|
|
|
|
|
|
|
|
|
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
return ['result.jpg', pd.DataFrame(bounds). iloc[: , 1:2]]
|
66 |
|
67 |
title = 'EasyOCR'
|
68 |
description = 'Gradio demo for EasyOCR. EasyOCR demo supports 80+ languages.To use it, simply upload your image and choose a language from the dropdown menu, or click one of the examples to load them. Read more at the links below.'
|
69 |
article = "<p style='text-align: center'><a href='https://www.jaided.ai/easyocr/'>Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.</a> | <a href='https://github.com/JaidedAI/EasyOCR'>Github Repo</a></p>"
|
70 |
+
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
71 |
examples = [['korean.jpg',"korean"]]
|
72 |
choices = [
|
73 |
"chinese",
|
|
|
77 |
]
|
78 |
gr.Interface(
|
79 |
inference,
|
80 |
+
[gr.inputs.Image(type='pil', label='Input'),gr.inputs.Dropdown(choices, type="value", default="korean", label='language')],
|
81 |
[gr.outputs.Image(type='file', label='Output'),
|
82 |
#gr.outputs.Image(type='file', label='Output'),
|
83 |
#gr.outputs.Image(type='file', label='Output'),
|