CUHKWilliam commited on
Commit
e044413
·
1 Parent(s): a26cb5e
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -1,7 +1,31 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello" + name
5
 
6
- demo = gr.Interface(fn=greet, inputs='text', outputs='text')
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import time
3
 
 
 
4
 
5
+ def sleep(im):
6
+ time.sleep(5)
7
+ return [im["background"], im["layers"][0], im["layers"][1], im["composite"]]
8
+
9
+
10
+ def predict(im):
11
+ return im["composite"]
12
+
13
+
14
+ with gr.Blocks() as demo:
15
+ with gr.Row():
16
+ im = gr.ImageEditor(
17
+ type="numpy",
18
+ crop_size="1:1",
19
+ )
20
+ im_preview = gr.Image()
21
+ n_upload = gr.Number(0, label="Number of upload events", step=1)
22
+ n_change = gr.Number(0, label="Number of change events", step=1)
23
+ n_input = gr.Number(0, label="Number of input events", step=1)
24
+
25
+ im.upload(lambda x: x + 1, outputs=n_upload, inputs=n_upload)
26
+ im.change(lambda x: x + 1, outputs=n_change, inputs=n_change)
27
+ im.input(lambda x: x + 1, outputs=n_input, inputs=n_input)
28
+ im.change(predict, outputs=im_preview, inputs=im, show_progress="hidden")
29
+
30
+ if __name__ == "__main__":
31
+ demo.launch()