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

Commit

Permalink
Fix normalizing video classification input (#1213)
Browse files Browse the repository at this point in the history
Co-authored-by: Ethan Harris <ethanwharris@gmail.com>
  • Loading branch information
dudeperf3ct and ethanwharris authored Mar 3, 2022
1 parent 8a4faa8 commit 36377b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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 examples (question answering), where NLTK's `punkt` module needs to be downloaded first. ([#1215](https://github.com/PyTorchLightning/lightning-flash/pull/1215/files))

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

0 comments on commit 36377b7

Please sign in to comment.