Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
def process_image(img):
|
| 6 |
+
# Process the image and overlay it onto the background
|
| 7 |
+
img = cv2.resize(img, (480, 360))
|
| 8 |
+
background = cv2.imread('background.png') # This should be the path to your background image
|
| 9 |
+
background[110:110+360, 26:26+480] = img
|
| 10 |
+
return background
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=process_image,
|
| 14 |
+
inputs=gr.inputs.Image(shape=(360, 480), source="webcam"),
|
| 15 |
+
outputs="image",
|
| 16 |
+
live=True,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
iface.launch(inline=False)
|