sberbank-ai commited on
Commit
c8cc838
1 Parent(s): 7d394f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -30,7 +30,7 @@ def get_text_from_image(img):
30
  return bg
31
 
32
 
33
- def split_text_to_rows(text, n=4):
34
  # https://stackoverflow.com/a/6187258
35
  l = text.split()
36
  return [' '.join(l[x:x+n]) for x in range(0, len(l), n)]
@@ -64,7 +64,7 @@ def get_canvas_size(images, row_width, left_pad):
64
 
65
  def predict(text):
66
  if text.find(NEW_LINE_SYMB) == -1:
67
- texts = split_text_to_rows(text)
68
  else:
69
  texts = [row.strip() for row in text.split(NEW_LINE_SYMB)]
70
 
@@ -103,6 +103,7 @@ GENERATOR = ImgGenerator(
103
  BATCH_SIZE = 3
104
  ROW_WIDTH = 0.7
105
  LEFT_PAD = 10
 
106
  NEW_LINE_SYMB = '{n}'
107
 
108
  gr.Interface(
 
30
  return bg
31
 
32
 
33
+ def split_text_to_rows(text, n):
34
  # https://stackoverflow.com/a/6187258
35
  l = text.split()
36
  return [' '.join(l[x:x+n]) for x in range(0, len(l), n)]
 
64
 
65
  def predict(text):
66
  if text.find(NEW_LINE_SYMB) == -1:
67
+ texts = split_text_to_rows(text, WORDS_IN_ROW)
68
  else:
69
  texts = [row.strip() for row in text.split(NEW_LINE_SYMB)]
70
 
 
103
  BATCH_SIZE = 3
104
  ROW_WIDTH = 0.7
105
  LEFT_PAD = 10
106
+ WORDS_IN_ROW = 4
107
  NEW_LINE_SYMB = '{n}'
108
 
109
  gr.Interface(