Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,21 +6,31 @@ def to_black(image):
|
|
6 |
output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
7 |
return output
|
8 |
|
|
|
|
|
|
|
9 |
with gr.Blocks() as demo:
|
10 |
-
gr.Markdown("
|
11 |
with gr.Tabs():
|
12 |
-
with gr.TabItem("
|
13 |
with gr.Row():
|
14 |
image_input = gr.Image()
|
15 |
image_output = gr.Image()
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
image_button.click(to_black, inputs=image_input, outputs=image_output)
|
22 |
video_button.click(to_black, inputs=video_input, outputs=video_output)
|
23 |
-
|
|
|
24 |
demo.launch()
|
25 |
|
26 |
# 启动接口
|
|
|
6 |
output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
7 |
return output
|
8 |
|
9 |
+
def clear_output(input_widget):
|
10 |
+
input_widget = np.array([])
|
11 |
+
|
12 |
with gr.Blocks() as demo:
|
13 |
+
gr.Markdown("Transfer image or video files using this demo.")
|
14 |
with gr.Tabs():
|
15 |
+
with gr.TabItem("Transfer Image"):
|
16 |
with gr.Row():
|
17 |
image_input = gr.Image()
|
18 |
image_output = gr.Image()
|
19 |
+
with gr.Row():
|
20 |
+
image_button = gr.Button("Transfer")
|
21 |
+
clear_image_button = gr.Button("Clear")
|
22 |
+
with gr.TabItem("Transfer Video"):
|
23 |
+
with gr.Row():
|
24 |
+
video_input = gr.Video()
|
25 |
+
video_output = gr.Video()
|
26 |
+
with gr.Row():
|
27 |
+
video_button = gr.Button("Transfer")
|
28 |
+
clear_video_button = gr.Button("Clear")
|
29 |
+
|
30 |
image_button.click(to_black, inputs=image_input, outputs=image_output)
|
31 |
video_button.click(to_black, inputs=video_input, outputs=video_output)
|
32 |
+
clear_image_button.click(clear_output, inputs=image_input,outputs=image_output)
|
33 |
+
clear_video_button.click(clear_output, inputs=video_input,outputs=video_output)
|
34 |
demo.launch()
|
35 |
|
36 |
# 启动接口
|