Spaces:
Sleeping
Sleeping
File size: 1,573 Bytes
1da5d75 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import gradio as gr
def predict(im):
return im["composite"]
with gr.Blocks() as demo:
with gr.Group():
with gr.Row():
im = gr.ImageEditor(
type="numpy",
crop_size="1:1",
elem_id="image_editor",
)
im_preview = gr.Image()
with gr.Group():
with gr.Row():
n_upload = gr.Label(
0,
label="upload",
elem_id="upload",
)
n_change = gr.Label(
0,
label="change",
elem_id="change",
)
n_input = gr.Label(
0,
label="input",
elem_id="input",
)
n_apply = gr.Label(
0,
label="apply",
elem_id="apply",
)
clear_btn = gr.Button("Clear", elem_id="clear")
im.upload(
lambda x: int(x) + 1, outputs=n_upload, inputs=n_upload, show_progress="hidden"
)
im.change(
lambda x: int(x) + 1, outputs=n_change, inputs=n_change, show_progress="hidden"
)
im.input(
lambda x: int(x) + 1, outputs=n_input, inputs=n_input, show_progress="hidden"
)
im.apply(
lambda x: int(x) + 1, outputs=n_apply, inputs=n_apply, show_progress="hidden"
)
im.change(predict, outputs=im_preview, inputs=im, show_progress="hidden")
clear_btn.click(
lambda: None,
None,
im,
)
if __name__ == "__main__":
demo.launch()
|