Spaces:
Configuration error
Configuration error
de
Browse files
app.py
CHANGED
|
@@ -89,24 +89,23 @@ def resize_image_old(image):
|
|
| 89 |
|
| 90 |
|
| 91 |
@spaces.GPU
|
| 92 |
-
def generate_(prompt, negative_prompt, pose_image, input_image, controlnet_conditioning_scale):
|
| 93 |
-
generator = torch.Generator()
|
| 94 |
-
generator.manual_seed(random.randint(0, 2147483647))
|
| 95 |
images = pipe(
|
| 96 |
-
prompt, negative_prompt=negative_prompt, image=pose_image, num_inference_steps=
|
| 97 |
generator=generator, height=input_image.size[1], width=input_image.size[0],
|
| 98 |
).images
|
| 99 |
return images
|
| 100 |
|
| 101 |
@spaces.GPU
|
| 102 |
-
def process(input_image, prompt, negative_prompt, controlnet_conditioning_scale):
|
| 103 |
|
| 104 |
# resize input_image to 1024x1024
|
| 105 |
input_image = resize_image(input_image)
|
| 106 |
|
| 107 |
pose_image = openpose(input_image, include_body=True, include_hand=True, include_face=True)
|
| 108 |
|
| 109 |
-
images = generate_(prompt, negative_prompt, pose_image, input_image, controlnet_conditioning_scale)
|
| 110 |
|
| 111 |
return [pose_image,images[0]]
|
| 112 |
|
|
@@ -247,12 +246,21 @@ block = gr.Blocks().queue()
|
|
| 247 |
|
| 248 |
with block:
|
| 249 |
gr.Markdown("## BRIA 2.3 ControlNet Pose")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
with gr.Row():
|
| 251 |
with gr.Column():
|
| 252 |
input_image = gr.Image(sources=None, type="pil") # None for upload, ctrl+v and webcam
|
| 253 |
prompt = gr.Textbox(label="Prompt")
|
| 254 |
negative_prompt = gr.Textbox(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")
|
|
|
|
| 255 |
controlnet_conditioning_scale = gr.Slider(label="ControlNet conditioning scale", minimum=0.1, maximum=2.0, value=1.0, step=0.05)
|
|
|
|
| 256 |
run_button = gr.Button(value="Run")
|
| 257 |
|
| 258 |
with gr.Column():
|
|
@@ -260,7 +268,8 @@ with block:
|
|
| 260 |
pose_image_output = gr.Image(label="Pose Image", type="pil", interactive=False)
|
| 261 |
generated_image_output = gr.Image(label="Generated Image", type="pil", interactive=False)
|
| 262 |
|
| 263 |
-
|
|
|
|
| 264 |
|
| 265 |
|
| 266 |
block.launch(debug = True)
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
@spaces.GPU
|
| 92 |
+
def generate_(prompt, negative_prompt, pose_image, input_image, num_steps, controlnet_conditioning_scale, seed):
|
| 93 |
+
generator = torch.Generator("cuda").manual_seed(seed)
|
|
|
|
| 94 |
images = pipe(
|
| 95 |
+
prompt, negative_prompt=negative_prompt, image=pose_image, num_inference_steps=num_steps, controlnet_conditioning_scale=float(controlnet_conditioning_scale),
|
| 96 |
generator=generator, height=input_image.size[1], width=input_image.size[0],
|
| 97 |
).images
|
| 98 |
return images
|
| 99 |
|
| 100 |
@spaces.GPU
|
| 101 |
+
def process(input_image, prompt, negative_prompt, num_steps, controlnet_conditioning_scale, seed):
|
| 102 |
|
| 103 |
# resize input_image to 1024x1024
|
| 104 |
input_image = resize_image(input_image)
|
| 105 |
|
| 106 |
pose_image = openpose(input_image, include_body=True, include_hand=True, include_face=True)
|
| 107 |
|
| 108 |
+
images = generate_(prompt, negative_prompt, pose_image, input_image, num_steps, controlnet_conditioning_scale, seed)
|
| 109 |
|
| 110 |
return [pose_image,images[0]]
|
| 111 |
|
|
|
|
| 246 |
|
| 247 |
with block:
|
| 248 |
gr.Markdown("## BRIA 2.3 ControlNet Pose")
|
| 249 |
+
gr.HTML('''
|
| 250 |
+
<p style="margin-bottom: 10px; font-size: 94%">
|
| 251 |
+
This is a demo for ControlNet Pose that using
|
| 252 |
+
<a href="https://huggingface.co/briaai/BRIA-2.3" target="_blank">BRIA 2.3 text-to-image model</a> as backbone.
|
| 253 |
+
Trained on licensed data, BRIA 2.3 provide full legal liability coverage for copyright and privacy infringement.
|
| 254 |
+
</p>
|
| 255 |
+
''')
|
| 256 |
with gr.Row():
|
| 257 |
with gr.Column():
|
| 258 |
input_image = gr.Image(sources=None, type="pil") # None for upload, ctrl+v and webcam
|
| 259 |
prompt = gr.Textbox(label="Prompt")
|
| 260 |
negative_prompt = gr.Textbox(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")
|
| 261 |
+
num_steps = gr.Slider(label="Number of steps", minimum=25, maximum=100, value=50, step=1)
|
| 262 |
controlnet_conditioning_scale = gr.Slider(label="ControlNet conditioning scale", minimum=0.1, maximum=2.0, value=1.0, step=0.05)
|
| 263 |
+
seed = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, randomize=True,)
|
| 264 |
run_button = gr.Button(value="Run")
|
| 265 |
|
| 266 |
with gr.Column():
|
|
|
|
| 268 |
pose_image_output = gr.Image(label="Pose Image", type="pil", interactive=False)
|
| 269 |
generated_image_output = gr.Image(label="Generated Image", type="pil", interactive=False)
|
| 270 |
|
| 271 |
+
ips = [input_image, prompt, negative_prompt, num_steps, controlnet_conditioning_scale, seed]
|
| 272 |
+
run_button.click(fn=process, inputs=ips, outputs=[pose_image_output, generated_image_output])
|
| 273 |
|
| 274 |
|
| 275 |
block.launch(debug = True)
|