jamesliu1217 commited on
Commit
aa83627
·
verified ·
1 Parent(s): 014a7de

support cfg_zero*

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -28,7 +28,7 @@ def clear_cache(transformer):
28
 
29
  # Define the Gradio interface
30
  @spaces.GPU()
31
- def single_condition_generate_image(prompt, spatial_img, height, width, seed, control_type):
32
  # Set the control type
33
  if control_type == "Ghibli":
34
  lora_path = os.path.join(lora_base_path, "Ghibli.safetensors")
@@ -47,6 +47,8 @@ def single_condition_generate_image(prompt, spatial_img, height, width, seed, co
47
  subject_images=[],
48
  spatial_images=spatial_imgs,
49
  cond_size=512,
 
 
50
  ).images[0]
51
  clear_cache(pipe.transformer)
52
  return image
@@ -86,13 +88,16 @@ with gr.Blocks() as demo:
86
  seed = gr.Number(label="Seed", value=42)
87
  control_type = gr.Dropdown(choices=control_types, label="Control Type")
88
  single_generate_btn = gr.Button("Generate Image")
 
 
 
89
  with gr.Column():
90
  single_output_image = gr.Image(label="Generated Image")
91
 
92
  # Add examples for Single Condition Generation
93
  gr.Examples(
94
  examples=single_examples,
95
- inputs=[prompt, spatial_img, height, width, seed, control_type],
96
  outputs=single_output_image,
97
  fn=single_condition_generate_image,
98
  cache_examples=False, # 缓存示例结果以加快加载速度
 
28
 
29
  # Define the Gradio interface
30
  @spaces.GPU()
31
+ def single_condition_generate_image(prompt, spatial_img, height, width, seed, control_type, use_zero_init, zero_steps):
32
  # Set the control type
33
  if control_type == "Ghibli":
34
  lora_path = os.path.join(lora_base_path, "Ghibli.safetensors")
 
47
  subject_images=[],
48
  spatial_images=spatial_imgs,
49
  cond_size=512,
50
+ use_zero_init=use_zero_init,
51
+ zero_steps=int(zero_steps)
52
  ).images[0]
53
  clear_cache(pipe.transformer)
54
  return image
 
88
  seed = gr.Number(label="Seed", value=42)
89
  control_type = gr.Dropdown(choices=control_types, label="Control Type")
90
  single_generate_btn = gr.Button("Generate Image")
91
+ use_zero_init = gr.Checkbox(label="Use zero init", default=False)
92
+ zero_steps = gr.Number(label="Zero Init Steps", value=1)
93
+
94
  with gr.Column():
95
  single_output_image = gr.Image(label="Generated Image")
96
 
97
  # Add examples for Single Condition Generation
98
  gr.Examples(
99
  examples=single_examples,
100
+ inputs=[prompt, spatial_img, height, width, seed, control_type, use_zero_init, zero_steps],
101
  outputs=single_output_image,
102
  fn=single_condition_generate_image,
103
  cache_examples=False, # 缓存示例结果以加快加载速度