Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
•
80de021
1
Parent(s):
07f410e
Update app.py
Browse files
app.py
CHANGED
@@ -5,12 +5,13 @@ from PIL import Image
|
|
5 |
import re
|
6 |
import os
|
7 |
import requests
|
|
|
|
|
8 |
|
9 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
10 |
|
11 |
word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt")
|
12 |
word_list = word_list_dataset["train"]['text']
|
13 |
-
print(word_list)
|
14 |
|
15 |
is_gpu_busy = False
|
16 |
def infer(prompt, negative, scale):
|
@@ -27,11 +28,12 @@ def infer(prompt, negative, scale):
|
|
27 |
payload = {'prompt': prompt, 'negative_prompt': negative, 'guidance_scale': scale}
|
28 |
images_request = requests.post(url, json = payload)
|
29 |
for image in images_request.json()["images"]:
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
|
36 |
|
37 |
css = """
|
@@ -253,7 +255,7 @@ with block:
|
|
253 |
)
|
254 |
with gr.Group():
|
255 |
with gr.Box():
|
256 |
-
with gr.Row(elem_id="prompt-container")
|
257 |
with gr.Column():
|
258 |
text = gr.Textbox(
|
259 |
label="Enter your prompt",
|
@@ -261,10 +263,6 @@ with block:
|
|
261 |
max_lines=1,
|
262 |
placeholder="Enter your prompt",
|
263 |
elem_id="prompt-text-input",
|
264 |
-
).style(
|
265 |
-
border=(True, False, True, True),
|
266 |
-
rounded=(True, False, False, True),
|
267 |
-
container=False,
|
268 |
)
|
269 |
negative = gr.Textbox(
|
270 |
label="Enter your negative prompt",
|
@@ -272,20 +270,12 @@ with block:
|
|
272 |
max_lines=1,
|
273 |
placeholder="Enter a negative prompt",
|
274 |
elem_id="negative-prompt-text-input",
|
275 |
-
).style(
|
276 |
-
border=(True, False, True, True),
|
277 |
-
rounded=(True, False, False, True),
|
278 |
-
container=False,
|
279 |
)
|
280 |
-
btn = gr.Button("Generate image")
|
281 |
-
margin=False,
|
282 |
-
rounded=(False, True, True, False),
|
283 |
-
full_width=False,
|
284 |
-
)
|
285 |
|
286 |
gallery = gr.Gallery(
|
287 |
label="Generated images", show_label=False, elem_id="gallery"
|
288 |
-
)
|
289 |
|
290 |
with gr.Group(elem_id="container-advanced-btns"):
|
291 |
#advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
|
|
|
5 |
import re
|
6 |
import os
|
7 |
import requests
|
8 |
+
import uuid
|
9 |
+
import base64
|
10 |
|
11 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
12 |
|
13 |
word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt")
|
14 |
word_list = word_list_dataset["train"]['text']
|
|
|
15 |
|
16 |
is_gpu_busy = False
|
17 |
def infer(prompt, negative, scale):
|
|
|
28 |
payload = {'prompt': prompt, 'negative_prompt': negative, 'guidance_scale': scale}
|
29 |
images_request = requests.post(url, json = payload)
|
30 |
for image in images_request.json()["images"]:
|
31 |
+
file_path = f"{uuid.uuid4()}.jpg"
|
32 |
+
with open(file_path, "wb") as f:
|
33 |
+
f.write(base64.b64decode(image))
|
34 |
+
images.append(file_path)
|
35 |
+
|
36 |
+
return images
|
37 |
|
38 |
|
39 |
css = """
|
|
|
255 |
)
|
256 |
with gr.Group():
|
257 |
with gr.Box():
|
258 |
+
with gr.Row(elem_id="prompt-container"):
|
259 |
with gr.Column():
|
260 |
text = gr.Textbox(
|
261 |
label="Enter your prompt",
|
|
|
263 |
max_lines=1,
|
264 |
placeholder="Enter your prompt",
|
265 |
elem_id="prompt-text-input",
|
|
|
|
|
|
|
|
|
266 |
)
|
267 |
negative = gr.Textbox(
|
268 |
label="Enter your negative prompt",
|
|
|
270 |
max_lines=1,
|
271 |
placeholder="Enter a negative prompt",
|
272 |
elem_id="negative-prompt-text-input",
|
|
|
|
|
|
|
|
|
273 |
)
|
274 |
+
btn = gr.Button("Generate image")
|
|
|
|
|
|
|
|
|
275 |
|
276 |
gallery = gr.Gallery(
|
277 |
label="Generated images", show_label=False, elem_id="gallery"
|
278 |
+
)
|
279 |
|
280 |
with gr.Group(elem_id="container-advanced-btns"):
|
281 |
#advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
|