DerrylNessie commited on
Commit
2f1cdb1
1 Parent(s): b2e6310

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -30
app.py CHANGED
@@ -21,35 +21,10 @@ def draw_mask(img, bounds):
21
 
22
  for bound in bounds:
23
  p0, p1, p2, p3 = bound[0]
24
- draw.line([*p0, *p1, *p2, *p3, *p0], fill=color, width=width)
25
 
26
- return imag
27
- """
28
- for bound in bounds:
29
- p0, p1, p2, p3 = bound[0]
30
-
31
- x0,y0 = p0
32
- x1,y1 = p1
33
- x2,y2 = p2
34
- x3,y3 = p3
35
-
36
- x_mid0, y_mid0 = midpoint(x1, y1, x2, y2)
37
- x_mid1, y_mi1 = midpoint(x0, y0, x3, y3)
38
- thickness = int(math.sqrt( (x2 - x1)**2 + (y2 - y1)**2 ))
39
-
40
- mask = np.zeros(img.shape[:2], dtype="uint8")
41
- cv2.line(mask, (x_mid0, y_mid0), (x_mid1, y_mi1), 255, thickness)
42
- img = cv2.inpaint(img, mask, 7, cv2.INPAINT_NS)
43
-
44
- draw.polygon((*p0, *p1, *p2, *p3), fill=255)
45
-
46
- #masking
47
-
48
- return img
49
- def remove_text(img,imgwmask):
50
- masked = cv2.bitwise_and(img, img, mask=imgwmask)
51
  return img
52
- """
53
  def inference(img, lang):
54
  if lang == "english":
55
  lang = ['en']
@@ -62,10 +37,10 @@ def inference(img, lang):
62
  reader = easyocr.Reader(lang)
63
  bounds = reader.readtext(img.name)
64
  im = PIL.Image.open(img.name)
65
- #mask = PIL.Image.new("L", im1.size, 0)
66
- #w, h = im.size
67
 
68
- #draw_mask(im, bounds)
69
  #remove_text(im, mask, bounds)
70
  lang = ""
71
  im.save('result.jpg')
 
21
 
22
  for bound in bounds:
23
  p0, p1, p2, p3 = bound[0]
24
+ draw.polygon((*p0, *p1, *p2, *p3, *p0), fill=255)
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  return img
27
+
28
  def inference(img, lang):
29
  if lang == "english":
30
  lang = ['en']
 
37
  reader = easyocr.Reader(lang)
38
  bounds = reader.readtext(img.name)
39
  im = PIL.Image.open(img.name)
40
+ mask = PIL.Image.new("L", im1.size, 0)
41
+ w, h = im.size
42
 
43
+ draw_mask(mask, bounds)
44
  #remove_text(im, mask, bounds)
45
  lang = ""
46
  im.save('result.jpg')