Spaces:
Runtime error
Runtime error
DerrylNessie
commited on
Commit
•
3aee4cc
1
Parent(s):
46efdd9
Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ def draw_mask(img, bounds, color='yellow', width=2):
|
|
20 |
for bound in bounds:
|
21 |
p0, p1, p2, p3 = bound[0]
|
22 |
|
|
|
23 |
x0,y0 = p0
|
24 |
x1,y1 = p1
|
25 |
x2,y2 = p2
|
@@ -32,7 +33,9 @@ def draw_mask(img, bounds, color='yellow', width=2):
|
|
32 |
mask = np.zeros(img.shape[:2], dtype="uint8")
|
33 |
cv2.line(mask, (x_mid0, y_mid0), (x_mid1, y_mi1), 255, thickness)
|
34 |
img = cv2.inpaint(img, mask, 7, cv2.INPAINT_NS)
|
35 |
-
|
|
|
|
|
36 |
|
37 |
#masking
|
38 |
|
@@ -54,6 +57,7 @@ def inference(img, lang):
|
|
54 |
reader = easyocr.Reader(lang)
|
55 |
bounds = reader.readtext(img.name)
|
56 |
im = PIL.Image.open(img.name)
|
|
|
57 |
#w, h = im.size
|
58 |
|
59 |
draw_mask(mask, bounds)
|
|
|
20 |
for bound in bounds:
|
21 |
p0, p1, p2, p3 = bound[0]
|
22 |
|
23 |
+
"""
|
24 |
x0,y0 = p0
|
25 |
x1,y1 = p1
|
26 |
x2,y2 = p2
|
|
|
33 |
mask = np.zeros(img.shape[:2], dtype="uint8")
|
34 |
cv2.line(mask, (x_mid0, y_mid0), (x_mid1, y_mi1), 255, thickness)
|
35 |
img = cv2.inpaint(img, mask, 7, cv2.INPAINT_NS)
|
36 |
+
"""
|
37 |
+
|
38 |
+
draw.polygon((*p0, *p1, *p2, *p3), fill=255)
|
39 |
|
40 |
#masking
|
41 |
|
|
|
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)
|