geyongtao commited on
Commit
e7c5601
·
verified ·
1 Parent(s): 0054d52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -65,11 +65,16 @@ def get_normal_map(image):
65
 
66
 
67
  @spaces.GPU
68
- def generate_(prompt, negative_prompt, canny_image, num_steps, controlnet_conditioning_scale, seed):
69
  generator = torch.Generator("cuda").manual_seed(seed)
70
  images = pipe(
71
- prompt, negative_prompt=negative_prompt, image=canny_image, num_inference_steps=num_steps, controlnet_conditioning_scale=float(controlnet_conditioning_scale),
72
- generator=generator,
 
 
 
 
 
73
  ).images
74
  return images
75
 
@@ -80,7 +85,7 @@ def process(normal_image, prompt, negative_prompt, num_steps, controlnet_conditi
80
  # depth_image = get_depth_map(input_image)
81
  images = generate_(prompt, negative_prompt, normal_image, num_steps, controlnet_conditioning_scale, seed)
82
 
83
- return [normal_image, images[0]]
84
 
85
 
86
  def run_demo():
@@ -111,12 +116,12 @@ def run_demo():
111
  prompt = gr.Textbox(label="Prompt")
112
  negative_prompt = gr.Textbox(visible=False, label="Negative prompt", value="Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers")
113
  num_steps = gr.Slider(label="Number of steps", minimum=25, maximum=100, value=50, step=1)
114
- controlnet_conditioning_scale = gr.Slider(label="ControlNet conditioning scale", minimum=0.1, maximum=2.0, value=1.0, step=0.05)
115
  seed = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, randomize=True,)
116
  run_button = gr.Button(value="Run")
117
 
118
  with gr.Column():
119
- result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery", columns=[2], height='auto')
120
  ips = [input_image, prompt, negative_prompt, num_steps, controlnet_conditioning_scale, seed]
121
 
122
  run_button.click(fn=process, inputs=ips, outputs=[result_gallery])
 
65
 
66
 
67
  @spaces.GPU
68
+ def generate_(prompt, negative_prompt, normal_image, num_steps, controlnet_conditioning_scale, seed):
69
  generator = torch.Generator("cuda").manual_seed(seed)
70
  images = pipe(
71
+ prompt,
72
+ negative_prompt=negative_prompt,
73
+ image=normal_image,
74
+ num_inference_steps=num_steps,
75
+ controlnet_conditioning_scale=float(controlnet_conditioning_scale),
76
+ num_images_per_prompt=4,
77
+ generator=generator,
78
  ).images
79
  return images
80
 
 
85
  # depth_image = get_depth_map(input_image)
86
  images = generate_(prompt, negative_prompt, normal_image, num_steps, controlnet_conditioning_scale, seed)
87
 
88
+ return [images[0], images[1], images[2], images[3]]
89
 
90
 
91
  def run_demo():
 
116
  prompt = gr.Textbox(label="Prompt")
117
  negative_prompt = gr.Textbox(visible=False, label="Negative prompt", value="Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers")
118
  num_steps = gr.Slider(label="Number of steps", minimum=25, maximum=100, value=50, step=1)
119
+ controlnet_conditioning_scale = gr.Slider(label="ControlNet conditioning scale", minimum=0.1, maximum=1.0, value=0.95, step=0.05)
120
  seed = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, randomize=True,)
121
  run_button = gr.Button(value="Run")
122
 
123
  with gr.Column():
124
+ result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery", columns=[2], rows=[2], height='auto')
125
  ips = [input_image, prompt, negative_prompt, num_steps, controlnet_conditioning_scale, seed]
126
 
127
  run_button.click(fn=process, inputs=ips, outputs=[result_gallery])