Spaces:
Runtime error
Runtime error
Commit
•
3664fda
1
Parent(s):
ba29956
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,10 @@ def draw_boxes(image, bounds, color='yellow', width=2):
|
|
14 |
p0, p1, p2, p3 = bound[0]
|
15 |
draw.line([*p0, *p1, *p2, *p3, *p0], fill=color, width=width)
|
16 |
return image
|
17 |
-
|
|
|
|
|
|
|
18 |
def inference(img, lang):
|
19 |
if lang == "english":
|
20 |
lang = ['en']
|
@@ -28,6 +31,7 @@ def inference(img, lang):
|
|
28 |
bounds = reader.readtext(img.name)
|
29 |
im = PIL.Image.open(img.name)
|
30 |
draw_boxes(im, bounds)
|
|
|
31 |
lang = ""
|
32 |
im.save('result.jpg')
|
33 |
return ['result.jpg', pd.DataFrame(bounds).iloc[: , 1:]]
|
|
|
14 |
p0, p1, p2, p3 = bound[0]
|
15 |
draw.line([*p0, *p1, *p2, *p3, *p0], fill=color, width=width)
|
16 |
return image
|
17 |
+
def remove_text(image, bounds):
|
18 |
+
for bound in bounds:
|
19 |
+
p0, p1, p2, p3 = bound[0]
|
20 |
+
|
21 |
def inference(img, lang):
|
22 |
if lang == "english":
|
23 |
lang = ['en']
|
|
|
31 |
bounds = reader.readtext(img.name)
|
32 |
im = PIL.Image.open(img.name)
|
33 |
draw_boxes(im, bounds)
|
34 |
+
remove_text(im, bounds)
|
35 |
lang = ""
|
36 |
im.save('result.jpg')
|
37 |
return ['result.jpg', pd.DataFrame(bounds).iloc[: , 1:]]
|