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

Pytorch video #216

Merged
merged 70 commits into from
Apr 30, 2021
Merged

Pytorch video #216

merged 70 commits into from
Apr 30, 2021

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Apr 15, 2021

What does this PR do?

Fixes # (issue)

This PR integrates PyTorchVideo to Lightning Flash: https://pytorchvideo.org

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests? [not needed for typos/docs]
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

Comment on lines 77 to 80
if not model_kwargs:
model_kwargs = {}

model_kwargs["pretrained"] = pretrained
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add a check if the User is passing pretrained in model_kwargs, or else the default will be passed to the Model.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.


if isinstance(model, nn.Module):
self.model = model
elif isinstance(model, str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly add a check for _PYTORCH_VIDEO_AVAILABLE here, or else self.models will be an empty FlashRegistry.

flash_examples/finetuning/video_classification.py Outdated Show resolved Hide resolved
flash/vision/video/classification/data.py Outdated Show resolved Hide resolved
flash/vision/video/classification/data.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 15, 2021

Codecov Report

Merging #216 (43e2bc3) into master (2b39eae) will decrease coverage by 0.01%.
The diff coverage is 80.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #216      +/-   ##
==========================================
- Coverage   87.38%   87.37%   -0.02%     
==========================================
  Files          59       62       +3     
  Lines        3123     3294     +171     
==========================================
+ Hits         2729     2878     +149     
- Misses        394      416      +22     
Flag Coverage Δ
unittests 87.37% <80.78%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
flash/core/classification.py 92.85% <ø> (-0.11%) ⬇️
flash/text/classification/data.py 83.49% <ø> (+1.94%) ⬆️
flash/text/seq2seq/translation/data.py 90.00% <ø> (ø)
flash/text/seq2seq/translation/model.py 72.22% <ø> (ø)
flash/text/seq2seq/summarization/metric.py 96.55% <33.33%> (ø)
flash/core/model.py 90.77% <60.00%> (-0.03%) ⬇️
flash/video/classification/data.py 77.52% <77.52%> (ø)
flash/text/seq2seq/core/data.py 80.26% <78.94%> (-0.39%) ⬇️
flash/video/classification/model.py 87.50% <87.50%> (ø)
flash/core/finetuning.py 88.88% <100.00%> (+0.20%) ⬆️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b39eae...43e2bc3. Read the comment docs.

flash/vision/video/classification/data.py Outdated Show resolved Hide resolved
decoder=self.decoder,
)
if self.training:
dataset.num_classes = len(np.unique([s[1]['label'] for s in ds._labeled_videos]))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good little line of code, probably should move it to PTV and just expose a num_classes property (also means we wouldn't need to access the private _labeled_videos property. Will add this as a PTV issue and we can change it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great !

flash/vision/video/classification/data.py Outdated Show resolved Hide resolved
flash/vision/video/classification/data.py Outdated Show resolved Hide resolved
flash/vision/video/classification/data.py Outdated Show resolved Hide resolved
flash/vision/video/classification/data.py Outdated Show resolved Hide resolved
flash/vision/video/classification/data.py Outdated Show resolved Hide resolved
tests/video/test_video_classifier.py Show resolved Hide resolved
tests/video/test_video_classifier.py Outdated Show resolved Hide resolved
tests/video/test_video_classifier.py Outdated Show resolved Hide resolved
@pep8speaks
Copy link

pep8speaks commented Apr 16, 2021

Hello @tchaton! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-04-30 14:35:36 UTC

@ethanwharris ethanwharris mentioned this pull request Apr 16, 2021
8 tasks
Copy link
Collaborator

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome 😍 the examples are super clean and easy to follow! Just some small comments 😃

flash/core/model.py Outdated Show resolved Hide resolved
flash/core/model.py Outdated Show resolved Hide resolved
flash/data/auto_dataset.py Outdated Show resolved Hide resolved
flash/data/auto_dataset.py Outdated Show resolved Hide resolved
flash/data/data_module.py Outdated Show resolved Hide resolved
flash/data/data_module.py Outdated Show resolved Hide resolved
flash/data/data_pipeline.py Outdated Show resolved Hide resolved
flash/data/data_pipeline.py Outdated Show resolved Hide resolved
flash/data/data_pipeline.py Outdated Show resolved Hide resolved
flash/data/process.py Outdated Show resolved Hide resolved
@tchaton tchaton enabled auto-merge (squash) April 29, 2021 19:38
@tchaton tchaton disabled auto-merge April 29, 2021 20:06
@@ -0,0 +1,2 @@
from flash.video.classification.data import VideoClassificationData
from flash.video.classification.model import VideoClassifier
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the preprocess

@tchaton tchaton merged commit 0263fd1 into master Apr 30, 2021
@tchaton tchaton deleted the pytorch_video branch April 30, 2021 14:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants