Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,92 +54,179 @@ css="""
|
|
54 |
|
55 |
with gr.Blocks(css=css) as demo:
|
56 |
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
with gr.Row():
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
placeholder="Enter a negative prompt",
|
84 |
-
visible=False,
|
85 |
)
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
step=1,
|
92 |
-
value=0,
|
93 |
)
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
with gr.Row():
|
98 |
|
99 |
-
|
100 |
-
label="
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
)
|
106 |
|
107 |
-
|
108 |
-
label="Height",
|
109 |
-
minimum=256,
|
110 |
-
maximum=MAX_IMAGE_SIZE,
|
111 |
-
step=32,
|
112 |
-
value=1024, #Replace with defaults that work for your model
|
113 |
-
)
|
114 |
|
115 |
-
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
label="
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
value=0.0, #Replace with defaults that work for your model
|
123 |
)
|
124 |
|
125 |
-
|
126 |
-
label="
|
127 |
-
minimum=
|
128 |
-
maximum=
|
129 |
step=1,
|
130 |
-
value=
|
131 |
)
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
# gr.on(
|
144 |
# triggers=[run_button.click, prompt.submit],
|
145 |
# fn = infer,
|
|
|
54 |
|
55 |
with gr.Blocks(css=css) as demo:
|
56 |
|
57 |
+
with gr.Tab("Text-to-Image"):
|
58 |
|
59 |
+
with gr.Column(elem_id="col-container"):
|
60 |
+
gr.Markdown(f"""
|
61 |
+
# Text-to-Image Gradio Template
|
62 |
+
""")
|
|
|
|
|
63 |
|
64 |
+
with gr.Row():
|
65 |
+
|
66 |
+
prompt = gr.Text(
|
67 |
+
label="Prompt",
|
68 |
+
show_label=False,
|
69 |
+
max_lines=1,
|
70 |
+
placeholder="Enter your prompt",
|
71 |
+
container=False,
|
72 |
+
)
|
73 |
+
|
74 |
+
run_button = gr.Button("Run", scale=0)
|
75 |
|
76 |
+
result = gr.Image(label="Result", show_label=False)
|
77 |
+
|
78 |
+
with gr.Accordion("Advanced Settings", open=False):
|
79 |
+
|
80 |
+
negative_prompt = gr.Text(
|
81 |
+
label="Negative prompt",
|
82 |
+
max_lines=1,
|
83 |
+
placeholder="Enter a negative prompt",
|
84 |
+
visible=False,
|
85 |
+
)
|
86 |
+
|
87 |
+
seed = gr.Slider(
|
88 |
+
label="Seed",
|
89 |
+
minimum=0,
|
90 |
+
maximum=MAX_SEED,
|
91 |
+
step=1,
|
92 |
+
value=0,
|
93 |
+
)
|
94 |
+
|
95 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
96 |
+
|
97 |
+
with gr.Row():
|
98 |
+
|
99 |
+
width = gr.Slider(
|
100 |
+
label="Width",
|
101 |
+
minimum=256,
|
102 |
+
maximum=MAX_IMAGE_SIZE,
|
103 |
+
step=32,
|
104 |
+
value=1024, #Replace with defaults that work for your model
|
105 |
+
)
|
106 |
+
|
107 |
+
height = gr.Slider(
|
108 |
+
label="Height",
|
109 |
+
minimum=256,
|
110 |
+
maximum=MAX_IMAGE_SIZE,
|
111 |
+
step=32,
|
112 |
+
value=1024, #Replace with defaults that work for your model
|
113 |
+
)
|
114 |
+
|
115 |
+
with gr.Row():
|
116 |
+
|
117 |
+
guidance_scale = gr.Slider(
|
118 |
+
label="Guidance scale",
|
119 |
+
minimum=0.0,
|
120 |
+
maximum=10.0,
|
121 |
+
step=0.1,
|
122 |
+
value=0.0, #Replace with defaults that work for your model
|
123 |
+
)
|
124 |
+
|
125 |
+
num_inference_steps = gr.Slider(
|
126 |
+
label="Number of inference steps",
|
127 |
+
minimum=1,
|
128 |
+
maximum=50,
|
129 |
+
step=1,
|
130 |
+
value=2, #Replace with defaults that work for your model
|
131 |
+
)
|
132 |
|
133 |
+
gr.Examples(
|
134 |
+
examples = examples,
|
135 |
+
inputs = [prompt]
|
|
|
|
|
136 |
)
|
137 |
+
|
138 |
+
run_button.click(
|
139 |
+
fn=infer,
|
140 |
+
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
141 |
+
outputs = [result, seed]
|
|
|
|
|
142 |
)
|
143 |
+
|
144 |
+
with gr.Tab("Image-to-Image"):
|
145 |
+
|
146 |
+
with gr.Column(elem_id="col-container"):
|
147 |
+
gr.Markdown(f"""
|
148 |
+
# Text-to-Image Gradio Template
|
149 |
+
""")
|
150 |
|
151 |
with gr.Row():
|
152 |
|
153 |
+
prompt = gr.Text(
|
154 |
+
label="Prompt",
|
155 |
+
show_label=False,
|
156 |
+
max_lines=1,
|
157 |
+
placeholder="Enter your prompt",
|
158 |
+
container=False,
|
159 |
)
|
160 |
|
161 |
+
run_button = gr.Button("Run", scale=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
+
result = gr.Image(label="Result", show_label=False)
|
164 |
+
|
165 |
+
with gr.Accordion("Advanced Settings", open=False):
|
166 |
|
167 |
+
negative_prompt = gr.Text(
|
168 |
+
label="Negative prompt",
|
169 |
+
max_lines=1,
|
170 |
+
placeholder="Enter a negative prompt",
|
171 |
+
visible=False,
|
|
|
172 |
)
|
173 |
|
174 |
+
seed = gr.Slider(
|
175 |
+
label="Seed",
|
176 |
+
minimum=0,
|
177 |
+
maximum=MAX_SEED,
|
178 |
step=1,
|
179 |
+
value=0,
|
180 |
)
|
181 |
+
|
182 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
183 |
+
|
184 |
+
with gr.Row():
|
185 |
+
|
186 |
+
width = gr.Slider(
|
187 |
+
label="Width",
|
188 |
+
minimum=256,
|
189 |
+
maximum=MAX_IMAGE_SIZE,
|
190 |
+
step=32,
|
191 |
+
value=1024, #Replace with defaults that work for your model
|
192 |
+
)
|
193 |
+
|
194 |
+
height = gr.Slider(
|
195 |
+
label="Height",
|
196 |
+
minimum=256,
|
197 |
+
maximum=MAX_IMAGE_SIZE,
|
198 |
+
step=32,
|
199 |
+
value=1024, #Replace with defaults that work for your model
|
200 |
+
)
|
201 |
+
|
202 |
+
with gr.Row():
|
203 |
+
|
204 |
+
guidance_scale = gr.Slider(
|
205 |
+
label="Guidance scale",
|
206 |
+
minimum=0.0,
|
207 |
+
maximum=10.0,
|
208 |
+
step=0.1,
|
209 |
+
value=7.5, #Replace with defaults that work for your model
|
210 |
+
)
|
211 |
+
|
212 |
+
num_inference_steps = gr.Slider(
|
213 |
+
label="Number of inference steps",
|
214 |
+
minimum=1,
|
215 |
+
maximum=50,
|
216 |
+
step=1,
|
217 |
+
value=25, #Replace with defaults that work for your model
|
218 |
+
)
|
219 |
+
|
220 |
+
gr.Examples(
|
221 |
+
examples = examples,
|
222 |
+
inputs = [prompt]
|
223 |
+
)
|
224 |
+
|
225 |
+
run_button.click(
|
226 |
+
fn=infer,
|
227 |
+
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
228 |
+
outputs = [result, seed]
|
229 |
+
)
|
230 |
# gr.on(
|
231 |
# triggers=[run_button.click, prompt.submit],
|
232 |
# fn = infer,
|