noamholz commited on
Commit
b41cba1
·
1 Parent(s): 816c1e3
Files changed (1) hide show
  1. run.py +18 -9
run.py CHANGED
@@ -1,16 +1,25 @@
1
-
2
  import gradio as gr
 
 
3
 
 
 
 
4
 
5
- def snap(image, video):
6
- return [image, video]
 
7
 
 
 
 
 
 
8
 
9
- demo = gr.Interface(
10
- snap,
11
- [gr.Image(sources=['webcam'])],
12
- ["image", "video"],
13
- )
14
 
15
  if __name__ == "__main__":
16
- demo.launch(share=False)
 
 
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()