Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Fix normalizing video classification input #1213

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed

- Fixed normalizing inputs to video classification ([#1213](https://github.com/PyTorchLightning/lightning-flash/pull/1213))

- Fixed a bug where DDP would not work with Flash tasks ([#1182](https://github.com/PyTorchLightning/lightning-flash/pull/1182))

- Fixed DDP support for `VideoClassifier` ([#1189](https://github.com/PyTorchLightning/lightning-flash/pull/1189))
Expand Down
7 changes: 6 additions & 1 deletion flash/video/classification/input_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
ClipSampler, LabeledVideoDataset, EncodedVideo, ApplyTransformToKey = None, None, None, None


def normalize(x: torch.Tensor) -> torch.Tensor:
return x / 255.0


@requires("video")
@dataclass
class VideoClassificationInputTransform(InputTransform):
Expand All @@ -48,7 +52,8 @@ def per_sample_transform(self) -> Callable:
per_sample_transform = [CenterCrop(self.image_size)]

return ApplyToKeys(
"video", Compose([UniformTemporalSubsample(self.temporal_sub_sample)] + per_sample_transform)
"video",
Compose([UniformTemporalSubsample(self.temporal_sub_sample), normalize] + per_sample_transform),
)

def per_batch_transform_on_device(self) -> Callable:
Expand Down