MPI-Sintel

http://sintel.is.tue.mpg.de/

root=data/sintel
mkdir -p ${root} && cd ${root}
f=MPI-Sintel-complete.zip
wget http://files.is.tue.mpg.de/sintel/${f}
unzip -q ${f}
cd ../..
 1__all__ = [
 2    'visualize',
 3]
 4
 5from typing import Any, Iterable
 6
 7T = dict[str, Any]
 8
 9
10def visualize(dataset: Iterable[T]) -> None:
11    from collections import defaultdict
12
13    import cv2
14    import numpy as np
15    import tqdm
16
17    import todd.tasks.optical_flow_estimation as ofe
18    from todd.patches.cv2 import ColorMap, VideoWriter
19
20    color_map = ColorMap(cv2.COLORMAP_JET)
21    video_writers: defaultdict[str, VideoWriter] = \
22        defaultdict(lambda: VideoWriter(12.))
23    for data in tqdm.tqdm(dataset):
24        id_: str = data['id_']
25        of = ofe.OpticalFlow(data['of'])
26        frame = np.concatenate([
27            data['frame1'],
28            of.to_color().numpy(),
29            color_map(of.a),
30            color_map(of.r),
31            color_map(of.u),
32            color_map(of.v),
33        ])
34        scene, _ = id_.split('/', 1)
35        video_writers[scene].write(frame)
36    for name, video_writer in video_writers.items():
37        video_writer.dump(f'{name}.mp4')
 1import pathlib
 2
 3import todd.tasks.optical_flow_estimation as ofe
 4from todd import Config
 5from todd.configs import PyConfig
 6
 7dataset = ofe.datasets.SintelDataset(
 8    access_layer=Config(data_root='data/sintel'),
 9    pass_='final',  # nosec B106
10)
11PyConfig.load(
12    pathlib.Path(__file__).parent / 'optical_flow.py',
13).visualize(dataset)
data/sintel/
├── training
│   ├── albedo|clean|final|flow_viz|invalid|occlusions
│   │   ├── alley_1
│   │   │   ├── frame_0001.png
│   │   │   └── ...
│   │   └── ...
│   └── flow
│       ├── alley_1
│       │   ├── frame_0001.flo
│       │   └── ...
│       └── ...
└── test
    └── clean|final
        ├── ambush_1
        │   ├── frame_0001.png
        │   └── ...
        └── ...