Spaces:
Runtime error
Runtime error
gradio
Browse files- Dockerfile +1 -1
- app.py +22 -0
Dockerfile
CHANGED
@@ -20,4 +20,4 @@ EXPOSE 8501
|
|
20 |
|
21 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
22 |
|
23 |
-
|
|
|
20 |
|
21 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
22 |
|
23 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
def apply_filter(frame):
|
6 |
+
# frame is a numpy array (H, W, 3) in RGB
|
7 |
+
img = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
|
8 |
+
|
9 |
+
# Example filter: invert colors
|
10 |
+
img = cv2.bitwise_not(img)
|
11 |
+
|
12 |
+
# Convert back to RGB for display
|
13 |
+
return cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
14 |
+
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=apply_filter,
|
17 |
+
inputs=gr.Video(source="webcam", streaming=True),
|
18 |
+
outputs="video",
|
19 |
+
live=True,
|
20 |
+
)
|
21 |
+
|
22 |
+
iface.launch()
|