Spaces:
Build error
Build error
| import gradio as gr | |
| from PIL import Image | |
| def infer_segmentation(prompt, negative_prompt, image): | |
| # implement your inference function here | |
| im = Image.open("cat_image.jpeg") | |
| return im | |
| def infer_canny(prompt, negative_prompt, image): | |
| # implement your inference function here | |
| im = Image.open("cat_image.jpeg") | |
| return im | |
| with gr.Blocks(theme='gradio/soft') as demo: | |
| gr.Markdown("## Stable Diffusion with Different Controls") | |
| gr.Markdown("In this app, you can find different ControlNets with different filters. ") | |
| with gr.Tab("ControlNet on Canny Filter "): | |
| prompt_input_canny = gr.Textbox(label="Prompt") | |
| negative_prompt_canny = gr.Textbox(label="Negative Prompt") | |
| canny_input = gr.Image(label="Input Image") | |
| canny_output = gr.Image(label="Output Image") | |
| submit_btn = gr.Button(value = "Submit") | |
| canny_inputs = [prompt_input_canny, negative_prompt_canny, canny_input] | |
| submit_btn.click(fn=infer_canny, inputs=canny_inputs, outputs=[canny_output]) | |
| with gr.Tab("ControlNet with Semantic Segmentation"): | |
| prompt_input_seg = gr.Textbox(label="Prompt") | |
| negative_prompt_seg = gr.Textbox(label="Negative Prompt") | |
| seg_input = gr.Image(label="Image") | |
| seg_output = gr.Image(label="Output Image") | |
| submit_btn = gr.Button(value = "Submit") | |
| seg_inputs = [prompt_input_seg, negative_prompt_seg, seg_input] | |
| submit_btn.click(fn=infer_segmentation, inputs=seg_inputs, outputs=[seg_output]) | |
| demo.launch() |