Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,20 @@
|
|
1 |
from diffusers import StableDiffusionXLPipeline
|
2 |
import torch
|
3 |
-
from gradio import Interface, Image, Dropdown, Slider
|
4 |
import gradio as gr
|
5 |
-
import spaces
|
6 |
|
|
|
7 |
model_id = "RunDiffusion/Juggernaut-X-v10"
|
8 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.
|
9 |
-
pipe = pipe.to("
|
10 |
|
11 |
-
|
12 |
-
def text_to_image(prompt, negative_prompt, steps, guidance_scale, add_4k_masterpiece, progress=gr.Progress(track_tqdm=True)):
|
13 |
if add_4k_masterpiece:
|
14 |
prompt += ", 4k, (masterpiece)"
|
15 |
image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=guidance_scale).images[0]
|
16 |
return image
|
17 |
-
duplicate_button = gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
18 |
|
19 |
-
gradio_interface = Interface(
|
20 |
fn=text_to_image,
|
21 |
-
allow_duplication=True,
|
22 |
inputs=[
|
23 |
gr.Textbox(label="Prompt", lines=2, placeholder="Enter your prompt here..."),
|
24 |
gr.Textbox(label="Negative Prompt", lines=2, placeholder="What to exclude from the image..."),
|
@@ -26,11 +22,12 @@ gradio_interface = Interface(
|
|
26 |
gr.Slider(minimum=1, maximum=20, value=7.5, label="Guidance Scale", step=0.1),
|
27 |
gr.Checkbox(label="Add recommended prompt items (4k, masterpiece)", value=False)
|
28 |
],
|
29 |
-
outputs=Image(type="pil", show_download_button=True),
|
30 |
examples=[
|
31 |
-
["magical kitten, 4k, high quality, (masterpiece)"],
|
32 |
],
|
33 |
cache_examples=False,
|
34 |
theme=gr.themes.Soft()
|
35 |
)
|
|
|
36 |
gradio_interface.launch()
|
|
|
1 |
from diffusers import StableDiffusionXLPipeline
|
2 |
import torch
|
|
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
+
# Load the model
|
6 |
model_id = "RunDiffusion/Juggernaut-X-v10"
|
7 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
8 |
+
pipe = pipe.to("cpu")
|
9 |
|
10 |
+
def text_to_image(prompt, negative_prompt, steps, guidance_scale, add_4k_masterpiece):
|
|
|
11 |
if add_4k_masterpiece:
|
12 |
prompt += ", 4k, (masterpiece)"
|
13 |
image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=guidance_scale).images[0]
|
14 |
return image
|
|
|
15 |
|
16 |
+
gradio_interface = gr.Interface(
|
17 |
fn=text_to_image,
|
|
|
18 |
inputs=[
|
19 |
gr.Textbox(label="Prompt", lines=2, placeholder="Enter your prompt here..."),
|
20 |
gr.Textbox(label="Negative Prompt", lines=2, placeholder="What to exclude from the image..."),
|
|
|
22 |
gr.Slider(minimum=1, maximum=20, value=7.5, label="Guidance Scale", step=0.1),
|
23 |
gr.Checkbox(label="Add recommended prompt items (4k, masterpiece)", value=False)
|
24 |
],
|
25 |
+
outputs=gr.Image(type="pil", show_download_button=True),
|
26 |
examples=[
|
27 |
+
["magical kitten, 4k, high quality, (masterpiece)", "", 50, 7.5, False],
|
28 |
],
|
29 |
cache_examples=False,
|
30 |
theme=gr.themes.Soft()
|
31 |
)
|
32 |
+
|
33 |
gradio_interface.launch()
|