__init__.py 982 Bytes
Newer Older
1
2
from torchvision import models
from torchvision import datasets
3
from torchvision import ops
4
5
from torchvision import transforms
from torchvision import utils
6
from torchvision import io
7

8
9
try:
    from .version import __version__  # noqa: F401
Soumith Chintala's avatar
Soumith Chintala committed
10
except ImportError:
11
    pass
12
13
14
15
16
17
18
19
20

_image_backend = 'PIL'


def set_image_backend(backend):
    """
    Specifies the package used to load images.

    Args:
21
22
23
        backend (string): Name of the image backend. one of {'PIL', 'accimage'}.
            The :mod:`accimage` package uses the Intel IPP library. It is
            generally faster than PIL, but does not support as many operations.
24
25
26
27
28
29
30
31
32
33
34
35
36
    """
    global _image_backend
    if backend not in ['PIL', 'accimage']:
        raise ValueError("Invalid backend '{}'. Options are 'PIL' and 'accimage'"
                         .format(backend))
    _image_backend = backend


def get_image_backend():
    """
    Gets the name of the package used to load images
    """
    return _image_backend