Skip to content

Commit

Permalink
Hotfix for torchvision (#6476)
Browse files Browse the repository at this point in the history
(cherry picked from commit 079fe9b)
  • Loading branch information
kaushikb11 authored and lexierule committed Mar 16, 2021
1 parent b546431 commit 4bf0675
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
5 changes: 3 additions & 2 deletions pl_examples/basic_examples/autoencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import pytorch_lightning as pl
from pl_examples import _DATASETS_PATH, _TORCHVISION_AVAILABLE, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo

if _TORCHVISION_AVAILABLE and _TORCHVISION_MNIST_AVAILABLE:
if _TORCHVISION_AVAILABLE:
from torchvision import transforms
from torchvision.datasets.mnist import MNIST
if _TORCHVISION_MNIST_AVAILABLE:
from torchvision.datasets import MNIST
else:
from tests.helpers.datasets import MNIST

Expand Down
5 changes: 3 additions & 2 deletions pl_examples/basic_examples/backbone_image_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import pytorch_lightning as pl
from pl_examples import _DATASETS_PATH, _TORCHVISION_AVAILABLE, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo

if _TORCHVISION_AVAILABLE and _TORCHVISION_MNIST_AVAILABLE:
if _TORCHVISION_AVAILABLE:
from torchvision import transforms
from torchvision.datasets.mnist import MNIST
if _TORCHVISION_MNIST_AVAILABLE:
from torchvision.datasets import MNIST
else:
from tests.helpers.datasets import MNIST

Expand Down
5 changes: 3 additions & 2 deletions pl_examples/basic_examples/dali_image_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
cli_lightning_logo,
)

if _TORCHVISION_AVAILABLE and _TORCHVISION_MNIST_AVAILABLE:
if _TORCHVISION_AVAILABLE:
from torchvision import transforms
from torchvision.datasets.mnist import MNIST
if _TORCHVISION_MNIST_AVAILABLE:
from torchvision.datasets import MNIST
else:
from tests.helpers.datasets import MNIST

Expand Down
3 changes: 2 additions & 1 deletion pl_examples/basic_examples/mnist_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
from pl_examples import _DATASETS_PATH, _TORCHVISION_AVAILABLE, _TORCHVISION_MNIST_AVAILABLE
from pytorch_lightning import LightningDataModule

if _TORCHVISION_AVAILABLE and _TORCHVISION_MNIST_AVAILABLE:
if _TORCHVISION_AVAILABLE:
from torchvision import transforms as transform_lib
if _TORCHVISION_MNIST_AVAILABLE:
from torchvision.datasets import MNIST
else:
from tests.helpers.datasets import MNIST
Expand Down
5 changes: 3 additions & 2 deletions pl_examples/domain_templates/generative_adversarial_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
from pytorch_lightning.core import LightningDataModule, LightningModule
from pytorch_lightning.trainer import Trainer

if _TORCHVISION_AVAILABLE and _TORCHVISION_MNIST_AVAILABLE:
if _TORCHVISION_AVAILABLE:
import torchvision
import torchvision.transforms as transforms
from torchvision import transforms
if _TORCHVISION_MNIST_AVAILABLE:
from torchvision.datasets import MNIST
else:
from tests.helpers.datasets import MNIST
Expand Down
1 change: 1 addition & 0 deletions tests/helpers/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(
train: bool = True,
normalize: tuple = (0.1307, 0.3081),
download: bool = True,
**kwargs,
):
super().__init__()
self.root = root
Expand Down

0 comments on commit 4bf0675

Please sign in to comment.