sdxs / demo_webcam_photo.py
soft-boy's picture
Upload folder using huggingface_hub
affe6d7 verified
raw
history blame contribute delete
623 Bytes
import gradio as gr
# Function to display webcam image on canvas
def display_webcam_image(img):
return img
# Gradio app interface
with gr.Blocks() as demo:
gr.Markdown("## Webcam Capture and Display")
# Webcam component
webcam = gr.Image(source="webcam", label="Webcam Capture", streaming=True)
# Canvas to display captured image
canvas = gr.Image(label="Captured Image")
# Button to capture image from webcam and display on canvas
capture_button = gr.Button("Capture Image")
capture_button.click(fn=display_webcam_image, inputs=webcam, outputs=canvas)
# Launch the app
demo.launch()