(cfg_dict: DictConfig)
| 40 | config_name="subsample", |
| 41 | ) |
| 42 | def subsample(cfg_dict: DictConfig): |
| 43 | cfg = get_typed_root_config(cfg_dict, SubsampleCfg) |
| 44 | device = torch.device("cuda" if torch.cuda.is_available() else "cpu") |
| 45 | |
| 46 | # Set up the flow predictor. |
| 47 | flow_predictor = get_flow_predictor(cfg.flow) |
| 48 | flow_predictor.to(device) |
| 49 | |
| 50 | with tempfile.TemporaryDirectory() as work_dir: |
| 51 | work_dir = Path(work_dir) |
| 52 | |
| 53 | # If the input isn't a directory, assume it's a video. |
| 54 | if cfg.in_path.is_dir(): |
| 55 | frame_dir = cfg.in_path |
| 56 | else: |
| 57 | video_to_frames(cfg.in_path, work_dir, cfg.limit_num_seconds) |
| 58 | frame_dir = work_dir |
| 59 | |
| 60 | subsample_frames( |
| 61 | flow_predictor, |
| 62 | frame_dir, |
| 63 | cfg.out_path, |
| 64 | cfg.target_num_frames, |
| 65 | cfg.flow_resolution, |
| 66 | device, |
| 67 | ) |
| 68 | |
| 69 | |
| 70 | def video_to_frames( |
no test coverage detected