gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.91k stars 2.57k forks source link

The way to start or stop the Image component for wabcam streaming #1323

Closed JefferyChiang closed 1 year ago

JefferyChiang commented 2 years ago

Is your feature request related to a problem? Please describe.

related to #220 I tried the Image streaming function for webcam, and it can performed real time inference correctly. I'm wondering is there a proper way to trigger start or stop the real time inference?

Describe the solution you'd like

Though I can use another Tab to stop the inference thread, I think it will be more easy to have a button to trigger.

Additional context
Here is my code for testing the Image stream function.

import gradio as gr

def image_mod(image):
    return image.rotate(45)

block = gr.Blocks()
with block:
    with gr.Tabs():
        with gr.TabItem("Train"):
            train = gr.Button("Train")
        with gr.TabItem("Inference"):
            with gr.Row():
                input_image = gr.Image(type='pil',label="Input Image", source="webcam",
                                 streaming=True)
                output_image = gr.Image(label="Output Image")
                input_image.change(image_mod,
                           inputs=input_image,
                           outputs=output_image)
block.launch(show_error=True, inbrowser=True)
pngwn commented 2 years ago

@aliabid94

abidlabs commented 1 year ago

I'll close as this is a duplicate of #3642 and that issue has a bit more activity. We're working on this!