MCPcopy Create free account
hub / github.com/dcharatan/flowmap / subsample

Function subsample

flowmap/subsample.py:42–67  ·  view source on GitHub ↗
(cfg_dict: DictConfig)

Source from the content-addressed store, hash-verified

40 config_name="subsample",
41)
42def 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
70def video_to_frames(

Callers 1

subsample.pyFile · 0.85

Calls 5

get_typed_root_configFunction · 0.85
get_flow_predictorFunction · 0.85
video_to_framesFunction · 0.85
subsample_framesFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected