n42 commited on
Commit
3b2835d
·
1 Parent(s): da67542

make refiner de-selectable

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -11,6 +11,12 @@ def device_change(device, config):
11
 
12
  return config, str(config), assemble_code(config)
13
 
 
 
 
 
 
 
14
  def models_change(model, scheduler, config):
15
 
16
  config = set_config(config, 'model', model)
@@ -210,7 +216,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
210
  with gr.Row():
211
  with gr.Column(scale=1):
212
  in_use_safetensors = gr.Radio(label="Use safe tensors:", choices=["True", "False"], interactive=False)
213
- in_model_refiner = gr.Textbox(value="", label="Refiner")
214
  with gr.Column(scale=1):
215
  in_safety_checker = gr.Radio(label="Enable safety checker:", value=config.value["safety_checker"], choices=["True", "False"])
216
  in_requires_safety_checker = gr.Radio(label="Requires safety checker:", value=config.value["requires_safety_checker"], choices=["True", "False"])
@@ -229,7 +235,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
229
  in_prompt = gr.TextArea(label="Prompt", value=config.value["prompt"])
230
  in_negative_prompt = gr.TextArea(label="Negative prompt", value=config.value["negative_prompt"])
231
  with gr.Row():
232
- in_inference_steps = gr.Number(label="Inference steps", value=config.value["inference_steps"])
233
  in_manual_seed = gr.Number(label="Manual seed", value=config.value["manual_seed"], info="Set this to -1 or leave it empty to randomly generate an image. A fixed value will result in a similar image for every run")
234
  in_guidance_scale = gr.Slider(minimum=0, maximum=1, step=0.01, label="Guidance Scale", value=config.value["guidance_scale"], info="A low guidance scale leads to a faster inference time, with the drawback that negative prompts don’t have any effect on the denoising process.")
235
 
@@ -251,6 +257,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
251
  in_allow_tensorfloat32.change(tensorfloat32_change, inputs=[in_allow_tensorfloat32, config], outputs=[config, out_config, out_code])
252
  in_variant.change(variant_change, inputs=[in_variant, config], outputs=[config, out_config, out_code])
253
  in_models.change(models_change, inputs=[in_models, in_schedulers, config], outputs=[out_model_description, in_model_refiner, in_use_safetensors, in_schedulers, config, out_config, out_code])
 
254
  in_safety_checker.change(safety_checker_change, inputs=[in_safety_checker, config], outputs=[config, out_config, out_code])
255
  in_requires_safety_checker.change(requires_safety_checker_change, inputs=[in_requires_safety_checker, config], outputs=[config, out_config, out_code])
256
  in_schedulers.change(schedulers_change, inputs=[in_schedulers, config], outputs=[out_scheduler_description, config, out_config, out_code])
 
11
 
12
  return config, str(config), assemble_code(config)
13
 
14
+ def model_refiner_change(refiner, config):
15
+
16
+ config = set_config(config, 'refiner', refiner)
17
+
18
+ return config, str(config), assemble_code(config)
19
+
20
  def models_change(model, scheduler, config):
21
 
22
  config = set_config(config, 'model', model)
 
216
  with gr.Row():
217
  with gr.Column(scale=1):
218
  in_use_safetensors = gr.Radio(label="Use safe tensors:", choices=["True", "False"], interactive=False)
219
+ in_model_refiner = gr.Dropdown(value="", choices=[""], label="Refiner", allow_custom_value=True, multiselect=False)
220
  with gr.Column(scale=1):
221
  in_safety_checker = gr.Radio(label="Enable safety checker:", value=config.value["safety_checker"], choices=["True", "False"])
222
  in_requires_safety_checker = gr.Radio(label="Requires safety checker:", value=config.value["requires_safety_checker"], choices=["True", "False"])
 
235
  in_prompt = gr.TextArea(label="Prompt", value=config.value["prompt"])
236
  in_negative_prompt = gr.TextArea(label="Negative prompt", value=config.value["negative_prompt"])
237
  with gr.Row():
238
+ in_inference_steps = gr.Number(label="Inference steps", value=config.value["inference_steps"], info="Each step improves the final result but also results in higher computation")
239
  in_manual_seed = gr.Number(label="Manual seed", value=config.value["manual_seed"], info="Set this to -1 or leave it empty to randomly generate an image. A fixed value will result in a similar image for every run")
240
  in_guidance_scale = gr.Slider(minimum=0, maximum=1, step=0.01, label="Guidance Scale", value=config.value["guidance_scale"], info="A low guidance scale leads to a faster inference time, with the drawback that negative prompts don’t have any effect on the denoising process.")
241
 
 
257
  in_allow_tensorfloat32.change(tensorfloat32_change, inputs=[in_allow_tensorfloat32, config], outputs=[config, out_config, out_code])
258
  in_variant.change(variant_change, inputs=[in_variant, config], outputs=[config, out_config, out_code])
259
  in_models.change(models_change, inputs=[in_models, in_schedulers, config], outputs=[out_model_description, in_model_refiner, in_use_safetensors, in_schedulers, config, out_config, out_code])
260
+ in_model_refiner.change(model_refiner_change, inputs=[in_model_refiner, config], outputs=[config, out_config, out_code])
261
  in_safety_checker.change(safety_checker_change, inputs=[in_safety_checker, config], outputs=[config, out_config, out_code])
262
  in_requires_safety_checker.change(requires_safety_checker_change, inputs=[in_requires_safety_checker, config], outputs=[config, out_config, out_code])
263
  in_schedulers.change(schedulers_change, inputs=[in_schedulers, config], outputs=[out_scheduler_description, config, out_config, out_code])