Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -585,7 +585,7 @@ def _summarize(text):
|
|
585 |
log(f'RET _summarize with ret as {ret}')
|
586 |
return ret
|
587 |
|
588 |
-
def summarize(text, max_words=
|
589 |
log(f'CALL summarize')
|
590 |
|
591 |
words = text.split()
|
@@ -616,7 +616,7 @@ def generate_random_string(length):
|
|
616 |
characters = str(ascii_letters + digits)
|
617 |
return ''.join(random.choice(characters) for _ in range(length))
|
618 |
|
619 |
-
def
|
620 |
|
621 |
w, h = img.size
|
622 |
|
@@ -1279,7 +1279,7 @@ def handle_generation(h,w,d):
|
|
1279 |
d = " ".join(d_lines)
|
1280 |
|
1281 |
d = re.sub(r"([ \t]){1,}", " ", d).lower().strip()
|
1282 |
-
d = d if d == "" else summarize(translate(d))
|
1283 |
d = re.sub(r"([ \t]){1,}", " ", d)
|
1284 |
d = re.sub(r"(\. \.)", ".", d)
|
1285 |
|
@@ -1377,7 +1377,7 @@ if __name__ == "__main__":
|
|
1377 |
outputs=[cover]
|
1378 |
)
|
1379 |
add_titles.click(
|
1380 |
-
fn=
|
1381 |
inputs=[cover,top,bottom],
|
1382 |
outputs=[cover]
|
1383 |
)
|
|
|
585 |
log(f'RET _summarize with ret as {ret}')
|
586 |
return ret
|
587 |
|
588 |
+
def summarize(text, max_words=100):
|
589 |
log(f'CALL summarize')
|
590 |
|
591 |
words = text.split()
|
|
|
616 |
characters = str(ascii_letters + digits)
|
617 |
return ''.join(random.choice(characters) for _ in range(length))
|
618 |
|
619 |
+
def add_text_above_image(img,top_title=None,bottom_title=None):
|
620 |
|
621 |
w, h = img.size
|
622 |
|
|
|
1279 |
d = " ".join(d_lines)
|
1280 |
|
1281 |
d = re.sub(r"([ \t]){1,}", " ", d).lower().strip()
|
1282 |
+
d = d if d == "" else summarize(translate(d),max_words=30)
|
1283 |
d = re.sub(r"([ \t]){1,}", " ", d)
|
1284 |
d = re.sub(r"(\. \.)", ".", d)
|
1285 |
|
|
|
1377 |
outputs=[cover]
|
1378 |
)
|
1379 |
add_titles.click(
|
1380 |
+
fn=add_text_above_image,
|
1381 |
inputs=[cover,top,bottom],
|
1382 |
outputs=[cover]
|
1383 |
)
|