Spaces:
Runtime error
Runtime error
DerrylNessie
commited on
Commit
•
44268fe
1
Parent(s):
8e2ecad
Update app.py
Browse files
app.py
CHANGED
@@ -18,21 +18,6 @@ def midpoint(x1, y1, x2, y2):
|
|
18 |
y_mid = int((y1 + y2)/2)
|
19 |
return (x_mid, y_mid)
|
20 |
|
21 |
-
def draw_boxes(image, bounds):
|
22 |
-
draw = ImageDraw.Draw(image)
|
23 |
-
#font = ImageFont.truetype("sans-serif.ttf", 12)
|
24 |
-
for bound in bounds:
|
25 |
-
boxes = [];
|
26 |
-
count = 1;
|
27 |
-
text = str(count)
|
28 |
-
p0, p1, p2, p3 = bound[0]
|
29 |
-
|
30 |
-
draw.polygon((*p0, *p1, *p2, *p3), fill="red")
|
31 |
-
draw.text((*p0),"HELLO")
|
32 |
-
|
33 |
-
bounds.append(boxes)
|
34 |
-
return image
|
35 |
-
|
36 |
def draw_mask(img, bounds):
|
37 |
mask = np.zeros(img.shape[:2], dtype="uint8")
|
38 |
for bound in bounds:
|
@@ -67,14 +52,13 @@ def inference(img, lang):
|
|
67 |
bounds = reader.readtext(img.name)
|
68 |
im = PIL.Image.open(img.name)
|
69 |
img_array = np.array(im)
|
70 |
-
draw_boxes(im, bounds)
|
71 |
img = draw_mask(img_array, bounds)
|
72 |
img = Image.fromarray(im, 'RGB')
|
73 |
lang = ""
|
74 |
im.save('box.jpb')
|
75 |
img.save('result.jpg')
|
76 |
|
77 |
-
return ['box.jpg', 'result.jpg', pd.DataFrame(bounds). iloc[: ,
|
78 |
|
79 |
title = 'EasyOCR'
|
80 |
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.'
|
|
|
18 |
y_mid = int((y1 + y2)/2)
|
19 |
return (x_mid, y_mid)
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
def draw_mask(img, bounds):
|
22 |
mask = np.zeros(img.shape[:2], dtype="uint8")
|
23 |
for bound in bounds:
|
|
|
52 |
bounds = reader.readtext(img.name)
|
53 |
im = PIL.Image.open(img.name)
|
54 |
img_array = np.array(im)
|
|
|
55 |
img = draw_mask(img_array, bounds)
|
56 |
img = Image.fromarray(im, 'RGB')
|
57 |
lang = ""
|
58 |
im.save('box.jpb')
|
59 |
img.save('result.jpg')
|
60 |
|
61 |
+
return ['box.jpg', 'result.jpg', pd.DataFrame(bounds). iloc[: , 1:2]]
|
62 |
|
63 |
title = 'EasyOCR'
|
64 |
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.'
|