Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
import gradio as gr | |
import imageio | |
def dummy(img): | |
imageio.imwrite("output_image.png", img["mask"]) | |
return img["image"], img["mask"] | |
# 这里需要一个图片的路径或者是一个URL | |
default_image_path = "https://api.telegram.org/file/bot6584991592:AAGNv881SaUQd9zmDs2OzQEpKD7nrMkzMpk/photos/file_3648.jpg" | |
with gr.Blocks() as demo: | |
with gr.Row(): | |
# 使用 default 参数来设置默认图片 | |
img = gr.Image(tool="sketch", label="base image", show_label=True, default=default_image_path) | |
with gr.Row(): | |
img1 = gr.Image() | |
img2 = gr.Image(label="mask image", show_label=True) | |
btn = gr.Button() | |
btn.click(dummy, img, [img1, img2]) | |
demo.launch(debug=True) |