Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,8 +23,8 @@ def parse_args():
|
|
23 |
def parse_args_video():
|
24 |
parser = argparse.ArgumentParser()
|
25 |
parser.add_argument('--weight', type=str, default='GeneratorV2_train_photo_Hayao_init.pt')
|
26 |
-
|
27 |
-
|
28 |
parser.add_argument('--batch-size', type=int, default=4)
|
29 |
parser.add_argument('--start', type=int, default=0, help='Start time of video (second)')
|
30 |
parser.add_argument('--end', type=int, default=10, help='End time of video (second), 0 if not set')
|
@@ -55,7 +55,7 @@ def transfer(image, transfer_style):
|
|
55 |
return image
|
56 |
|
57 |
|
58 |
-
def transfer_video(
|
59 |
if transfer_style == "Hayao":
|
60 |
#output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 转换为灰度图像
|
61 |
#os.system("wget https://huggingface.co/YANGYYYY/cartoonize/resolve/main/GeneratorV2_train_photo_Hayao_init.pt")
|
@@ -75,8 +75,12 @@ def transfer_video(video, transfer_style):
|
|
75 |
|
76 |
# # 关闭视频文件
|
77 |
# cap.release()
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
elif transfer_style == "Shinkai":
|
81 |
args = parse_args()
|
82 |
args.weight = 'GeneratorV2_train_photo_Shinkai_init.pt'
|
@@ -116,7 +120,7 @@ with gr.Blocks() as demo:
|
|
116 |
clear_video_button = gr.Button("Clear")
|
117 |
|
118 |
image_button.click(transfer, inputs=[image_input,image_dropdown], outputs=image_output)
|
119 |
-
video_button.click(transfer_video, inputs=[video_input,video_dropdown
|
120 |
clear_image_button.click(clear_output, inputs=image_input,outputs=image_output)
|
121 |
clear_video_button.click(clear_output, inputs=video_input,outputs=video_output)
|
122 |
demo.launch()
|
|
|
23 |
def parse_args_video():
|
24 |
parser = argparse.ArgumentParser()
|
25 |
parser.add_argument('--weight', type=str, default='GeneratorV2_train_photo_Hayao_init.pt')
|
26 |
+
parser.add_argument('--src', type=str, default='dataset/video/花.mp4', help='Path to input video')
|
27 |
+
parser.add_argument('--out', type=str, default='dataset/video_Hayao/hua_hayao.mp4', help='Path to save new video')
|
28 |
parser.add_argument('--batch-size', type=int, default=4)
|
29 |
parser.add_argument('--start', type=int, default=0, help='Start time of video (second)')
|
30 |
parser.add_argument('--end', type=int, default=10, help='End time of video (second), 0 if not set')
|
|
|
55 |
return image
|
56 |
|
57 |
|
58 |
+
def transfer_video(video_output, transfer_style,video_output):
|
59 |
if transfer_style == "Hayao":
|
60 |
#output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 转换为灰度图像
|
61 |
#os.system("wget https://huggingface.co/YANGYYYY/cartoonize/resolve/main/GeneratorV2_train_photo_Hayao_init.pt")
|
|
|
75 |
|
76 |
# # 关闭视频文件
|
77 |
# cap.release()
|
78 |
+
args.src = video_input
|
79 |
+
args.out = video_output
|
80 |
+
Predictor(args.weight).transform_video(args.src, args.out, args.batch_size, start=args.start, end=args.end)
|
81 |
+
|
82 |
+
#anime_video = Predictor(args.weight).transform_video(video, args.batch_size, args.start, args.end)
|
83 |
+
#return anime_video
|
84 |
elif transfer_style == "Shinkai":
|
85 |
args = parse_args()
|
86 |
args.weight = 'GeneratorV2_train_photo_Shinkai_init.pt'
|
|
|
120 |
clear_video_button = gr.Button("Clear")
|
121 |
|
122 |
image_button.click(transfer, inputs=[image_input,image_dropdown], outputs=image_output)
|
123 |
+
video_button.click(transfer_video, inputs=[video_input,video_dropdown,video_output])
|
124 |
clear_image_button.click(clear_output, inputs=image_input,outputs=image_output)
|
125 |
clear_video_button.click(clear_output, inputs=video_input,outputs=video_output)
|
126 |
demo.launch()
|