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 MovingMNIST dataset #7042

Merged
merged 15 commits into from
Jan 4, 2023
Merged

Conversation

tsugumi-sys
Copy link
Contributor

@tsugumi-sys tsugumi-sys commented Dec 19, 2022

Signed-off-by: tsugumi-sys tidemark0105@gmail.com

Implement this class applying this review here.

  1. Transform for each frames: Done
  2. There two ways, 1: Read form file and split. 2: Generate dataset with this class and split.) I prefer 1 to 2 and tensorflow also do 1. (The moving sequence dataset implemented by tensorflow is an other dataset.)
  3. Simply return a flames, Not split into input and label. : Moving MNIST is used both supervised and unsupervised training, so we should just return frames here.

closes #6981
cc @pmeier

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
@facebook-github-bot
Copy link

Hi @tsugumi-sys!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@tsugumi-sys
Copy link
Contributor Author

tsugumi-sys commented Dec 19, 2022

@pmeier
Do you have any idea why these CI are failed.

@pmeier
Copy link
Collaborator

pmeier commented Dec 19, 2022

@tsugumi-sys Both failures are unrelated.

@pmeier pmeier self-requested a review December 19, 2022 12:16
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
@tsugumi-sys
Copy link
Contributor Author

@pmeier
I want to discuss how to split data into train and test.
We can download only a single file so we need to manually split the data. I'm considering two ways.

  • Split in this class.
  • This class just returns the whole data and users need to split manually.

I think Split in this class is not a good way because we need to load the whole data to get whether train data or test data.
Or we can save into two files when downloading the raw data, but this may be a little bit confusing. If user wants to change the split ratio, we need to download again or concatenate two files.
Do you have any idea for this?

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

I think Split in this class is not a good way because we need to load the whole data to get whether train data or test data.

Not sure I understand. You are already loading the complete file, so what is difference? Plus, we are talking about ~800MB here which is not terribly large.

My suggestion is to have two parameters: split: Optional[str] = None and split_ratio: int = 10.

  1. For split=None, we return the full data without any split on our side. Meaning, we ignore split_ratio.
  2. For split="train", we return data[:split_ratio].
  3. For split="test", we return data[split_ratio:].

Here data is a single video in the dataset, i.e. (T, C, H, W). With this the user by default gets the unsupervised data by default, but has convenient access to the splits defined by the authors.

In addition, the user can set the split_ratio to their liking. IMO that is enough for the first round.

Generating new data is somewhat unrelated to MovingMNIST since they don't do anything special other than bouncing data in a larger image. Tensorflow has this functionality, but in a general way. If someone needs it, we can always add that later.

Thoughts?

test/datasets_utils.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>
@tsugumi-sys
Copy link
Contributor Author

@pmeier
Thank you for your reviews! I was warried too much. I agree your idea :)

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks @tsugumi-sys! Implementation looks correct. I have a couple of inline comments to make it more compatible with the datasets that we already have.

torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Show resolved Hide resolved
Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks for being patient @tsugumi-sys! Mostly minor nits left.

torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
test/test_datasets.py Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
torchvision/datasets/moving_mnist.py Outdated Show resolved Hide resolved
@pmeier
Copy link
Collaborator

pmeier commented Dec 26, 2022

Just as a heads-up for someone else reading this thread: the timestamps on the commits by @tsugumi-sys are wrong and this is why they are shown in this weird order in GH. For example #7042 (review) was done by me on Dec 25, 2022. eacd778 was added in response to that, but is stamped with Date: Tue, 20 Dec 2022 15:53:03 +0900.

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks @tsugumi-sys! Only some minor test cleanup left, but otherwise this is good to merge if relevant CI is green. Don't worry too much about failing jobs for now, since there seem to be some unrelated failures. I'll look through them and ping you in case something needs to be fixed here.

test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
@tsugumi-sys
Copy link
Contributor Author

tsugumi-sys commented Dec 27, 2022

@pmeier
Thank you for your kind reviews!
I'm going to start working as a engineer next year and I've learned a lot from your reviews :)

@tsugumi-sys
Copy link
Contributor Author

And my commit timestamp was wrong because the system datetime of my WSL2 (Ubuntu) was wrong (I dont figure out why this happened). Sorry:(

@pmeier
Copy link
Collaborator

pmeier commented Jan 4, 2023

None of the CI failures are related. Thanks @tsugumi-sys for the patience and good work!

@pmeier pmeier merged commit 46b7e27 into pytorch:main Jan 4, 2023
facebook-github-bot pushed a commit that referenced this pull request Jan 9, 2023
Summary:
* add moving mnist dataset

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* remove unused modules

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* modify docstring

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* modify docstring and docs

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* add split and split ratio kwargs

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* fix checking split argument

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* remove unused package

* delete lines

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* fix filename property

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* fix reviews

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* modify docstrings

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* add split tests and etc

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

* fix tests

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

Signed-off-by: tsugumi-sys <tidemark0105@gmail.com>

Reviewed By: NicolasHug

Differential Revision: D42414488

fbshipit-source-id: c001178b992bf033a5ca4fc75ee041f7ead948f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Moving MNIST dataset
4 participants