linoyts HF staff commited on
Commit
ca9e441
1 Parent(s): 0cbf06a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -36,7 +36,7 @@ controlnet_model = 'InstantX/FLUX.1-dev-Controlnet-Canny-alpha'
36
  # t5_slider_controlnet = T5SliderFlux(sd_pipe=pipe_controlnet,device=torch.device("cuda"))
37
 
38
  @spaces.GPU(duration=200)
39
- def generate(slider_x, prompt, seed, recalc_directions, iterations, steps, interm_steps, guidance_scale,
40
  x_concept_1, x_concept_2,
41
  avg_diff_x,
42
  img2img_type = None, img = None,
@@ -55,8 +55,8 @@ def generate(slider_x, prompt, seed, recalc_directions, iterations, steps, inter
55
  x_concept_1, x_concept_2 = slider_x[0], slider_x[1]
56
 
57
  images = []
58
- high_scale = x
59
- low_scale = -1 * x
60
  for i in range(interm_steps):
61
  cur_scale = low_scale + (high_scale - low_scale) * i / (steps - 1)
62
  image = clip_slider.generate(prompt,
@@ -71,7 +71,7 @@ def generate(slider_x, prompt, seed, recalc_directions, iterations, steps, inter
71
 
72
  avg_diff_x = avg_diff.cpu()
73
 
74
- return gr.update(label=comma_concepts_x, interactive=True, value=0), x_concept_1, x_concept_2, avg_diff_x, export_to_gif(images, "clip.gif", fps=5), canvas
75
 
76
  @spaces.GPU
77
  def update_scales(x,prompt,seed, steps, interm_steps, guidance_scale,
@@ -174,7 +174,7 @@ with gr.Blocks(css=css) as demo:
174
  slider_x = gr.Dropdown(label="Slider concept range", allow_custom_value=True, multiselect=True, max_choices=2)
175
  #slider_y = gr.Dropdown(label="Slider Y concept range", allow_custom_value=True, multiselect=True, max_choices=2)
176
  prompt = gr.Textbox(label="Prompt")
177
- x = gr.Slider(minimum=0, value=1.25, step=0.1, maximum=2.5, interactive=False, info="the strength to scale in each direction")
178
  submit = gr.Button("find directions")
179
  with gr.Column():
180
  with gr.Group(elem_id="group"):
@@ -247,7 +247,7 @@ with gr.Blocks(css=css) as demo:
247
  # inputs=[slider_x, slider_y, prompt, seed, iterations, steps, guidance_scale, x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x, avg_diff_y],
248
  # outputs=[x, y, x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x, avg_diff_y, output_image])
249
  submit.click(fn=generate,
250
- inputs=[slider_x, prompt, seed, recalc_directions, iterations, steps, interm_steps, guidance_scale, x_concept_1, x_concept_2, avg_diff_x],
251
  outputs=[x, x_concept_1, x_concept_2, avg_diff_x, output_image, image_seq])
252
 
253
  iterations.change(fn=reset_recalc_directions, outputs=[recalc_directions])
 
36
  # t5_slider_controlnet = T5SliderFlux(sd_pipe=pipe_controlnet,device=torch.device("cuda"))
37
 
38
  @spaces.GPU(duration=200)
39
+ def generate(slider_x, scale, prompt, seed, recalc_directions, iterations, steps, interm_steps, guidance_scale,
40
  x_concept_1, x_concept_2,
41
  avg_diff_x,
42
  img2img_type = None, img = None,
 
55
  x_concept_1, x_concept_2 = slider_x[0], slider_x[1]
56
 
57
  images = []
58
+ high_scale = scale
59
+ low_scale = -1 * scale
60
  for i in range(interm_steps):
61
  cur_scale = low_scale + (high_scale - low_scale) * i / (steps - 1)
62
  image = clip_slider.generate(prompt,
 
71
 
72
  avg_diff_x = avg_diff.cpu()
73
 
74
+ return gr.update(label=comma_concepts_x, interactive=True, value=scale), x_concept_1, x_concept_2, avg_diff_x, export_to_gif(images, "clip.gif", fps=5), canvas
75
 
76
  @spaces.GPU
77
  def update_scales(x,prompt,seed, steps, interm_steps, guidance_scale,
 
174
  slider_x = gr.Dropdown(label="Slider concept range", allow_custom_value=True, multiselect=True, max_choices=2)
175
  #slider_y = gr.Dropdown(label="Slider Y concept range", allow_custom_value=True, multiselect=True, max_choices=2)
176
  prompt = gr.Textbox(label="Prompt")
177
+ x = gr.Slider(minimum=0, value=1.25, step=0.1, maximum=2.5, info="the strength to scale in each direction")
178
  submit = gr.Button("find directions")
179
  with gr.Column():
180
  with gr.Group(elem_id="group"):
 
247
  # inputs=[slider_x, slider_y, prompt, seed, iterations, steps, guidance_scale, x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x, avg_diff_y],
248
  # outputs=[x, y, x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x, avg_diff_y, output_image])
249
  submit.click(fn=generate,
250
+ inputs=[slider_x, x, prompt, seed, recalc_directions, iterations, steps, interm_steps, guidance_scale, x_concept_1, x_concept_2, avg_diff_x],
251
  outputs=[x, x_concept_1, x_concept_2, avg_diff_x, output_image, image_seq])
252
 
253
  iterations.change(fn=reset_recalc_directions, outputs=[recalc_directions])