PNG sucks
Browse files
app.py
CHANGED
@@ -13,7 +13,8 @@ from PIL import Image
|
|
13 |
import gradio as gr
|
14 |
import time
|
15 |
from safetensors.torch import load_file
|
16 |
-
|
|
|
17 |
|
18 |
# Constants
|
19 |
BASE = "stabilityai/stable-diffusion-xl-base-1.0"
|
@@ -132,7 +133,10 @@ def predict(prompt, seed=1231231):
|
|
132 |
gr.Warning("NSFW content detected.")
|
133 |
return Image.new("RGB", (512, 512))
|
134 |
return images[0]
|
135 |
-
|
|
|
|
|
|
|
136 |
|
137 |
|
138 |
css = """
|
@@ -194,9 +198,12 @@ pipe("A girl smiling", num_inference_steps=2, guidance_scale=0).images[0].save("
|
|
194 |
)
|
195 |
|
196 |
inputs = [prompt, seed]
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
200 |
|
201 |
demo.queue()
|
202 |
demo.launch()
|
|
|
13 |
import gradio as gr
|
14 |
import time
|
15 |
from safetensors.torch import load_file
|
16 |
+
import time
|
17 |
+
import tempfile
|
18 |
|
19 |
# Constants
|
20 |
BASE = "stabilityai/stable-diffusion-xl-base-1.0"
|
|
|
133 |
gr.Warning("NSFW content detected.")
|
134 |
return Image.new("RGB", (512, 512))
|
135 |
return images[0]
|
136 |
+
image = results.images[0]
|
137 |
+
with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as tmpfile:
|
138 |
+
image.save(tmpfile, "JPEG", quality=80, optimize=True, progressive=True)
|
139 |
+
return tmpfile.name
|
140 |
|
141 |
|
142 |
css = """
|
|
|
198 |
)
|
199 |
|
200 |
inputs = [prompt, seed]
|
201 |
+
outputs = [image]
|
202 |
+
generate_bt.click(
|
203 |
+
fn=predict, inputs=inputs, outputs=outputs, show_progress=False
|
204 |
+
)
|
205 |
+
prompt.input(fn=predict, inputs=inputs, outputs=outputs, show_progress=False)
|
206 |
+
seed.change(fn=predict, inputs=inputs, outputs=outputs, show_progress=False)
|
207 |
|
208 |
demo.queue()
|
209 |
demo.launch()
|