Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -122,7 +122,13 @@ pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapt
|
|
| 122 |
pipe.enable_free_init(method="butterworth", use_fast_sampling=fast)
|
| 123 |
|
| 124 |
# functionality
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
def run(cmd):
|
| 127 |
return str(subprocess.run(cmd, shell=True, capture_output=True, env=None).stdout)
|
| 128 |
|
|
@@ -241,7 +247,7 @@ def handle_generate(*_inp):
|
|
| 241 |
|
| 242 |
if inp[5] != "":
|
| 243 |
draw = ImageDraw.Draw(pipe_out)
|
| 244 |
-
textwidth, textheight =
|
| 245 |
margin = 10
|
| 246 |
x = width - textwidth - margin
|
| 247 |
y = height - textheight - margin
|
|
|
|
| 122 |
pipe.enable_free_init(method="butterworth", use_fast_sampling=fast)
|
| 123 |
|
| 124 |
# functionality
|
| 125 |
+
|
| 126 |
+
def textsize(text):
|
| 127 |
+
im = Image.new(mode="P", size=(0, 0))
|
| 128 |
+
draw = ImageDraw.Draw(im)
|
| 129 |
+
_, _, width, height = draw.textbbox((0, 0), text=text)
|
| 130 |
+
return width, height
|
| 131 |
+
|
| 132 |
def run(cmd):
|
| 133 |
return str(subprocess.run(cmd, shell=True, capture_output=True, env=None).stdout)
|
| 134 |
|
|
|
|
| 247 |
|
| 248 |
if inp[5] != "":
|
| 249 |
draw = ImageDraw.Draw(pipe_out)
|
| 250 |
+
textwidth, textheight = textsize(inp[5])
|
| 251 |
margin = 10
|
| 252 |
x = width - textwidth - margin
|
| 253 |
y = height - textheight - margin
|