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 <[email protected]>
  • Loading branch information
dudeperf3ct and ethanwharris committed Mar 30, 2022
1 parent fd65a13 commit 9d6a5c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Fixed

- 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 normalizing inputs to video classification ([#1213](https://github.com/PyTorchLightning/lightning-flash/pull/1213))

### Removed

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 9d6a5c5

Please sign in to comment.