Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -194,23 +194,7 @@ with gr.Blocks(css=css) as demo:
|
|
194 |
step=1,
|
195 |
value=30,
|
196 |
)
|
197 |
-
|
198 |
-
with gr.Row(): # Добавляем чекбокс для ControlNet
|
199 |
-
use_control_net = gr.Checkbox(
|
200 |
-
label="Use ControlNet",
|
201 |
-
value=False,
|
202 |
-
)
|
203 |
-
|
204 |
-
with gr.Row(elem_id="control_net_row", visible=False): # Изначально скрываем элемент
|
205 |
-
#with gr.Row(elem_id="control_net_row"): # Изначально скрываем элемент
|
206 |
-
control_net_weight = gr.Slider(
|
207 |
-
label="ControlNet Weight",
|
208 |
-
minimum=0.0,
|
209 |
-
maximum=1.0,
|
210 |
-
step=0.05,
|
211 |
-
value=1.0,
|
212 |
-
)
|
213 |
-
|
214 |
with gr.Accordion("Advanced Settings", open=False):
|
215 |
with gr.Row():
|
216 |
width = gr.Slider(
|
@@ -230,18 +214,35 @@ with gr.Blocks(css=css) as demo:
|
|
230 |
value=512,
|
231 |
)
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
gr.Examples(examples=examples, inputs=[prompt])
|
234 |
gr.Examples(examples=examples_negative, inputs=[negative_prompt])
|
235 |
|
236 |
run_button = gr.Button("Run", scale=1, variant="primary")
|
237 |
result = gr.Image(label="Result", show_label=False)
|
238 |
|
239 |
-
|
240 |
-
# def toggle_control_net_visibility(use_control_net):
|
241 |
-
# return gr.update(visible=use_control_net, elem_id="control_net_row")
|
242 |
-
def toggle_control_net_visibility(control_net_weight):
|
243 |
-
return gr.update(visible=control_net_weight, elem_id="control_net_row")
|
244 |
-
use_control_net.change(fn=toggle_control_net_visibility, inputs=[use_control_net], outputs=[control_net_weight])
|
245 |
|
246 |
gr.on(
|
247 |
triggers=[run_button.click, prompt.submit],
|
|
|
194 |
step=1,
|
195 |
value=30,
|
196 |
)
|
197 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
with gr.Accordion("Advanced Settings", open=False):
|
199 |
with gr.Row():
|
200 |
width = gr.Slider(
|
|
|
214 |
value=512,
|
215 |
)
|
216 |
|
217 |
+
def update_controlnet_options(use_control_net):
|
218 |
+
if use_control_net:
|
219 |
+
return gr.Column.update(visible=True)
|
220 |
+
else:
|
221 |
+
return gr.Column.update(visible=False)
|
222 |
+
|
223 |
+
with gr.Blocks() as demo:
|
224 |
+
with gr.Row():
|
225 |
+
use_control_net = gr.Checkbox(label="Use ControlNet", value=False)
|
226 |
+
|
227 |
+
with gr.Column(visible=False) as controlnet_column:
|
228 |
+
with gr.Row():
|
229 |
+
control_strength_slider = gr.Slider(minimum=0, maximum=1, step=0.01, label="Control Strength")
|
230 |
+
|
231 |
+
with gr.Row():
|
232 |
+
control_mode_dropdown = gr.Dropdown(['edge_detection', 'pose_estimation'], label='Control Mode')
|
233 |
+
|
234 |
+
with gr.Row():
|
235 |
+
control_image_input = gr.Image(type="pil", label="Upload Image for ControlNet")
|
236 |
+
|
237 |
+
use_control_net.change(update_controlnet_options, inputs=[use_control_net], outputs=[controlnet_column])
|
238 |
+
|
239 |
gr.Examples(examples=examples, inputs=[prompt])
|
240 |
gr.Examples(examples=examples_negative, inputs=[negative_prompt])
|
241 |
|
242 |
run_button = gr.Button("Run", scale=1, variant="primary")
|
243 |
result = gr.Image(label="Result", show_label=False)
|
244 |
|
245 |
+
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
gr.on(
|
248 |
triggers=[run_button.click, prompt.submit],
|