Spaces:
Runtime error
Runtime error
Commit
•
dc72617
1
Parent(s):
0fe7020
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ import math
|
|
10 |
import numpy as np
|
11 |
|
12 |
torch.hub.download_url_to_file('https://i.pinimg.com/originals/45/d0/30/45d03054e15f4be731781eecba7458a4.jpg', 'korean.png')
|
|
|
13 |
def midpoint(x1, y1, x2, y2):
|
14 |
x_mid = int((x1 + x2)/2)
|
15 |
y_mid = int((y1 + y2)/2)
|
@@ -57,15 +58,15 @@ def inference(img, lang):
|
|
57 |
reader = easyocr.Reader(lang)
|
58 |
bounds = reader.readtext(img.name)
|
59 |
im = PIL.Image.open(img.name)
|
60 |
-
mask = Image.new("L", im.size, 0)
|
61 |
#w, h = im.size
|
62 |
|
63 |
draw_mask(mask, bounds)
|
64 |
#remove_text(im, mask, bounds)
|
65 |
lang = ""
|
66 |
-
im.save('result.
|
67 |
-
mask.save('mask.
|
68 |
-
return ['result.
|
69 |
|
70 |
title = 'EasyOCR'
|
71 |
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.'
|
|
|
10 |
import numpy as np
|
11 |
|
12 |
torch.hub.download_url_to_file('https://i.pinimg.com/originals/45/d0/30/45d03054e15f4be731781eecba7458a4.jpg', 'korean.png')
|
13 |
+
|
14 |
def midpoint(x1, y1, x2, y2):
|
15 |
x_mid = int((x1 + x2)/2)
|
16 |
y_mid = int((y1 + y2)/2)
|
|
|
58 |
reader = easyocr.Reader(lang)
|
59 |
bounds = reader.readtext(img.name)
|
60 |
im = PIL.Image.open(img.name)
|
61 |
+
mask = PIL.Image.new("L", im.size, 0)
|
62 |
#w, h = im.size
|
63 |
|
64 |
draw_mask(mask, bounds)
|
65 |
#remove_text(im, mask, bounds)
|
66 |
lang = ""
|
67 |
+
im.save('result.jpg')
|
68 |
+
mask.save('mask.jpg')
|
69 |
+
return ['result.jpg','mask.jpg', pd.DataFrame(bounds). iloc[: , 1:2]]
|
70 |
|
71 |
title = 'EasyOCR'
|
72 |
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.'
|