Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,16 @@ import numpy as np
|
|
2 |
import gradio as gr
|
3 |
import cv2
|
4 |
|
5 |
-
def to_black(image):
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def clear_output(input_widget):
|
10 |
input_widget = np.array([])
|
@@ -17,18 +24,20 @@ with gr.Blocks() as demo:
|
|
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()
|
|
|
2 |
import gradio as gr
|
3 |
import cv2
|
4 |
|
5 |
+
def to_black(image, transfer_style):
|
6 |
+
if transfer_style == "Hayao":
|
7 |
+
output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 转换为灰度图像
|
8 |
+
return output
|
9 |
+
elif transfer_style == "Shinkai":
|
10 |
+
return image
|
11 |
+
elif transfer_style == "Kon Satoshi":
|
12 |
+
return image
|
13 |
+
else:
|
14 |
+
return image
|
15 |
|
16 |
def clear_output(input_widget):
|
17 |
input_widget = np.array([])
|
|
|
24 |
image_input = gr.Image()
|
25 |
image_output = gr.Image()
|
26 |
with gr.Row():
|
27 |
+
image_dropdown = gr.Dropdown(label="Transfer Style",choices=["Hayao", "Shinkai", "Kon Satoshi"])
|
28 |
image_button = gr.Button("Transfer")
|
29 |
clear_image_button = gr.Button("Clear")
|
30 |
with gr.TabItem("Transfer Video"):
|
31 |
with gr.Row():
|
32 |
+
video_dropdown = gr.Dropdown(label="Transfer Style",choices=["Hayao", "Shinkai", "Kon Satoshi"])
|
33 |
video_input = gr.Video()
|
34 |
video_output = gr.Video()
|
35 |
with gr.Row():
|
36 |
video_button = gr.Button("Transfer")
|
37 |
clear_video_button = gr.Button("Clear")
|
38 |
|
39 |
+
image_button.click(to_black, inputs=[image_input,image_dropdown], outputs=image_output)
|
40 |
+
video_button.click(to_black, inputs=[video_input,video_dropdown], outputs=video_output)
|
41 |
clear_image_button.click(clear_output, inputs=image_input,outputs=image_output)
|
42 |
clear_video_button.click(clear_output, inputs=video_input,outputs=video_output)
|
43 |
demo.launch()
|