| import gradio as gr | |
| import numpy as np | |
| def flip(im): | |
| return np.flipud(im) | |
| def start_stop_stream(): | |
| if demo.interface_live: | |
| demo.interface_live = False | |
| else: | |
| demo.interface_live = True | |
| demo = gr.Interface( | |
| flip, | |
| gr.Image(source="webcam", streaming=True), | |
| "image", | |
| live=True, | |
| show_input=True, | |
| show_output=True, | |
| title="Image Flipper", | |
| description="Flip an image vertically", | |
| theme="default", | |
| layout="vertical", | |
| allow_flagging=False, | |
| allow_screenshot=False, | |
| allow_download=False, | |
| allow_share=False, | |
| allow_duplicate=False, | |
| allow_newline_in_output=False, | |
| allow_output_upload=False, | |
| allow_input_upload=False, | |
| input_columns=1, | |
| input_rows=1, | |
| button_text="Start/Stop Streaming", | |
| button_fn=start_stop_stream | |
| ) | |
| demo.launch() | |