multimodalart HF staff commited on
Commit
70bd2e0
·
verified ·
1 Parent(s): de26694

Update app_ctrlx.py

Browse files
Files changed (1) hide show
  1. app_ctrlx.py +34 -30
app_ctrlx.py CHANGED
@@ -85,7 +85,8 @@ title = """
85
  SDXL v1.0
86
  </h3>
87
  </div>
88
- <div style="display: flex; align-items: center; justify-content: center;margin-bottom: 25px">
 
89
  <h3 style="text-align: center">
90
  [<a href="https://genforce.github.io/ctrl-x/">Page</a>]
91
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
@@ -167,6 +168,7 @@ def inference(
167
  width, height,
168
  structure_schedule, appearance_schedule, use_advanced_config,
169
  control_config,
 
170
  ):
171
  torch.manual_seed(seed)
172
 
@@ -235,54 +237,56 @@ def inference(
235
 
236
  with gr.Blocks(theme=gr.themes.Default(), css=css, title="Ctrl-X (SDXL v1.0)") as app:
237
  gr.HTML(title)
238
-
 
239
  with gr.Row():
240
 
241
  with gr.Column(scale=55):
242
  with gr.Group():
243
  kwargs = {} # {"width": 400, "height": 400}
 
 
 
244
  with gr.Row():
245
  result = gr.Image(label="Output image", format="jpg", **kwargs)
246
  result_refiner = gr.Image(label="Output image w/ refiner", format="jpg", **kwargs)
247
  with gr.Row():
248
  structure_recon = gr.Image(label="Structure image", format="jpg", **kwargs)
249
  appearance_recon = gr.Image(label="Style image", format="jpg", **kwargs)
250
- with gr.Row():
251
- structure_image = gr.Image(label="Upload structure image (optional)", type="pil", **kwargs)
252
- appearance_image = gr.Image(label="Upload appearance image (optional)", type="pil", **kwargs)
253
-
254
  with gr.Column(scale=45):
255
  with gr.Group():
256
  with gr.Row():
257
- structure_prompt = gr.Textbox(label="Structure prompt (optional)", placeholder="Prompt which describes the structure image")
258
- appearance_prompt = gr.Textbox(label="Appearance prompt (optional)", placeholder="Prompt which describes the style image")
259
  with gr.Row():
260
  prompt = gr.Textbox(label="Output prompt", placeholder="Prompt which describes the output image")
261
  with gr.Row():
262
  positive_prompt = gr.Textbox(label="Positive prompt", value="high quality", placeholder="")
263
  negative_prompt = gr.Textbox(label="Negative prompt", value="ugly, blurry, dark, low res, unrealistic", placeholder="")
264
- with gr.Row():
265
- guidance_scale = gr.Slider(label="Target guidance scale", value=5.0, minimum=1, maximum=10)
266
- structure_guidance_scale = gr.Slider(label="Structure guidance scale", value=5.0, minimum=1, maximum=10)
267
- appearance_guidance_scale = gr.Slider(label="Appearance guidance scale", value=5.0, minimum=1, maximum=10)
268
- with gr.Row():
269
- num_inference_steps = gr.Slider(label="# inference steps", value=50, minimum=1, maximum=200, step=1)
270
- eta = gr.Slider(label="Eta (noise)", value=1.0, minimum=0, maximum=1.0, step=0.01)
271
- seed = gr.Slider(0, 2147483647, label="Seed", value=90095, step=1)
272
- with gr.Row():
273
- width = gr.Slider(label="Width", value=1024, minimum=256, maximum=2048, step=pipe.vae_scale_factor)
274
- height = gr.Slider(label="Height", value=1024, minimum=256, maximum=2048, step=pipe.vae_scale_factor)
275
- with gr.Row():
276
- structure_schedule = gr.Slider(label="Structure schedule", value=0.6, minimum=0.0, maximum=1.0, step=0.01, scale=2)
277
- appearance_schedule = gr.Slider(label="Appearance schedule", value=0.6, minimum=0.0, maximum=1.0, step=0.01, scale=2)
278
- use_advanced_config = gr.Checkbox(label="Use advanced config", value=False, scale=1)
279
- with gr.Row():
280
- control_config = gr.Textbox(
281
- label="Advanced control config", lines=20, value=get_control_config(0.6, 0.6), elem_classes=["config"], visible=False,
282
- )
283
- use_advanced_config.change(
284
- fn=lambda value: gr.update(visible=value), inputs=use_advanced_config, outputs=control_config,
285
- )
 
286
  with gr.Row():
287
  generate = gr.Button(value="Run")
288
 
 
85
  SDXL v1.0
86
  </h3>
87
  </div>
88
+ """
89
+ description = """<div style="display: flex; align-items: center; justify-content: center;margin-bottom: 25px">
90
  <h3 style="text-align: center">
91
  [<a href="https://genforce.github.io/ctrl-x/">Page</a>]
92
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
168
  width, height,
169
  structure_schedule, appearance_schedule, use_advanced_config,
170
  control_config,
171
+ progress=gr.Progress(track_tqdm=True)
172
  ):
173
  torch.manual_seed(seed)
174
 
 
237
 
238
  with gr.Blocks(theme=gr.themes.Default(), css=css, title="Ctrl-X (SDXL v1.0)") as app:
239
  gr.HTML(title)
240
+ with gr.Accordion("Instructions", open=False):
241
+ gr.HTML(description)
242
  with gr.Row():
243
 
244
  with gr.Column(scale=55):
245
  with gr.Group():
246
  kwargs = {} # {"width": 400, "height": 400}
247
+ with gr.Row():
248
+ structure_image = gr.Image(label="Upload structure image (optional)", type="pil", **kwargs)
249
+ appearance_image = gr.Image(label="Upload appearance image (optional)", type="pil", **kwargs)
250
  with gr.Row():
251
  result = gr.Image(label="Output image", format="jpg", **kwargs)
252
  result_refiner = gr.Image(label="Output image w/ refiner", format="jpg", **kwargs)
253
  with gr.Row():
254
  structure_recon = gr.Image(label="Structure image", format="jpg", **kwargs)
255
  appearance_recon = gr.Image(label="Style image", format="jpg", **kwargs)
256
+
 
 
 
257
  with gr.Column(scale=45):
258
  with gr.Group():
259
  with gr.Row():
260
+ structure_prompt = gr.Textbox(label="Structure prompt (optional)", placeholder="Describes the structure image")
261
+ appearance_prompt = gr.Textbox(label="Appearance prompt (optional)", placeholder="Describes the style image")
262
  with gr.Row():
263
  prompt = gr.Textbox(label="Output prompt", placeholder="Prompt which describes the output image")
264
  with gr.Row():
265
  positive_prompt = gr.Textbox(label="Positive prompt", value="high quality", placeholder="")
266
  negative_prompt = gr.Textbox(label="Negative prompt", value="ugly, blurry, dark, low res, unrealistic", placeholder="")
267
+ with gr.Accordion("Advanced Options", open=False):
268
+ with gr.Row():
269
+ guidance_scale = gr.Slider(label="Target guidance scale", value=5.0, minimum=1, maximum=10)
270
+ structure_guidance_scale = gr.Slider(label="Structure guidance scale", value=5.0, minimum=1, maximum=10)
271
+ appearance_guidance_scale = gr.Slider(label="Appearance guidance scale", value=5.0, minimum=1, maximum=10)
272
+ with gr.Row():
273
+ num_inference_steps = gr.Slider(label="# inference steps", value=50, minimum=1, maximum=200, step=1)
274
+ eta = gr.Slider(label="Eta (noise)", value=1.0, minimum=0, maximum=1.0, step=0.01)
275
+ seed = gr.Slider(0, 2147483647, label="Seed", value=90095, step=1)
276
+ with gr.Row():
277
+ width = gr.Slider(label="Width", value=1024, minimum=256, maximum=2048, step=pipe.vae_scale_factor)
278
+ height = gr.Slider(label="Height", value=1024, minimum=256, maximum=2048, step=pipe.vae_scale_factor)
279
+ with gr.Row():
280
+ structure_schedule = gr.Slider(label="Structure schedule", value=0.6, minimum=0.0, maximum=1.0, step=0.01, scale=2)
281
+ appearance_schedule = gr.Slider(label="Appearance schedule", value=0.6, minimum=0.0, maximum=1.0, step=0.01, scale=2)
282
+ use_advanced_config = gr.Checkbox(label="Use advanced config", value=False, scale=1)
283
+ with gr.Row():
284
+ control_config = gr.Textbox(
285
+ label="Advanced control config", lines=20, value=get_control_config(0.6, 0.6), elem_classes=["config"], visible=False,
286
+ )
287
+ use_advanced_config.change(
288
+ fn=lambda value: gr.update(visible=value), inputs=use_advanced_config, outputs=control_config,
289
+ )
290
  with gr.Row():
291
  generate = gr.Button(value="Run")
292