vision icon indicating copy to clipboard operation
vision copied to clipboard

Generalising FakeData

Open ctr26 opened this issue 11 months ago • 8 comments

Hi all,

I've added a convenience module for creating a fake image folder in torch vision. I recently needed to create a mock folder and this can be a little painful without a FakeImage folder like this

Thanks

Craig

ctr26 avatar Mar 20 '24 10:03 ctr26

:link: Helpful Links

:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8344

Note: Links to docs will display an error until the docs builds have been completed.

:x: 3 New Failures

As of commit 3099a07484b59cc1f3fdc47786c35edd98cda50a with merge base d868be90e8d1032e16ec67631725f29f8390afd7 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

pytorch-bot[bot] avatar Mar 20 '24 10:03 pytorch-bot[bot]

Hi @ctr26!

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 [email protected]. Thanks!

facebook-github-bot avatar Mar 20 '24 10:03 facebook-github-bot

Thanks for the PR @ctr26 , but what is the benefit of FakeImageFolder over the existing FakeData class?

NicolasHug avatar Mar 20 '24 11:03 NicolasHug

Thanks for the PR @ctr26 , but what is the benefit of FakeImageFolder over the existing FakeData class?

Thank you for your question regarding the benefit of FakeImageFolder over the existing FakeData class.

The key advantage lies in its compatibility with testing environments that utilise ImageFolder derived datasets (most of them). In my specific use case, it was challenging for me to perform mock data tests on my MLOps pipeline, which relied on ImageFolder rather than Dataset. The existing FakeData class, although useful, does not support the kwargs expected by ImageFolder, leading to errors when used in this context and generally isn't a drop replacement.

The alternative being hacky solutions like downloading stock datasets like celeba as a mock, which seems excessive.

Thanks

Craig

ctr26 avatar Mar 20 '24 11:03 ctr26

Thanks for the details. IIUC you just need the signature of FakeData to be compatible with that of VisionDataset in order to avoid special-casing the call to FakeData?

Instead of creating a new class, would it be enough for your use-case to add *args, **kwargs to the signature of FakeData (both of which would be ignored/unsued)?

NicolasHug avatar Mar 20 '24 12:03 NicolasHug

That would an easier solution yes. My only concern there was that it would have unforeseen downstream effects. I've pushed the changes

ctr26 avatar Mar 20 '24 12:03 ctr26

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

facebook-github-bot avatar Mar 20 '24 14:03 facebook-github-bot

Thanks for the feedback @ctr26 . I'm still not sure I completely understand why FakeData and VisionDataset need to have the same signature. But since this seems to be a very specific use-case (and not necessarily a broadly useful one), I might recommend for you to simply inherit from FakeData and accept **kwargs in your own subclass, like so:

class MyFakeData(FakeData):
    def __init__(self, ..., *kwargs):
        super().__init__(...)

NicolasHug avatar Apr 02 '24 14:04 NicolasHug