Spaces:
Sleeping
Sleeping
switch to stable difussion 3.5 large
Browse files
app.py
CHANGED
@@ -21,17 +21,16 @@ pipe = pipe.to(device)
|
|
21 |
MAX_SEED = np.iinfo(np.int32).max
|
22 |
MAX_IMAGE_SIZE = 1024
|
23 |
|
24 |
-
|
25 |
-
@spaces.GPU
|
26 |
def infer(
|
27 |
prompt,
|
28 |
-
negative_prompt,
|
29 |
-
seed,
|
30 |
-
randomize_seed,
|
31 |
-
width,
|
32 |
-
height,
|
33 |
-
guidance_scale,
|
34 |
-
num_inference_steps,
|
35 |
progress=gr.Progress(track_tqdm=True),
|
36 |
):
|
37 |
if randomize_seed:
|
@@ -53,9 +52,7 @@ def infer(
|
|
53 |
|
54 |
|
55 |
examples = [
|
56 |
-
|
57 |
-
"An astronaut riding a green horse",
|
58 |
-
"A delicious ceviche cheesecake slice",
|
59 |
]
|
60 |
|
61 |
css = """
|
@@ -67,8 +64,8 @@ css = """
|
|
67 |
|
68 |
with gr.Blocks(css=css) as demo:
|
69 |
with gr.Column(elem_id="col-container"):
|
70 |
-
gr.Markdown(" #
|
71 |
-
|
72 |
with gr.Row():
|
73 |
prompt = gr.Text(
|
74 |
label="Prompt",
|
@@ -103,27 +100,27 @@ with gr.Blocks(css=css) as demo:
|
|
103 |
with gr.Row():
|
104 |
width = gr.Slider(
|
105 |
label="Width",
|
106 |
-
minimum=
|
107 |
maximum=MAX_IMAGE_SIZE,
|
108 |
step=32,
|
109 |
-
value=1024,
|
110 |
)
|
111 |
|
112 |
height = gr.Slider(
|
113 |
label="Height",
|
114 |
-
minimum=
|
115 |
maximum=MAX_IMAGE_SIZE,
|
116 |
step=32,
|
117 |
-
value=1024,
|
118 |
)
|
119 |
|
120 |
with gr.Row():
|
121 |
guidance_scale = gr.Slider(
|
122 |
label="Guidance scale",
|
123 |
minimum=0.0,
|
124 |
-
maximum=
|
125 |
step=0.1,
|
126 |
-
value=
|
127 |
)
|
128 |
|
129 |
num_inference_steps = gr.Slider(
|
@@ -131,10 +128,10 @@ with gr.Blocks(css=css) as demo:
|
|
131 |
minimum=1,
|
132 |
maximum=50,
|
133 |
step=1,
|
134 |
-
value=
|
135 |
)
|
136 |
|
137 |
-
gr.Examples(examples=examples, inputs=[prompt])
|
138 |
gr.on(
|
139 |
triggers=[run_button.click, prompt.submit],
|
140 |
fn=infer,
|
|
|
21 |
MAX_SEED = np.iinfo(np.int32).max
|
22 |
MAX_IMAGE_SIZE = 1024
|
23 |
|
24 |
+
@spaces.GPU(duration=65)
|
|
|
25 |
def infer(
|
26 |
prompt,
|
27 |
+
negative_prompt="",
|
28 |
+
seed=42,
|
29 |
+
randomize_seed=False,
|
30 |
+
width=1024,
|
31 |
+
height=1024,
|
32 |
+
guidance_scale=4.5,
|
33 |
+
num_inference_steps=40,
|
34 |
progress=gr.Progress(track_tqdm=True),
|
35 |
):
|
36 |
if randomize_seed:
|
|
|
52 |
|
53 |
|
54 |
examples = [
|
55 |
+
"A capybara wearing a suit holding a sign that reads Hello World",
|
|
|
|
|
56 |
]
|
57 |
|
58 |
css = """
|
|
|
64 |
|
65 |
with gr.Blocks(css=css) as demo:
|
66 |
with gr.Column(elem_id="col-container"):
|
67 |
+
gr.Markdown(" # [Stable Diffusion 3.5 Large (8B)](https://huggingface.co/stabilityai/stable-diffusion-3.5-large)")
|
68 |
+
gr.Markdown("[Learn more](https://stability.ai/news/introducing-stable-diffusion-3-5) about the Stable Diffusion 3.5 series. Try on [Stability AI API](https://platform.stability.ai/docs/api-reference#tag/Generate/paths/~1v2beta~1stable-image~1generate~1sd3/post), or [download model](https://huggingface.co/stabilityai/stable-diffusion-3.5-large) to run locally with ComfyUI or diffusers.")
|
69 |
with gr.Row():
|
70 |
prompt = gr.Text(
|
71 |
label="Prompt",
|
|
|
100 |
with gr.Row():
|
101 |
width = gr.Slider(
|
102 |
label="Width",
|
103 |
+
minimum=512,
|
104 |
maximum=MAX_IMAGE_SIZE,
|
105 |
step=32,
|
106 |
+
value=1024,
|
107 |
)
|
108 |
|
109 |
height = gr.Slider(
|
110 |
label="Height",
|
111 |
+
minimum=512,
|
112 |
maximum=MAX_IMAGE_SIZE,
|
113 |
step=32,
|
114 |
+
value=1024,
|
115 |
)
|
116 |
|
117 |
with gr.Row():
|
118 |
guidance_scale = gr.Slider(
|
119 |
label="Guidance scale",
|
120 |
minimum=0.0,
|
121 |
+
maximum=7.5,
|
122 |
step=0.1,
|
123 |
+
value=4.5,
|
124 |
)
|
125 |
|
126 |
num_inference_steps = gr.Slider(
|
|
|
128 |
minimum=1,
|
129 |
maximum=50,
|
130 |
step=1,
|
131 |
+
value=40,
|
132 |
)
|
133 |
|
134 |
+
gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=True, cache_mode="lazy")
|
135 |
gr.on(
|
136 |
triggers=[run_button.click, prompt.submit],
|
137 |
fn=infer,
|