Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,8 @@ import random
|
|
| 5 |
import torch
|
| 6 |
from diffusers import StableDiffusion3Pipeline, SD3Transformer2DModel, FlowMatchEulerDiscreteScheduler
|
| 7 |
from PIL import Image
|
| 8 |
-
import
|
|
|
|
| 9 |
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
dtype = torch.float16
|
|
@@ -34,13 +35,13 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
| 34 |
generator = generator
|
| 35 |
).images[0]
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
# Return the
|
| 43 |
-
return
|
| 44 |
|
| 45 |
examples = [
|
| 46 |
# Each sublist corresponds to a full set of inputs
|
|
@@ -129,7 +130,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as generino:
|
|
| 129 |
)
|
| 130 |
run_button = gr.Button("Generate image", elem_id="genBtn", scale=1)
|
| 131 |
|
| 132 |
-
result = gr.Image(label="Result", show_label=False, elem_id="genImage", type="
|
| 133 |
|
| 134 |
with gr.Accordion("Pro settings", open=False):
|
| 135 |
|
|
|
|
| 5 |
import torch
|
| 6 |
from diffusers import StableDiffusion3Pipeline, SD3Transformer2DModel, FlowMatchEulerDiscreteScheduler
|
| 7 |
from PIL import Image
|
| 8 |
+
import tempfile
|
| 9 |
+
import os
|
| 10 |
|
| 11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 12 |
dtype = torch.float16
|
|
|
|
| 35 |
generator = generator
|
| 36 |
).images[0]
|
| 37 |
|
| 38 |
+
# Save the image as a PNG
|
| 39 |
+
temp_dir = tempfile.gettempdir()
|
| 40 |
+
image_path = os.path.join(temp_dir, f"generated_image_{seed}.png")
|
| 41 |
+
image.save(image_path, format="PNG")
|
| 42 |
+
|
| 43 |
+
# Return the file path and seed
|
| 44 |
+
return image_path, seed
|
| 45 |
|
| 46 |
examples = [
|
| 47 |
# Each sublist corresponds to a full set of inputs
|
|
|
|
| 130 |
)
|
| 131 |
run_button = gr.Button("Generate image", elem_id="genBtn", scale=1)
|
| 132 |
|
| 133 |
+
result = gr.Image(label="Result", show_label=False, elem_id="genImage", type="filepath")
|
| 134 |
|
| 135 |
with gr.Accordion("Pro settings", open=False):
|
| 136 |
|