|
import gradio as gr |
|
import numpy as np |
|
from time import sleep |
|
|
|
def flip_periodically(im, interval_ms=100): |
|
""" |
|
Flips the image periodically with the given interval. |
|
|
|
Args: |
|
im: The input image. |
|
interval_ms: The interval in milliseconds between flips. |
|
|
|
Returns: |
|
The flipped image. |
|
""" |
|
sleep(interval_ms / 1000) |
|
return np.flipud(im) |
|
|
|
with gr.Blocks() as demo: |
|
inp = gr.Image(sources=["webcam"], streaming=True) |
|
out = gr.Image() |
|
inp.stream(flip_periodically, inputs=inp, outputs=out) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |