Spaces:
Runtime error
Runtime error
sberbank-ai
commited on
Commit
·
04c0f3a
1
Parent(s):
c8cc838
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,6 +36,13 @@ def split_text_to_rows(text, n):
|
|
| 36 |
return [' '.join(l[x:x+n]) for x in range(0, len(l), n)]
|
| 37 |
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
def remove_right_padding(img, len_text, char_w=32):
|
| 40 |
# char_w for a standard ScrabbleGAN char width
|
| 41 |
return img[:, :len_text*char_w]
|
|
@@ -64,7 +71,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 =
|
| 68 |
else:
|
| 69 |
texts = [row.strip() for row in text.split(NEW_LINE_SYMB)]
|
| 70 |
|
|
@@ -104,6 +111,7 @@ 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(
|
|
|
|
| 36 |
return [' '.join(l[x:x+n]) for x in range(0, len(l), n)]
|
| 37 |
|
| 38 |
|
| 39 |
+
def split_text_to_rows_by_chars(text, n):
|
| 40 |
+
list_of_rows = []
|
| 41 |
+
for i in range(0, len(a), n):
|
| 42 |
+
list_of_rows.append(a[i:n+i].strip())
|
| 43 |
+
return list_of_rows
|
| 44 |
+
|
| 45 |
+
|
| 46 |
def remove_right_padding(img, len_text, char_w=32):
|
| 47 |
# char_w for a standard ScrabbleGAN char width
|
| 48 |
return img[:, :len_text*char_w]
|
|
|
|
| 71 |
|
| 72 |
def predict(text):
|
| 73 |
if text.find(NEW_LINE_SYMB) == -1:
|
| 74 |
+
texts = split_text_to_rows_by_chars(text, CHARS_IN_ROW)
|
| 75 |
else:
|
| 76 |
texts = [row.strip() for row in text.split(NEW_LINE_SYMB)]
|
| 77 |
|
|
|
|
| 111 |
ROW_WIDTH = 0.7
|
| 112 |
LEFT_PAD = 10
|
| 113 |
WORDS_IN_ROW = 4
|
| 114 |
+
CHARS_IN_ROW = 40
|
| 115 |
NEW_LINE_SYMB = '{n}'
|
| 116 |
|
| 117 |
gr.Interface(
|