Spaces:
Running
on
Zero
Running
on
Zero
added sliders
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from torchvision import transforms
|
|
| 9 |
# from huggingface_hub import login
|
| 10 |
# login()
|
| 11 |
|
| 12 |
-
controlnet_conditioning_scale = 1.0
|
| 13 |
|
| 14 |
controlnet = ControlNetModel.from_pretrained(
|
| 15 |
"briaai/ControlNet-Canny",
|
|
@@ -46,13 +46,13 @@ def get_canny_filter(image):
|
|
| 46 |
canny_image = Image.fromarray(image)
|
| 47 |
return canny_image
|
| 48 |
|
| 49 |
-
def process(input_image, prompt):
|
| 50 |
# resize input_image to 1024x1024
|
| 51 |
input_image = resize_image(input_image)
|
| 52 |
|
| 53 |
canny_image = get_canny_filter(input_image)
|
| 54 |
images = pipe(
|
| 55 |
-
prompt,image=canny_image, controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 56 |
).images
|
| 57 |
|
| 58 |
return [canny_image,images[0]]
|
|
@@ -70,12 +70,14 @@ with block:
|
|
| 70 |
with gr.Column():
|
| 71 |
input_image = gr.Image(sources=None, type="pil") # None for upload, ctrl+v and webcam
|
| 72 |
prompt = gr.Textbox(label="Prompt")
|
|
|
|
|
|
|
| 73 |
run_button = gr.Button(value="Run")
|
| 74 |
|
| 75 |
|
| 76 |
with gr.Column():
|
| 77 |
result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery", columns=[2], height='auto')
|
| 78 |
-
ips = [input_image, prompt]
|
| 79 |
run_button.click(fn=process, inputs=ips, outputs=[result_gallery])
|
| 80 |
|
| 81 |
block.launch(debug = True)
|
|
|
|
| 9 |
# from huggingface_hub import login
|
| 10 |
# login()
|
| 11 |
|
| 12 |
+
# controlnet_conditioning_scale = 1.0
|
| 13 |
|
| 14 |
controlnet = ControlNetModel.from_pretrained(
|
| 15 |
"briaai/ControlNet-Canny",
|
|
|
|
| 46 |
canny_image = Image.fromarray(image)
|
| 47 |
return canny_image
|
| 48 |
|
| 49 |
+
def process(input_image, prompt, num_steps, controlnet_conditioning_scale):
|
| 50 |
# resize input_image to 1024x1024
|
| 51 |
input_image = resize_image(input_image)
|
| 52 |
|
| 53 |
canny_image = get_canny_filter(input_image)
|
| 54 |
images = pipe(
|
| 55 |
+
prompt,image=canny_image, num_inference_steps=num_steps, controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 56 |
).images
|
| 57 |
|
| 58 |
return [canny_image,images[0]]
|
|
|
|
| 70 |
with gr.Column():
|
| 71 |
input_image = gr.Image(sources=None, type="pil") # None for upload, ctrl+v and webcam
|
| 72 |
prompt = gr.Textbox(label="Prompt")
|
| 73 |
+
num_steps = gr.Slider(label="Number of steps", minimum=25, maximum=100, value=50, step=1)
|
| 74 |
+
controlnet_conditioning_scale = gr.Slider(label="ControlNet conditioning scale", minimum=0.1, maximum=2.0, value=1.0, step=0.05)
|
| 75 |
run_button = gr.Button(value="Run")
|
| 76 |
|
| 77 |
|
| 78 |
with gr.Column():
|
| 79 |
result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery", columns=[2], height='auto')
|
| 80 |
+
ips = [input_image, prompt, num_steps, controlnet_conditioning_scale]
|
| 81 |
run_button.click(fn=process, inputs=ips, outputs=[result_gallery])
|
| 82 |
|
| 83 |
block.launch(debug = True)
|