Metadata-Version: 2.1
Name: pytorch-disentanglement-datasets
Version: 0.0.1
Summary: PyTorch datasets with a focus on disentanglement
Author-email: Walter Nelson <walterj.nelson@mail.utoronto.ca>
License: MIT License
        
        Copyright (c) 2022 Walter Nelson
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/wjn0/pytorch-disentanglement-datasets
Project-URL: Bug Tracker, https://github.com/wjn0/pytorch-disentanglement-datasets/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# Disentanglement Datasets

A lightweight package of `torchvision`-style PyTorch datasets with a focus on flexibility.

## Installation

    $ pip install pytorch-disentanglement-datasets

## Usage

Each dataset returns a dictionary containing at least an `input` key:

```python
>>> from disentanglement_datasets import DSprites
>>> dataset = DSprites(root="./data", download=True)
>>> dataset[0]
{'input': tensor([[0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        ...,
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0]], dtype=torch.uint8),
 'latent': tensor([1.0000, 1.0000, 0.5000, 0.0000, 0.0000, 0.0000], dtype=torch.float64)}
 ```

This dictionary can be transformed. For example, for self-supervised learning with augmentations you might do something like:

```python
>>> def my_transform(item):
...   view1 = my_random_augmentation(item["input"])
...   view2 = my_random_augmentation(item["input"])
...   return view1, view2
...
>>> dataset = DSprites(root="./data", download=True, transform=my_transform)
>>> dataset[0]
(tensor([[0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        ...,
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0]], dtype=torch.uint8), tensor([[0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        ...,
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0],
        [0, 0, 0,  ..., 0, 0, 0]], dtype=torch.uint8))
```

## Datasets and their original sources

* [DSprites](https://github.com/deepmind/dsprites-dataset)
* [MPI3D-Toy](https://github.com/rr-learning/disentanglement_dataset)

## Attribution

If this code was useful to you, please cite the original dataset (links above) and this codebase.

### BibTeX

TODO

## Development

Pull requests are welcome.

## See also

* [`disentanglement-pytorch`](https://github.com/amir-abdi/disentanglement-pytorch): Variational autoencoder models for disentanglement, created as a contribution to the [*Disentanglement Challenge of NeurIPS 2019*](https://aicrowd.com/challenges/neurips-2019-disentanglement-challenge), along with more datasets with a different interface.
* [`disentanglement_lib`](https://github.com/google-research/disentanglement_lib): VAE models, metrics, and data for disentanglement, implemented in TensorFlow, created as a contribution to the [*Disentanglement Challenge of NeurIPS 2019*](https://aicrowd.com/challenges/neurips-2019-disentanglement-challenge).
