Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
# This function takes the webcam frame, processes it, and sends it back
|
| 5 |
+
def snap_photo(image):
|
| 6 |
+
# The 'image' comes in as a numpy array.
|
| 7 |
+
# You can use OpenCV (cv2) here to edit it if you want!
|
| 8 |
+
return image
|
| 9 |
+
|
| 10 |
+
# Build the web interface
|
| 11 |
+
demo = gr.Interface(
|
| 12 |
+
fn=snap_photo,
|
| 13 |
+
inputs=gr.Image(sources=["webcam"]), # Tells Gradio to open the camera
|
| 14 |
+
outputs="image",
|
| 15 |
+
title="My Online Python Webcam",
|
| 16 |
+
description="Click the camera icon to allow access and snap a photo."
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
# Run the app
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
demo.launch()
|