()
| 153 | return blend |
| 154 | |
| 155 | def demo(): |
| 156 | args = get_demo_video_args() |
| 157 | scene_path = os.path.join(args.demo_root, args.scene_name) |
| 158 | marker_path = os.path.join(args.demo_root, args.marker_name) |
| 159 | movie_path = os.path.join(args.demo_root, args.movie_name) |
| 160 | save_path = os.path.join(args.demo_root, args.save_name) |
| 161 | print('===> Path Config') |
| 162 | print(f"marker: {marker_path}") |
| 163 | print(f"scene video: {scene_path}") |
| 164 | print(f"movie: {movie_path}") |
| 165 | print(f"save to: {save_path}") |
| 166 | |
| 167 | print('\n===> Loading marker image') |
| 168 | marker = cv2.imread(marker_path) |
| 169 | |
| 170 | print('===> Loading scene video') |
| 171 | scenes, _ = read_video(scene_path) |
| 172 | scenes = scenes[args.scene_start_idx:] |
| 173 | |
| 174 | print('===> Loading movie') |
| 175 | frames, fps = read_video(movie_path) |
| 176 | frames = frames[args.movie_start_idx:] |
| 177 | |
| 178 | print('===> Loading Model\n') |
| 179 | model_args = get_life_args() |
| 180 | estimator = Flow_estimator(model_args) |
| 181 | |
| 182 | if args.test: |
| 183 | print('> Test mode') |
| 184 | if args.draw: |
| 185 | plt.figure() |
| 186 | plt.imshow(scenes[args.scene_id][:,:,::-1]) |
| 187 | blend(estimator, marker, scenes[args.scene_id], frames[args.frame_id], args) |
| 188 | else: |
| 189 | print('> Video saving mode') |
| 190 | imgs = [] |
| 191 | for i, scene in tqdm(enumerate(scenes), total = len(scenes)): |
| 192 | frame = frames[i%len(frames)] |
| 193 | if i == 0: |
| 194 | args.save = True |
| 195 | else: |
| 196 | args.save = False |
| 197 | imgs.append(blend(estimator, marker, scene, frame, args)) |
| 198 | save_video(imgs, fps=fps, size=(imgs[0].shape[1], imgs[0].shape[0]), video_path=save_path) |
| 199 | |
| 200 | if __name__=='__main__': |
| 201 | demo() |
no test coverage detected