fffiloni commited on
Commit
a045576
1 Parent(s): 038916c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -33
app.py CHANGED
@@ -29,6 +29,12 @@ controlnet = ControlNetModel.from_pretrained(
29
  torch_dtype=torch.float16
30
  )
31
 
 
 
 
 
 
 
32
  def get_files(file_paths):
33
  last_files = {} # Dictionary to store the last file for each path
34
 
@@ -243,41 +249,10 @@ with gr.Blocks(css=css) as demo:
243
  <p style="text-align: center;">Use StableDiffusion XL with <a href="https://huggingface.co/collections/diffusers/sdxl-controlnets-64f9c35846f3f06f5abe351f">Diffusers' SDXL ControlNets</a></p>
244
 
245
  """)
246
-
247
- image_in = gr.Image(source="upload", type="filepath")
248
-
249
- with gr.Row():
250
-
251
- with gr.Column():
252
- with gr.Group():
253
- prompt = gr.Textbox(label="Prompt")
254
- negative_prompt = gr.Textbox(label="Negative prompt", value="extra digit, fewer digits, cropped, worst quality, low quality, glitch, deformed, mutated, ugly, disfigured")
255
- with gr.Group():
256
- guidance_scale = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=7.5)
257
- inf_steps = gr.Slider(label="Inference Steps", minimum="25", maximum="50", step=1, value=25)
258
- custom_lora_weight = gr.Slider(label="Custom model weights", minimum=0.1, maximum=0.9, step=0.1, value=0.9)
259
 
260
- with gr.Column():
261
- with gr.Group():
262
- preprocessor = gr.Dropdown(label="Preprocessor", choices=["canny"], value="canny", interactive=False, info="For the moment, only canny is available")
263
- controlnet_conditioning_scale = gr.Slider(label="Controlnet conditioning Scale", minimum=0.1, maximum=0.9, step=0.01, value=0.5)
264
- with gr.Group():
265
- seed = gr.Slider(
266
- label="Seed",
267
- info = "-1 denotes a random seed",
268
- minimum=-1,
269
- maximum=423538377342,
270
- step=1,
271
- value=-1
272
- )
273
- last_used_seed = gr.Number(
274
- label = "Last used seed",
275
- info = "the seed used in the last generation",
276
- )
277
-
278
  use_custom_model = gr.Checkbox(label="Use a public custom model ?(optional)", value=False, info="To use a private model, you'll prefer to duplicate the space with your own access token.")
279
 
280
- with gr.Box(visible=True) as custom_model_box:
281
  with gr.Row():
282
  with gr.Column():
283
  if not is_shared_ui:
@@ -320,10 +295,49 @@ with gr.Blocks(css=css) as demo:
320
  )
321
  trigger_word = gr.Textbox(label="Trigger word", interactive=False, visible=False)
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  submit_btn = gr.Button("Submit")
324
 
325
  result = gr.Image(label="Result")
326
-
 
 
 
 
 
 
327
  custom_model.blur(
328
  fn=custom_model_changed,
329
  inputs = [custom_model, previous_model],
 
29
  torch_dtype=torch.float16
30
  )
31
 
32
+ def check_use_custom_or_no(value):
33
+ if value is True:
34
+ return gr.update(visible=True)
35
+ else:
36
+ return gr.update(visible=False)
37
+
38
  def get_files(file_paths):
39
  last_files = {} # Dictionary to store the last file for each path
40
 
 
249
  <p style="text-align: center;">Use StableDiffusion XL with <a href="https://huggingface.co/collections/diffusers/sdxl-controlnets-64f9c35846f3f06f5abe351f">Diffusers' SDXL ControlNets</a></p>
250
 
251
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  use_custom_model = gr.Checkbox(label="Use a public custom model ?(optional)", value=False, info="To use a private model, you'll prefer to duplicate the space with your own access token.")
254
 
255
+ with gr.Box(visible=False) as custom_model_box:
256
  with gr.Row():
257
  with gr.Column():
258
  if not is_shared_ui:
 
295
  )
296
  trigger_word = gr.Textbox(label="Trigger word", interactive=False, visible=False)
297
 
298
+ image_in = gr.Image(source="upload", type="filepath")
299
+
300
+ with gr.Row():
301
+
302
+ with gr.Column():
303
+ with gr.Group():
304
+ prompt = gr.Textbox(label="Prompt")
305
+ negative_prompt = gr.Textbox(label="Negative prompt", value="extra digit, fewer digits, cropped, worst quality, low quality, glitch, deformed, mutated, ugly, disfigured")
306
+ with gr.Group():
307
+ guidance_scale = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=7.5)
308
+ inf_steps = gr.Slider(label="Inference Steps", minimum="25", maximum="50", step=1, value=25)
309
+ custom_lora_weight = gr.Slider(label="Custom model weights", minimum=0.1, maximum=0.9, step=0.1, value=0.9)
310
+
311
+ with gr.Column():
312
+ with gr.Group():
313
+ preprocessor = gr.Dropdown(label="Preprocessor", choices=["canny"], value="canny", interactive=False, info="For the moment, only canny is available")
314
+ controlnet_conditioning_scale = gr.Slider(label="Controlnet conditioning Scale", minimum=0.1, maximum=0.9, step=0.01, value=0.5)
315
+ with gr.Group():
316
+ seed = gr.Slider(
317
+ label="Seed",
318
+ info = "-1 denotes a random seed",
319
+ minimum=-1,
320
+ maximum=423538377342,
321
+ step=1,
322
+ value=-1
323
+ )
324
+ last_used_seed = gr.Number(
325
+ label = "Last used seed",
326
+ info = "the seed used in the last generation",
327
+ )
328
+
329
+
330
+
331
  submit_btn = gr.Button("Submit")
332
 
333
  result = gr.Image(label="Result")
334
+
335
+ use_custom_model.change(
336
+ fn = check_custom_or_no,
337
+ inputs =[use_custom_model],
338
+ outputs = [custom_model_box],
339
+ queue = False
340
+ )
341
  custom_model.blur(
342
  fn=custom_model_changed,
343
  inputs = [custom_model, previous_model],