Spaces:
Paused
Paused
commit
Browse files
app.py
CHANGED
|
@@ -13,6 +13,7 @@ import sys
|
|
| 13 |
import warnings
|
| 14 |
import time
|
| 15 |
import asyncio
|
|
|
|
| 16 |
from functools import partial
|
| 17 |
|
| 18 |
# external
|
|
@@ -122,9 +123,9 @@ image_pipe.enable_model_cpu_offload()
|
|
| 122 |
|
| 123 |
# functionality
|
| 124 |
|
| 125 |
-
@spaces.GPU(duration=
|
| 126 |
def summarize_text(
|
| 127 |
-
text, max_length=30, num_beams=
|
| 128 |
pegasus_tokenizer = PegasusTokenizerFast.from_pretrained("google/pegasus-xsum"),
|
| 129 |
pegasus_model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
|
| 130 |
):
|
|
@@ -139,7 +140,7 @@ def generate_random_string(length):
|
|
| 139 |
characters = str(ascii_letters + digits)
|
| 140 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 141 |
|
| 142 |
-
@spaces.GPU(duration=
|
| 143 |
def pipe_generate(p1,p2):
|
| 144 |
return image_pipe(
|
| 145 |
prompt=p1,
|
|
@@ -175,22 +176,22 @@ def handle_generate(artist,song,genre,lyrics):
|
|
| 175 |
draw = ImageDraw.Draw(img)
|
| 176 |
|
| 177 |
rows = 1
|
| 178 |
-
labes_distance = 1
|
| 179 |
|
| 180 |
-
textheight=min(( width
|
| 181 |
font = ImageFont.truetype(r"Alef-Bold.ttf", textheight)
|
| 182 |
textwidth = draw.textlength(pos_song,font)
|
| 183 |
-
x = (width - textwidth)
|
| 184 |
-
y = (height - (textheight * rows
|
| 185 |
-
y = y - (y
|
| 186 |
draw.text((x, y), pos_song, (255,255,255), font=font)
|
| 187 |
|
| 188 |
-
textheight=min(( width
|
| 189 |
font = ImageFont.truetype(r"Alef-Bold.ttf", textheight)
|
| 190 |
textwidth = draw.textlength(pos_artist,font)
|
| 191 |
-
x = (width - textwidth)
|
| 192 |
-
y = (height - (textheight * rows
|
| 193 |
-
y = y + (y
|
| 194 |
draw.text((x, y), pos_artist, (255,255,255), font=font)
|
| 195 |
|
| 196 |
name = generate_random_string(12) + ".png"
|
|
|
|
| 13 |
import warnings
|
| 14 |
import time
|
| 15 |
import asyncio
|
| 16 |
+
import math
|
| 17 |
from functools import partial
|
| 18 |
|
| 19 |
# external
|
|
|
|
| 123 |
|
| 124 |
# functionality
|
| 125 |
|
| 126 |
+
@spaces.GPU(duration=70)
|
| 127 |
def summarize_text(
|
| 128 |
+
text, max_length=30, num_beams=16, early_stopping=True,
|
| 129 |
pegasus_tokenizer = PegasusTokenizerFast.from_pretrained("google/pegasus-xsum"),
|
| 130 |
pegasus_model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
|
| 131 |
):
|
|
|
|
| 140 |
characters = str(ascii_letters + digits)
|
| 141 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 142 |
|
| 143 |
+
@spaces.GPU(duration=140)
|
| 144 |
def pipe_generate(p1,p2):
|
| 145 |
return image_pipe(
|
| 146 |
prompt=p1,
|
|
|
|
| 176 |
draw = ImageDraw.Draw(img)
|
| 177 |
|
| 178 |
rows = 1
|
| 179 |
+
labes_distance = math.cail(1 / 3)
|
| 180 |
|
| 181 |
+
textheight=min(math.cail( width / 10 ), math.cail( height / 5 ))
|
| 182 |
font = ImageFont.truetype(r"Alef-Bold.ttf", textheight)
|
| 183 |
textwidth = draw.textlength(pos_song,font)
|
| 184 |
+
x = math.cail((width - textwidth) / 2)
|
| 185 |
+
y = math.cail((height - math.cail(textheight * rows / 2)) / 2)
|
| 186 |
+
y = y - math.cail(y / labes_distance)
|
| 187 |
draw.text((x, y), pos_song, (255,255,255), font=font)
|
| 188 |
|
| 189 |
+
textheight=min(math.cail( width / 12 ), math.cail( height / 6 ))
|
| 190 |
font = ImageFont.truetype(r"Alef-Bold.ttf", textheight)
|
| 191 |
textwidth = draw.textlength(pos_artist,font)
|
| 192 |
+
x = math.cail((width - textwidth) / 2)
|
| 193 |
+
y = math.cail((height - math.cail(textheight * rows / 2)) / 2)
|
| 194 |
+
y = y + math.cail(y / labes_distance)
|
| 195 |
draw.text((x, y), pos_artist, (255,255,255), font=font)
|
| 196 |
|
| 197 |
name = generate_random_string(12) + ".png"
|