-
Notifications
You must be signed in to change notification settings - Fork 7k
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
implement imagenet prototype dataset as function #5565
Changes from 1 commit
be6c32d
dbcde5c
2e92d26
617bfb3
3539ebe
271fe99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
from torch.utils.data.graph import traverse | ||
from torchdata.datapipes.iter import Shuffler, ShardingFilter | ||
from torchvision.prototype import transforms, datasets | ||
from torchvision.prototype.datasets.utils._internal import TakerDataPipe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NivekT If I recall correctly, we wanted to upstream this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will have a look at the implementation sometime today There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can upstream There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please tag me in the PR so I can make the changes here after it is landed. |
||
from torchvision.prototype.utils._internal import sequence_to_str | ||
|
||
|
||
|
@@ -51,8 +52,10 @@ def test_smoke(self, test_home, dataset_mock, config): | |
|
||
dataset = datasets.load(dataset_mock.name, **config) | ||
|
||
if not isinstance(dataset, datasets.utils.Dataset2): | ||
raise AssertionError(f"Loading the dataset should return an Dataset, but got {type(dataset)} instead.") | ||
if not isinstance(dataset, TakerDataPipe): | ||
raise AssertionError( | ||
f"Loading the dataset should return an TakerDataPipe, but got {type(dataset)} instead." | ||
) | ||
|
||
@parametrize_dataset_mocks(DATASET_MOCKS) | ||
def test_sample(self, test_home, dataset_mock, config): | ||
|
@@ -100,7 +103,6 @@ def test_transformable(self, test_home, dataset_mock, config): | |
|
||
next(iter(dataset.map(transforms.Identity()))) | ||
|
||
@pytest.mark.xfail(reason="See https://github.com/pytorch/data/issues/237") | ||
@parametrize_dataset_mocks(DATASET_MOCKS) | ||
def test_serializable(self, test_home, dataset_mock, config): | ||
dataset_mock.prepare(test_home, config) | ||
|
@@ -109,7 +111,6 @@ def test_serializable(self, test_home, dataset_mock, config): | |
|
||
pickle.dumps(dataset) | ||
|
||
@pytest.mark.xfail(reason="See https://github.com/pytorch/data/issues/237") | ||
@parametrize_dataset_mocks(DATASET_MOCKS) | ||
@pytest.mark.parametrize("annotation_dp_type", (Shuffler, ShardingFilter)) | ||
def test_has_annotations(self, test_home, dataset_mock, config, annotation_dp_type): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the resources are now fully internal inside the dataset function, I don't see a good way to check if the mock data is set up correctly. One thing we could try is to patch
vision/torchvision/prototype/datasets/utils/_resource.py
Lines 117 to 119 in d8654bb
on all subclasses to raise the error I commented out above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could
load_images_dp
be registered and mocked?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would require registering functions like that just for testing purposes. Not sure if we should go that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, how about making
info
including another dictionary ofResource
s? And,load_images_dp
could load resource frominfo
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a possibility, yes. cc @NicolasHug