YANGYYYY commited on
Commit
ae0812f
1 Parent(s): 473f3b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -59,7 +59,20 @@ def transfer_video(video, transfer_style):
59
  #output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 转换为灰度图像
60
  #os.system("wget https://huggingface.co/YANGYYYY/cartoonize/resolve/main/GeneratorV2_train_photo_Hayao_init.pt")
61
  args = parse_args_video()
62
- anime_video = Predictor(args.weight).transform_video(video, args.batch_size)
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  return anime_video
64
  elif transfer_style == "Shinkai":
65
  args = parse_args()
 
59
  #output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 转换为灰度图像
60
  #os.system("wget https://huggingface.co/YANGYYYY/cartoonize/resolve/main/GeneratorV2_train_photo_Hayao_init.pt")
61
  args = parse_args_video()
62
+ # 加载视频文件
63
+ cap = cv2.VideoCapture(video)
64
+
65
+ # 读取视频帧并保存到一个列表中
66
+ video_frames = []
67
+ while True:
68
+ ret, frame = cap.read()
69
+ if not ret:
70
+ break
71
+ video_frames.append(frame)
72
+
73
+ # 关闭视频文件
74
+ cap.release()
75
+ anime_video = Predictor(args.weight).transform_video(video_frames, args.batch_size)
76
  return anime_video
77
  elif transfer_style == "Shinkai":
78
  args = parse_args()