napatswift commited on
Commit
7831c58
1 Parent(s): dc45c07

Remove text

Browse files
Files changed (1) hide show
  1. main.py +4 -4
main.py CHANGED
@@ -17,17 +17,17 @@ def get_rec(points):
17
 
18
  def predict(image_input, score_threshold):
19
  draw_img = image_input.copy()
20
- print(image_input.shape)
21
- output = ocr.readtext(image_input)
 
 
22
  polygons = output['det_polygons']
23
  scores = output['det_scores']
24
  for polygon, score in zip(polygons, scores):
25
  if score < score_threshold:
26
  continue
27
-
28
  p0, p1 = get_rec([int(i) for i in polygon])
29
  draw_img = cv2.rectangle(draw_img, p0, p1, (255,0,0), 2)
30
- draw_img = cv2.putText(draw_img, '%.3f' % score, p0, cv2.FONT_HERSHEY_PLAIN, 2, (0, 255, 0))
31
  return draw_img
32
 
33
  def run():
 
17
 
18
  def predict(image_input, score_threshold):
19
  draw_img = image_input.copy()
20
+ try:
21
+ output = ocr.readtext(image_input)
22
+ except:
23
+ output = dict(det_polygons=[], det_scores=[])
24
  polygons = output['det_polygons']
25
  scores = output['det_scores']
26
  for polygon, score in zip(polygons, scores):
27
  if score < score_threshold:
28
  continue
 
29
  p0, p1 = get_rec([int(i) for i in polygon])
30
  draw_img = cv2.rectangle(draw_img, p0, p1, (255,0,0), 2)
 
31
  return draw_img
32
 
33
  def run():