Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing lambda to transforms in tutorial #49

Closed

Conversation

nateraw
Copy link
Contributor

@nateraw nateraw commented May 24, 2021

Motivation and Context

Closes #32 by adding lambda in the tutorial. Code changes to be made in #41 - this is just a quickfix.

How Has This Been Tested

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 24, 2021
@facebook-github-bot
Copy link
Contributor

@kalyanvasudev has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kalyanvasudev merged this pull request in b3f55aa.

facebook-github-bot pushed a commit that referenced this pull request Apr 7, 2022
Summary:
## Motivation and Context

Adds the ability to set the stride < window size for UniformClipSampler. Why?
- Feature extraction on imagenet based models for videos, e.g. every 5 frames with a single frame retrieved

## How Has This Been Tested

- Added some unit tests
- Run existing unit tests

## Other comments

This was a bit difficult to implement due to the way clip samplers are designed. Personally I think this can be re-designed such that the implementation is much simpler. As an example, the implementation of UniformClipSampler could be ~20 lines of code compared to the current implementation:

```
def _num_clips(...) -> int:
      num_frames = round(duration_sec * fps)
      N = num_frames - window_size_frames
      if N < 0:
          return 1
      result = int(N / stride_frames + 1)
      pad = backpad_last and N % stride_frames != 0
      return result + pad

start_end_times = [
    (
      (i * s_prime) / fps,
      ((i * s_prime + window_size) / fps)
    )
    for i in range(num_clips(...))
]
if expected_start_end_times[-1][1] - video_length > 1e-6:
     expected_start_end_times[-1] = (video_length - window_size / fps, video_length)
```

X-link: fairinternal/pytorchvideo#49

Reviewed By: lyttonhao

Differential Revision: D34811417

Pulled By: miguelmartin75

fbshipit-source-id: b9d93d5446d16008ede20e61a6314a89e6b1364e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should add Lambda(lambda x: x/255.0) in tutorial
3 participants