zhiweili commited on
Commit
87bd420
1 Parent(s): c978d99

add output size option

Browse files
Files changed (3) hide show
  1. app_base.py +7 -6
  2. inversion_run_base.py +2 -0
  3. segment_utils.py +2 -2
app_base.py CHANGED
@@ -117,12 +117,13 @@ def create_demo() -> gr.Blocks:
117
  num_steps = gr.Slider(minimum=1, maximum=100, value=20, step=1, label="Num Steps")
118
  start_step = gr.Slider(minimum=1, maximum=100, value=15, step=1, label="Start Step")
119
  with gr.Accordion("Advanced Options", open=False):
120
- guidance_scale = gr.Slider(minimum=0, maximum=20, value=0, step=0.5, label="Guidance Scale")
121
- generate_size = gr.Number(label="Generate Size", value=1024)
 
122
  mask_expansion = gr.Number(label="Mask Expansion", value=50, visible=True)
123
  mask_dilation = gr.Slider(minimum=0, maximum=10, value=2, step=1, label="Mask Dilation")
124
- enhance_face = gr.Checkbox(label="Enhance Face", value=False)
125
- adapter_weights = gr.Slider(minimum=0, maximum=1, value=0.5, step=0.1, label="Adapter Weights", visible=True)
126
  with gr.Column():
127
  seed = gr.Number(label="Seed", value=8)
128
  w1 = gr.Number(label="W1", value=2)
@@ -142,11 +143,11 @@ def create_demo() -> gr.Blocks:
142
 
143
  g_btn.click(
144
  fn=segment_image,
145
- inputs=[input_image, category, generate_size, mask_expansion, mask_dilation],
146
  outputs=[origin_area_image, croper],
147
  ).success(
148
  fn=image_to_image,
149
- inputs=[origin_area_image, input_image_prompt, edit_prompt,seed,w1, num_steps, start_step, guidance_scale, generate_size, adapter_weights, enhance_face],
150
  outputs=[enhanced_image, generated_image, generated_cost],
151
  ).success(
152
  fn=restore_result,
 
117
  num_steps = gr.Slider(minimum=1, maximum=100, value=20, step=1, label="Num Steps")
118
  start_step = gr.Slider(minimum=1, maximum=100, value=15, step=1, label="Start Step")
119
  with gr.Accordion("Advanced Options", open=False):
120
+ guidance_scale = gr.Slider(minimum=0, maximum=20, value=1, step=0.5, label="Guidance Scale")
121
+ input_size = gr.Number(label="Generate Size", value=1024)
122
+ output_size = gr.Number(label="Output Size", value=512)
123
  mask_expansion = gr.Number(label="Mask Expansion", value=50, visible=True)
124
  mask_dilation = gr.Slider(minimum=0, maximum=10, value=2, step=1, label="Mask Dilation")
125
+ enhance_face = gr.Checkbox(label="Enhance Face", value=True)
126
+ adapter_weights = gr.Slider(minimum=0, maximum=1, value=0.5, step=0.1, label="Adapter Weights", visible=False)
127
  with gr.Column():
128
  seed = gr.Number(label="Seed", value=8)
129
  w1 = gr.Number(label="W1", value=2)
 
143
 
144
  g_btn.click(
145
  fn=segment_image,
146
+ inputs=[input_image, category, input_size, mask_expansion, mask_dilation],
147
  outputs=[origin_area_image, croper],
148
  ).success(
149
  fn=image_to_image,
150
+ inputs=[origin_area_image, input_image_prompt, edit_prompt,seed,w1, num_steps, start_step, guidance_scale, output_size, adapter_weights, enhance_face],
151
  outputs=[enhanced_image, generated_image, generated_cost],
152
  ).success(
153
  fn=restore_result,
inversion_run_base.py CHANGED
@@ -114,6 +114,8 @@ def run(
114
  generator=generator,
115
  denoising_start=denoising_start,
116
  strength=0,
 
 
117
  )
118
 
119
  x_0_image = input_image
 
114
  generator=generator,
115
  denoising_start=denoising_start,
116
  strength=0,
117
+ height=generate_size,
118
+ width=generate_size,
119
  )
120
 
121
  x_0_image = input_image
segment_utils.py CHANGED
@@ -34,8 +34,8 @@ def restore_result(croper, category, generated_image):
34
 
35
  return restored_image, path
36
 
37
- def segment_image(input_image, category, generate_size, mask_expansion, mask_dilation):
38
- mask_size = int(generate_size)
39
  mask_expansion = int(mask_expansion)
40
 
41
  image = mp.Image(image_format=mp.ImageFormat.SRGB, data=np.asarray(input_image))
 
34
 
35
  return restored_image, path
36
 
37
+ def segment_image(input_image, category, input_size, mask_expansion, mask_dilation):
38
+ mask_size = int(input_size)
39
  mask_expansion = int(mask_expansion)
40
 
41
  image = mp.Image(image_format=mp.ImageFormat.SRGB, data=np.asarray(input_image))