improved
Browse files
run.py
CHANGED
@@ -1,16 +1,25 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
|
|
|
|
3 |
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
|
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
)
|
14 |
|
15 |
if __name__ == "__main__":
|
16 |
-
demo.launch(
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
from time import sleep
|
4 |
|
5 |
+
def flip_periodically(im, interval_ms=100):
|
6 |
+
"""
|
7 |
+
Flips the image periodically with the given interval.
|
8 |
|
9 |
+
Args:
|
10 |
+
im: The input image.
|
11 |
+
interval_ms: The interval in milliseconds between flips.
|
12 |
|
13 |
+
Returns:
|
14 |
+
The flipped image.
|
15 |
+
"""
|
16 |
+
sleep(interval_ms / 1000) # Convert milliseconds to seconds
|
17 |
+
return np.flipud(im)
|
18 |
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
inp = gr.Image(sources=["webcam"], streaming=True)
|
21 |
+
out = gr.Image()
|
22 |
+
inp.stream(flip_periodically, inputs=inp, outputs=out)
|
|
|
23 |
|
24 |
if __name__ == "__main__":
|
25 |
+
demo.launch()
|