jittor.transform

这里是Jittor的 数据变换 模块的API文档,您可以通过from jittor import transform来获取该模块。

class jittor.transform.CenterCrop(size)[源代码]

Class for cropping image centrally.

Args:

[in] size(int or tuple): Size want to crop.

Example:

transform = transform.CenterCrop(224)
img_ = transform(img)
class jittor.transform.Compose(transforms)[源代码]

Base class for combining various transformations.

Args:

[in] transforms(list): a list of transform.

Example:

transform = transform.Compose([
    transform.Resize(opt.img_size),
    transform.Gray(),
    transform.ImageNormalize(mean=[0.5], std=[0.5]),
])
img_ = transform(img)
class jittor.transform.Crop(top, left, height, width)[源代码]

Crop and the PIL Image to given size.

Args:

  • top(int): top pixel indexes

  • left(int): left pixel indexes

  • height(int): image height

  • width(int): image width

class jittor.transform.Gray[源代码]

Convert image to grayscale.

Example:

transform = transform.Gray()
img_ = transform(img)
class jittor.transform.ImageNormalize(mean, std)[源代码]

Class for normalizing the input image.

Args:

[in] mean(list): the mean value of Normalization.
[in] std(list): the std value of Normalization.

Example:

transform = transform.ImageNormalize(mean=[0.5], std=[0.5])
img_ = transform(img)
class jittor.transform.RandomCrop(size)[源代码]

Class for randomly cropping the input image.

Args:

[in] size(tuple or int): the size want to crop.

Example:

transform = transform.RandomCrop(128)
img_ = transform(img)
class jittor.transform.RandomCropAndResize(size, scale: tuple = 0.08, 1.0, ratio: tuple = 0.75, 1.3333333333333333, interpolation=2)[源代码]

Random crop and resize the given PIL Image to given size.

Args:

[in] size(int or tuple): width and height of the output image.
[in] scale(tuple): range of scale ratio of the area.
[in] ratio(tuple): range of aspect ratio.
[in] interpolation: type of resize. default: PIL.Image.BILINEAR.

Example:

transform = transform.RandomCropAndResize(224)
img_ = transform(img)
class jittor.transform.RandomHorizontalFlip(p=0.5)[源代码]

Random flip the image horizontally.

Args:

[in] p(float): The probability of image flip, default: 0.5.

Example:

transform = transform.RandomHorizontalFlip(0.6)
img_ = transform(img)
class jittor.transform.Resize(size, mode=2)[源代码]

Class for resizing image.

Args:

[in] size(int or tuple): Size want to resize.
[in] mode(int): type of resize.

Example:

transform = transform.Resize(224)
img_ = transform(img)
jittor.transform.crop(img, top, left, height, width)[源代码]

Function for cropping image.

Args:

[in] img(Image.Image): Input image.
[in] top(int): the top boundary of the cropping box.
[in] left(int): the left boundary of the cropping box.
[in] height(int): height of the cropping box.
[in] width(int): width of the cropping box.

Example:

img = Image.open(...)
img_ = transform.crop(img, 10, 10, 100, 100)
jittor.transform.crop_and_resize(img, top, left, height, width, size, interpolation=2)[源代码]

Function for cropping and resizing image.

Args:

[in] img(Image.Image): Input image.
[in] top(int): the top boundary of the cropping box.
[in] left(int): the left boundary of the cropping box.
[in] height(int): height of the cropping box.
[in] width(int): width of the cropping box.
[in] size: resize size.
[in] interpolation(int): type of resize. default: PIL.Image.BILINEAR

Example:

img = Image.open(...)
img_ = transform.resize(img, 10,10,200,200,100)
jittor.transform.resize(img, size, interpolation=2)[源代码]

Function for resizing image.

Args:

[in] img(Image.Image): Input image.
[in] size: resize size.
[in] interpolation(int): type of resize. default: PIL.Image.BILINEAR

Example:

img = Image.open(...)
img_ = transform.resize(img, (100, 100))
jittor.transform.to_tensor(img)[源代码]

Function for turning Image.Image to jt.array.

Args:

[in] img(Image.Image): Input image.

Example:

img = Image.open(...)
img_ = transform.to_tensor(img)