linoyts HF staff commited on
Commit
9303de6
1 Parent(s): 9724323

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -61,11 +61,11 @@ clip_slider_controlnet = CLIPSliderXL(sd_pipe=pipe_controlnet,device=torch.devic
61
 
62
 
63
  @spaces.GPU(duration=120)
64
- def generate(slider_x, slider_y, prompt, seed, iterations, steps,
65
  x_concept_1, x_concept_2, y_concept_1, y_concept_2,
66
  avg_diff_x_1, avg_diff_x_2,
67
  avg_diff_y_1, avg_diff_y_2,
68
- img2img_type = None, img = None,
69
  controlnet_scale= None, ip_adapter_scale=None):
70
 
71
  start_time = time.time()
@@ -93,11 +93,11 @@ def generate(slider_x, slider_y, prompt, seed, iterations, steps,
93
 
94
  if img2img_type=="controlnet canny" and img is not None:
95
  control_img = process_controlnet_img(img)
96
- image = clip_slider.generate(prompt, image=control_img, controlnet_conditioning_scale =controlnet_scale, scale=0, scale_2nd=0, seed=seed, num_inference_steps=steps, avg_diff=(avg_diff_0,avg_diff_1), avg_diff_2nd=(avg_diff_2nd_0,avg_diff_2nd_1))
97
  elif img2img_type=="ip adapter" and img is not None:
98
- image = clip_slider.generate(prompt, ip_adapter_image=img, scale=0, scale_2nd=0, seed=seed, num_inference_steps=steps, avg_diff=(avg_diff_0,avg_diff_1), avg_diff_2nd=(avg_diff_2nd_0,avg_diff_2nd_1))
99
  else: # text to image
100
- image = clip_slider.generate(prompt, scale=0, scale_2nd=0, seed=seed, num_inference_steps=steps, avg_diff=(avg_diff_0,avg_diff_1), avg_diff_2nd=(avg_diff_2nd_0,avg_diff_2nd_1))
101
 
102
  end_time = time.time()
103
  print(f"generation time: {end_time - start_time:.2f} ms")
@@ -113,7 +113,7 @@ def generate(slider_x, slider_y, prompt, seed, iterations, steps,
113
  return gr.update(label=comma_concepts_x, interactive=True),gr.update(label=comma_concepts_y, interactive=True), x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2, image
114
 
115
  @spaces.GPU
116
- def update_scales(x,y,prompt,seed, steps,
117
  avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2,
118
  img2img_type = None, img = None,
119
  controlnet_scale= None, ip_adapter_scale=None):
@@ -121,11 +121,11 @@ def update_scales(x,y,prompt,seed, steps,
121
  avg_diff_2nd = (avg_diff_y_1.cuda(), avg_diff_y_2.cuda())
122
  if img2img_type=="controlnet canny" and img is not None:
123
  control_img = process_controlnet_img(img)
124
- image = clip_slider.generate(prompt, image=control_img, controlnet_conditioning_scale =controlnet_scale, scale=x, scale_2nd=y, seed=seed, num_inference_steps=steps, avg_diff=avg_diff,avg_diff_2nd=avg_diff_2nd)
125
  elif img2img_type=="ip adapter" and img is not None:
126
- image = clip_slider.generate(prompt, ip_adapter_image=img, scale=x, scale_2nd=y, seed=seed, num_inference_steps=steps, avg_diff=avg_diff,avg_diff_2nd=avg_diff_2nd)
127
  else:
128
- image = clip_slider.generate(prompt, scale=x, scale_2nd=y, seed=seed, num_inference_steps=steps, avg_diff=avg_diff,avg_diff_2nd=avg_diff_2nd)
129
  return image
130
 
131
  @spaces.GPU
 
61
 
62
 
63
  @spaces.GPU(duration=120)
64
+ def generate(slider_x, slider_y, prompt, seed, iterations, steps, guidance_scale,
65
  x_concept_1, x_concept_2, y_concept_1, y_concept_2,
66
  avg_diff_x_1, avg_diff_x_2,
67
  avg_diff_y_1, avg_diff_y_2,
68
+ img2img_type = None, img = None,
69
  controlnet_scale= None, ip_adapter_scale=None):
70
 
71
  start_time = time.time()
 
93
 
94
  if img2img_type=="controlnet canny" and img is not None:
95
  control_img = process_controlnet_img(img)
96
+ image = clip_slider.generate(prompt, guidance_scale=guidance_scale, image=control_img, controlnet_conditioning_scale =controlnet_scale, scale=0, scale_2nd=0, seed=seed, num_inference_steps=steps, avg_diff=(avg_diff_0,avg_diff_1), avg_diff_2nd=(avg_diff_2nd_0,avg_diff_2nd_1))
97
  elif img2img_type=="ip adapter" and img is not None:
98
+ image = clip_slider.generate(prompt, guidance_scale=guidance_scale, ip_adapter_image=img, scale=0, scale_2nd=0, seed=seed, num_inference_steps=steps, avg_diff=(avg_diff_0,avg_diff_1), avg_diff_2nd=(avg_diff_2nd_0,avg_diff_2nd_1))
99
  else: # text to image
100
+ image = clip_slider.generate(prompt, guidance_scale=guidance_scale, scale=0, scale_2nd=0, seed=seed, num_inference_steps=steps, avg_diff=(avg_diff_0,avg_diff_1), avg_diff_2nd=(avg_diff_2nd_0,avg_diff_2nd_1))
101
 
102
  end_time = time.time()
103
  print(f"generation time: {end_time - start_time:.2f} ms")
 
113
  return gr.update(label=comma_concepts_x, interactive=True),gr.update(label=comma_concepts_y, interactive=True), x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2, image
114
 
115
  @spaces.GPU
116
+ def update_scales(x,y,prompt,seed, steps, guidance_scale,
117
  avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2,
118
  img2img_type = None, img = None,
119
  controlnet_scale= None, ip_adapter_scale=None):
 
121
  avg_diff_2nd = (avg_diff_y_1.cuda(), avg_diff_y_2.cuda())
122
  if img2img_type=="controlnet canny" and img is not None:
123
  control_img = process_controlnet_img(img)
124
+ image = clip_slider.generate(prompt, guidance_scale=guidance_scale, image=control_img, controlnet_conditioning_scale =controlnet_scale, scale=x, scale_2nd=y, seed=seed, num_inference_steps=steps, avg_diff=avg_diff,avg_diff_2nd=avg_diff_2nd)
125
  elif img2img_type=="ip adapter" and img is not None:
126
+ image = clip_slider.generate(prompt, guidance_scale=guidance_scale, ip_adapter_image=img, scale=x, scale_2nd=y, seed=seed, num_inference_steps=steps, avg_diff=avg_diff,avg_diff_2nd=avg_diff_2nd)
127
  else:
128
+ image = clip_slider.generate(prompt, guidance_scale=guidance_scale, scale=x, scale_2nd=y, seed=seed, num_inference_steps=steps, avg_diff=avg_diff,avg_diff_2nd=avg_diff_2nd)
129
  return image
130
 
131
  @spaces.GPU