Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 1.9 KB

File metadata and controls

56 lines (44 loc) · 1.9 KB

Transforms

You can transform data in dataset with DPF. For example, resize videos or photos in dataset. You can use DPF.transforms for these tasks.

Transformations are currently working only for files and sharded files formats and only on local storage

List of implemented transforms:

Examples

Resize all images to 768 pixels on the minimum side while maintaining the aspect ratio:

from DPF.transforms import ImageResizeTransforms, Resizer, ResizerModes

transforms = ImageResizeTransforms(Resizer(ResizerModes.MIN_SIZE, size=768))
processor.apply_transform(transforms)

Resize all images to 768 pixels on the maximum side while maintaining the aspect ratio:

from DPF.transforms import VideoResizeTransforms, Resizer, ResizerModes

transforms = VideoResizeTransforms(Resizer(ResizerModes.MAX_SIZE, size=768))
processor.apply_transform(transforms)

Change fps to 24 and resize all videos to 768 pixels on the minimum side while maintaining the aspect ratio:

from DPF.transforms import VideoFFMPEGTransforms, Resizer, ResizerModes

transforms = VideoFFMPEGTransforms(
    resizer=Resizer(ResizerModes.MIN_SIZE, size=768),
    fps=24,
    workers=8
)
processor.apply_transform(transforms)

Fast video cutting: cut_start and cut_duration columns should have values in seconds. For example, cutting video from 7 to 11 second should be specified in dataframe as: cut_start = 7, cut_duration = 4

from DPF.transforms import VideoFFMPEGTransforms

transforms = VideoFFMPEGTransforms(
    cut_start_col='cut_start',
    cut_duration_col='cut_duration',
    copy_stream=True,
    workers=4,
)
processor.apply_transform(transforms)