1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] gradio how to hide a webcam interface

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024 às 22:32.

  1. Stack

    Stack Membro Participativo

    In Python 3.10 with gradio 4.44.1 on Windows 10, I struggle to hide a webcam "live" image with a button click. Currently, I am stuck with the following code:

    import gradio as gr
    import numpy as np

    def flip(im):
    return np.flipud(im)

    cam = gr.Image(sources=["webcam"], streaming=True)

    with gr.Blocks(css="footer {visibility: hidden}") as demo:
    webcam = gr.Interface(
    flip,
    inputs=cam,
    outputs=None, # "image",
    live=True,
    clear_btn=None,
    show_progress='hidden'
    )
    hide_btn = gr.Button("Hide")

    def hide_cam(webcam):
    webcam.visible = False
    return webcam

    hide_btn.click(fn=hide_cam, inputs=webcam, outputs=webcam)
    demo.launch()


    After clicking the button the error gradio.exceptions.InvalidComponentError: <class 'gradio.interface.Interface'> Component not a valid input component. shows up.

    Can anyone please give me a hint, how to toggle the webcam visibility?

    Continue reading...

Compartilhe esta Página