Documentation ¶
Index ¶
- func Byte2FloatImage(x *ts.Tensor) *ts.Tensor
- func Float2ByteImage(x *ts.Tensor) *ts.Tensor
- func HSV2RGB(x *ts.Tensor) *ts.Tensor
- func RGB2HSV(x *ts.Tensor) *ts.Tensor
- func RandomRotate(img *ts.Tensor, min, max float64) (*ts.Tensor, error)
- func Rotate(img *ts.Tensor, angle float64) (*ts.Tensor, error)
- type AffineOption
- func WithAffineDegree(degree []int64) AffineOption
- func WithAffineFillValue(fillValue []float64) AffineOption
- func WithAffineMode(mode string) AffineOption
- func WithAffineScale(scale []float64) AffineOption
- func WithAffineShear(shear []float64) AffineOption
- func WithAffineTranslate(translate []float64) AffineOption
- type Augment
- type CenterCrop
- type ColorJitter
- type ColorOption
- type CutoutOption
- type DownSample
- type GaussianBlur
- type Grayscale
- type Normalize
- type NormalizeOption
- type Option
- func OneOf(pvalue float64, tfOpts ...Option) Option
- func WithCenterCrop(size []int64) Option
- func WithColorJitter(opts ...ColorOption) Option
- func WithGaussianBlur(ks []int64, sig []float64) Option
- func WithNormalize(opts ...NormalizeOption) Option
- func WithRandRotate(minAngle, maxAngle float64) Option
- func WithRandomAdjustSharpness(opts ...SharpnessOption) Option
- func WithRandomAffine(opts ...AffineOption) Option
- func WithRandomAutocontrast(p ...float64) Option
- func WithRandomCrop(size []int64, padding []int64, paddingIfNeeded bool, paddingMode string) Option
- func WithRandomCutout(opts ...CutoutOption) Option
- func WithRandomEqualize(p ...float64) Option
- func WithRandomGrayscale(pvalueOpt ...float64) Option
- func WithRandomHFlip(pvalue float64) Option
- func WithRandomInvert(pvalueOpt ...float64) Option
- func WithRandomPerspective(opts ...PerspectiveOption) Option
- func WithRandomPosterize(opts ...PosterizeOption) Option
- func WithRandomSolarize(opts ...SolarizeOption) Option
- func WithRandomVFlip(pvalue float64) Option
- func WithResize(h, w int64) Option
- func WithRotate(angle float64) Option
- func WithZoomIn(v float64) Option
- func WithZoomOut(v float64) Option
- type Options
- type PerspectiveOption
- type PosterizeOption
- type RandRotateModule
- type RandomAdjustSharpness
- type RandomAffine
- type RandomAutocontrast
- type RandomCrop
- type RandomCutout
- type RandomEqualize
- type RandomGrayscale
- type RandomHorizontalFlip
- type RandomInvert
- type RandomPerspective
- type RandomPosterize
- type RandomResizedCrop
- type RandomSolarize
- type RandomVerticalFlip
- type ResizeModule
- type RotateModule
- type SharpnessOption
- type SolarizeOption
- type Transformer
- type ZoomIn
- type ZoomOut
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Byte2FloatImage ¶
Byte2FloatImage converts uint8 dtype image tensor to float dtype. It's panic if input image is not uint8 dtype.
func Float2ByteImage ¶
Float2ByteImage converts float dtype image to uint8 dtype image. It's panic if input is not float dtype tensor.
func RandomRotate ¶
RandomRotate randomly rotates a tensor image within a specifed angle range (degree).
Types ¶
type AffineOption ¶
type AffineOption func(*affineOptions)
func WithAffineDegree ¶
func WithAffineDegree(degree []int64) AffineOption
func WithAffineFillValue ¶
func WithAffineFillValue(fillValue []float64) AffineOption
func WithAffineMode ¶
func WithAffineMode(mode string) AffineOption
func WithAffineScale ¶
func WithAffineScale(scale []float64) AffineOption
func WithAffineShear ¶
func WithAffineShear(shear []float64) AffineOption
func WithAffineTranslate ¶
func WithAffineTranslate(translate []float64) AffineOption
type Augment ¶
type Augment struct {
// contains filtered or unexported fields
}
Augment is a struct composes of augmentation functions to implement Transformer interface.
type CenterCrop ¶
type CenterCrop struct {
// contains filtered or unexported fields
}
CenterCrop crops the given image at the center. If the image is torch Tensor, it is expected to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions. If image size is smaller than output size along any edge, image is padded with 0 and then center cropped.
type ColorJitter ¶
type ColorJitter struct {
// contains filtered or unexported fields
}
type ColorOption ¶
type ColorOption func(*colorOptions)
func WithColorBrightness ¶
func WithColorBrightness(v []float64) ColorOption
func WithColorContrast ¶
func WithColorContrast(v []float64) ColorOption
func WithColorHue ¶
func WithColorHue(vals []float64) ColorOption
func WithColorSaturation ¶
func WithColorSaturation(v []float64) ColorOption
type CutoutOption ¶
type CutoutOption func(o *cutoutOptions)
func WithCutoutPvalue ¶
func WithCutoutPvalue(p float64) CutoutOption
func WithCutoutRatio ¶
func WithCutoutRatio(ratio []float64) CutoutOption
func WithCutoutScale ¶
func WithCutoutScale(scale []float64) CutoutOption
func WithCutoutValue ¶
func WithCutoutValue(rgb []int64) CutoutOption
type DownSample ¶
type DownSample struct{}
type GaussianBlur ¶
type GaussianBlur struct {
// contains filtered or unexported fields
}
type Grayscale ¶
type Grayscale struct {
// contains filtered or unexported fields
}
GrayScale converts image to grayscale. If the image is torch Tensor, it is expected to have [..., 3, H, W] shape, where ... means an arbitrary number of leading dimensions Args: - num_output_channels (int): (1 or 3) number of channels desired for output image
func NewGrayscale ¶
type Normalize ¶
type Normalize struct {
// contains filtered or unexported fields
}
Normalize normalizes a tensor image with mean and standard deviation. Given mean: “(mean[1],...,mean[n])“ and std: “(std[1],..,std[n])“ for “n“ channels, this transform will normalize each channel of the input “torch.*Tensor“ i.e., “output[channel] = (input[channel] - mean[channel]) / std[channel]“ .. note:: This transform acts out of place, i.e., it does not mutate the input tensor. Args: - mean (sequence): Sequence of means for each channel. - std (sequence): Sequence of standard deviations for each channel.
type NormalizeOption ¶
type NormalizeOption func(*normalizeOptions)
func WithNormalizeMean ¶
func WithNormalizeMean(mean []float64) NormalizeOption
func WithNormalizeStd ¶
func WithNormalizeStd(std []float64) NormalizeOption
type Option ¶
type Option func(o *Options)
func OneOf ¶
OneOf randomly return one transformer from list of transformers with a specific p value.
func WithCenterCrop ¶
func WithColorJitter ¶
func WithColorJitter(opts ...ColorOption) Option
func WithGaussianBlur ¶
func WithNormalize ¶
func WithNormalize(opts ...NormalizeOption) Option
func WithRandRotate ¶
func WithRandomAdjustSharpness ¶
func WithRandomAdjustSharpness(opts ...SharpnessOption) Option
func WithRandomAffine ¶
func WithRandomAffine(opts ...AffineOption) Option
func WithRandomAutocontrast ¶
func WithRandomCrop ¶
func WithRandomCutout ¶
func WithRandomCutout(opts ...CutoutOption) Option
func WithRandomEqualize ¶
func WithRandomGrayscale ¶
func WithRandomHFlip ¶
func WithRandomInvert ¶
func WithRandomPerspective ¶
func WithRandomPerspective(opts ...PerspectiveOption) Option
func WithRandomPosterize ¶
func WithRandomPosterize(opts ...PosterizeOption) Option
func WithRandomSolarize ¶
func WithRandomSolarize(opts ...SolarizeOption) Option
func WithRandomVFlip ¶
func WithResize ¶
func WithRotate ¶
func WithZoomIn ¶
func WithZoomOut ¶
type PerspectiveOption ¶
type PerspectiveOption func(*perspectiveOptions)
func WithPerspectiveMode ¶
func WithPerspectiveMode(m string) PerspectiveOption
func WithPerspectivePvalue ¶
func WithPerspectivePvalue(p float64) PerspectiveOption
func WithPerspectiveScale ¶
func WithPerspectiveScale(s float64) PerspectiveOption
func WithPerspectiveValue ¶
func WithPerspectiveValue(v []float64) PerspectiveOption
type PosterizeOption ¶
type PosterizeOption func(*posterizeOptions)
func WithPosterizeBits ¶
func WithPosterizeBits(bits uint8) PosterizeOption
func WithPosterizePvalue ¶
func WithPosterizePvalue(p float64) PosterizeOption
type RandRotateModule ¶
type RandRotateModule struct {
// contains filtered or unexported fields
}
RandomRotateModule
type RandomAdjustSharpness ¶
type RandomAdjustSharpness struct {
// contains filtered or unexported fields
}
Adjust the sharpness of the image randomly with a given probability. If the image is torch Tensor, it is expected to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions. Args: sharpness_factor (float): How much to adjust the sharpness. Can be any non negative number. 0 gives a blurred image, 1 gives the original image while 2 increases the sharpness by a factor of 2. p (float): probability of the image being color inverted. Default value is 0.5
type RandomAffine ¶
type RandomAffine struct {
// contains filtered or unexported fields
}
RandomAffine is transformation of the image keeping center invariant. If the image is torch Tensor, it is expected to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions. Args: - degrees (sequence or number): Range of degrees to select from. If degrees is a number instead of sequence like (min, max), the range of degrees will be (-degrees, +degrees). Set to 0 to deactivate rotations. - translate (tuple, optional): tuple of maximum absolute fraction for horizontal and vertical translations. For example translate=(a, b), then horizontal shift is randomly sampled in the range -img_width * a < dx < img_width * a and vertical shift is randomly sampled in the range -img_height * b < dy < img_height * b. Will not translate by default. - scale (tuple, optional): scaling factor interval, e.g (a, b), then scale is randomly sampled from the range a <= scale <= b. Will keep original scale by default. - shear (sequence or number, optional): Range of degrees to select from. If shear is a number, a shear parallel to the x axis in the range (-shear, +shear) will be applied. Else if shear is a sequence of 2 values a shear parallel to the x axis in the range (shear[0], shear[1]) will be applied. Else if shear is a sequence of 4 values, a x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3]) will be applied. Will not apply shear by default. - interpolation (InterpolationMode): Desired interpolation enum defined by :class:`torchvision.transforms.InterpolationMode`. Default is “InterpolationMode.NEAREST“. If input is Tensor, only “InterpolationMode.NEAREST“, “InterpolationMode.BILINEAR“ are supported. For backward compatibility integer values (e.g. “PIL.Image.NEAREST“) are still acceptable. - fill (sequence or number): Pixel fill value for the area outside the transformed image. Default is “0“. If given a number, the value is used for all bands respectively. Please use the “interpolation“ parameter instead. .. _filters: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters
type RandomAutocontrast ¶
type RandomAutocontrast struct {
// contains filtered or unexported fields
}
RandomAutocontrast autocontrasts the pixels of the given image randomly with a given probability. If the image is torch Tensor, it is expected to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions. Args: - p (float): probability of the image being autocontrasted. Default value is 0.5
type RandomCrop ¶
type RandomCrop struct {
// contains filtered or unexported fields
}
type RandomCutout ¶
type RandomCutout struct {
// contains filtered or unexported fields
}
Randomly selects a rectangle region in an torch Tensor image and erases its pixels. This transform does not support PIL Image. 'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/abs/1708.04896
Args: p: probability that the random erasing operation will be performed. scale: range of proportion of erased area against input image. ratio: range of aspect ratio of erased area. value: erasing value. Default is 0. If a single int, it is used to erase all pixels. If a tuple of length 3, it is used to erase R, G, B channels respectively. If a str of 'random', erasing each pixel with random values.
type RandomEqualize ¶
type RandomEqualize struct {
// contains filtered or unexported fields
}
RandomEqualize equalizes the histogram of the given image randomly with a given probability. If the image is torch Tensor, it is expected to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions. Args: - p (float): probability of the image being equalized. Default value is 0.5 Histogram equalization Ref. https://en.wikipedia.org/wiki/Histogram_equalization
type RandomGrayscale ¶
type RandomGrayscale struct {
// contains filtered or unexported fields
}
RandomGrayscale randomly converts image to grayscale with a probability of p (default 0.1). If the image is torch Tensor, it is expected to have [..., 3, H, W] shape, where ... means an arbitrary number of leading dimensions Args: - p (float): probability that image should be converted to grayscale.
type RandomHorizontalFlip ¶
type RandomHorizontalFlip struct {
// contains filtered or unexported fields
}
RandomHorizontalFlip horizontally flips the given image randomly with a given probability.
If the image is torch Tensor, it is expected to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions Args: p (float): probability of the image being flipped. Default value is 0.5
type RandomInvert ¶
type RandomInvert struct {
// contains filtered or unexported fields
}
type RandomPerspective ¶
type RandomPerspective struct {
// contains filtered or unexported fields
}
RandomPerspective performs a random perspective transformation of the given image with a given probability. If the image is torch Tensor, it is expected to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions. Args: distortion_scale (float): argument to control the degree of distortion and ranges from 0 to 1. Default is 0.5. p (float): probability of the image being transformed. Default is 0.5. interpolation (InterpolationMode): Desired interpolation enum defined by :class:`torchvision.transforms.InterpolationMode`. Default is “InterpolationMode.BILINEAR“. If input is Tensor, only “InterpolationMode.NEAREST“, “InterpolationMode.BILINEAR“ are supported. For backward compatibility integer values (e.g. “PIL.Image.NEAREST“) are still acceptable. fill (sequence or number): Pixel fill value for the area outside the transformed image. Default is “0“. If given a number, the value is used for all bands respectively.
type RandomPosterize ¶
type RandomPosterize struct {
// contains filtered or unexported fields
}
RandomPosterize posterizes the image randomly with a given probability by reducing the number of bits for each color channel. If the image is torch Tensor, it should be of type torch.uint8, and it is expected to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions. Args: - bits (int): number of bits to keep for each channel (0-8) - p (float): probability of the image being color inverted. Default value is 0.5 Ref. https://en.wikipedia.org/wiki/Posterization
type RandomSolarize ¶
type RandomSolarize struct {
// contains filtered or unexported fields
}
RandomSolarize solarizes the image randomly with a given probability by inverting all pixel values above a threshold. If img is a Tensor, it is expected to be in [..., 1 or 3, H, W] format, where ... means it can have an arbitrary number of leading dimensions. If img is PIL Image, it is expected to be in mode "L" or "RGB". Args: - threshold (float): all pixels equal or above this value are inverted. - p (float): probability of the image being color inverted. Default value is 0.5 Ref. https://en.wikipedia.org/wiki/Solarization_(photography)
type RandomVerticalFlip ¶
type RandomVerticalFlip struct {
// contains filtered or unexported fields
}
RandomVerticalFlip vertically flips the given image randomly with a given probability.
If the image is torch Tensor, it is expected to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions Args: p (float): probability of the image being flipped. Default value is 0.5
type ResizeModule ¶
type ResizeModule struct {
// contains filtered or unexported fields
}
type RotateModule ¶
type RotateModule struct {
// contains filtered or unexported fields
}
RotateModule
type SharpnessOption ¶
type SharpnessOption func(*sharpnessOptions)
func WithSharpnessFactor ¶
func WithSharpnessFactor(f float64) SharpnessOption
func WithSharpnessPvalue ¶
func WithSharpnessPvalue(p float64) SharpnessOption
type SolarizeOption ¶
type SolarizeOption func(*solarizeOptions)
func WithSolarizePvalue ¶
func WithSolarizePvalue(p float64) SolarizeOption
func WithSolarizeThreshold ¶
func WithSolarizeThreshold(th float64) SolarizeOption
type Transformer ¶
Transformer is an interface that can transform an image tensor.
func Compose ¶
func Compose(opts ...Option) (Transformer, error)
Compose creates a new Augment struct by adding augmentation methods.