lakshya-raj commited on
Commit
99ca077
·
1 Parent(s): f62dfcf

v1.0.2-Test Webstream using start stop button

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -4,11 +4,36 @@ import numpy as np
4
  def flip(im):
5
  return np.flipud(im)
6
 
 
 
 
 
 
 
7
  demo = gr.Interface(
8
  flip,
9
  gr.Image(source="webcam", streaming=True),
10
  "image",
11
- live=True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  )
13
  demo.launch()
14
 
 
4
  def flip(im):
5
  return np.flipud(im)
6
 
7
+ def start_stop_stream():
8
+ if demo.interface_live:
9
+ demo.interface_live = False
10
+ else:
11
+ demo.interface_live = True
12
+
13
  demo = gr.Interface(
14
  flip,
15
  gr.Image(source="webcam", streaming=True),
16
  "image",
17
+ live=True,
18
+ show_input=True,
19
+ show_output=True,
20
+ examples=[["image1.jpg"], ["image2.jpg"]],
21
+ title="Image Flipper",
22
+ description="Flip an image vertically",
23
+ theme="default",
24
+ layout="vertical",
25
+ allow_flagging=False,
26
+ allow_screenshot=False,
27
+ allow_download=False,
28
+ allow_share=False,
29
+ allow_duplicate=False,
30
+ allow_newline_in_output=False,
31
+ allow_output_upload=False,
32
+ allow_input_upload=False,
33
+ input_columns=1,
34
+ input_rows=1,
35
+ button_text="Start/Stop Streaming",
36
+ button_fn=start_stop_stream
37
  )
38
  demo.launch()
39