Reuse _TORCHVISION_AVAILABLE (#6976)
This commit is contained in:
parent
b9bc77293b
commit
6a7f011495
|
@ -14,7 +14,6 @@ _EXAMPLES_ROOT = os.path.dirname(__file__)
|
|||
_PACKAGE_ROOT = os.path.dirname(_EXAMPLES_ROOT)
|
||||
_DATASETS_PATH = os.path.join(_PACKAGE_ROOT, 'Datasets')
|
||||
|
||||
_TORCHVISION_AVAILABLE = _module_available("torchvision")
|
||||
_TORCHVISION_MNIST_AVAILABLE = not bool(os.environ.get("PL_USE_MOCKED_MNIST", False))
|
||||
_DALI_AVAILABLE = _module_available("nvidia.dali")
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ from torch import nn
|
|||
from torch.utils.data import DataLoader, random_split
|
||||
|
||||
import pytorch_lightning as pl
|
||||
from pl_examples import _DATASETS_PATH, _TORCHVISION_AVAILABLE, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
|
||||
from pl_examples import _DATASETS_PATH, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
|
||||
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
|
||||
|
||||
if _TORCHVISION_AVAILABLE:
|
||||
from torchvision import transforms
|
||||
|
|
|
@ -19,7 +19,8 @@ from torch.nn import functional as F
|
|||
from torch.utils.data import DataLoader, random_split
|
||||
|
||||
import pytorch_lightning as pl
|
||||
from pl_examples import _DATASETS_PATH, _TORCHVISION_AVAILABLE, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
|
||||
from pl_examples import _DATASETS_PATH, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
|
||||
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
|
||||
|
||||
if _TORCHVISION_AVAILABLE:
|
||||
from torchvision import transforms
|
||||
|
|
|
@ -23,13 +23,8 @@ from torch.nn import functional as F
|
|||
from torch.utils.data import random_split
|
||||
|
||||
import pytorch_lightning as pl
|
||||
from pl_examples import (
|
||||
_DALI_AVAILABLE,
|
||||
_DATASETS_PATH,
|
||||
_TORCHVISION_AVAILABLE,
|
||||
_TORCHVISION_MNIST_AVAILABLE,
|
||||
cli_lightning_logo,
|
||||
)
|
||||
from pl_examples import _DALI_AVAILABLE, _DATASETS_PATH, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
|
||||
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
|
||||
|
||||
if _TORCHVISION_AVAILABLE:
|
||||
from torchvision import transforms
|
||||
|
|
|
@ -17,8 +17,9 @@ from warnings import warn
|
|||
|
||||
from torch.utils.data import DataLoader, random_split
|
||||
|
||||
from pl_examples import _DATASETS_PATH, _TORCHVISION_AVAILABLE, _TORCHVISION_MNIST_AVAILABLE
|
||||
from pl_examples import _DATASETS_PATH, _TORCHVISION_MNIST_AVAILABLE
|
||||
from pytorch_lightning import LightningDataModule
|
||||
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
|
||||
|
||||
if _TORCHVISION_AVAILABLE:
|
||||
from torchvision import transforms as transform_lib
|
||||
|
|
|
@ -28,9 +28,10 @@ import torch.nn as nn
|
|||
import torch.nn.functional as F # noqa
|
||||
from torch.utils.data import DataLoader
|
||||
|
||||
from pl_examples import _TORCHVISION_AVAILABLE, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
|
||||
from pl_examples import _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
|
||||
from pytorch_lightning.core import LightningDataModule, LightningModule
|
||||
from pytorch_lightning.trainer import Trainer
|
||||
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
|
||||
|
||||
if _TORCHVISION_AVAILABLE:
|
||||
import torchvision
|
||||
|
|
Loading…
Reference in New Issue