mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
* stuff * fix layrs * add changeset * lint * ensure a default image can be passed when sources list is empty * fix loading status * add layers option to disable layer ui * types * fix tests * cleanup * cleanup * notebooks * fix composite * fix * fix trash icon * add changeset * fix layer bg * fix error display * notebooks --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2.4 KiB
2.4 KiB
Gradio Demo: image_editor_events¶
In [ ]:
!pip install -q gradio
In [ ]:
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()