vision

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2020 License: Apache-2.0 Imports: 13 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlexNet

func AlexNet(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func Augmentation

func Augmentation(t ts.Tensor, flip bool, crop int64, cutout int64) (retVal ts.Tensor)

func DenseNet121

func DenseNet121(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func DenseNet161

func DenseNet161(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func DenseNet169

func DenseNet169(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func DenseNet201

func DenseNet201(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func EfficientNetB0

func EfficientNetB0(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func EfficientNetB1

func EfficientNetB1(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func EfficientNetB2

func EfficientNetB2(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func EfficientNetB3

func EfficientNetB3(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func EfficientNetB4

func EfficientNetB4(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func EfficientNetB5

func EfficientNetB5(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func EfficientNetB6

func EfficientNetB6(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func EfficientNetB7

func EfficientNetB7(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func InceptionV3

func InceptionV3(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func Load

func Load(path string) (retVal ts.Tensor, err error)

Load loads an image from a file.

On success returns a tensor of shape [channel, height, width].

func LoadAndResize

func LoadAndResize(path string, outW int64, outH int64) (retVal ts.Tensor, err error)

LoadAndResize loads and resizes an image, preserve the aspect ratio by taking a center crop.

func LoadDir

func LoadDir(dir string, outW int64, outH int64) (retVal ts.Tensor, err error)

LoadDir loads all the images in a directory.

func MobileNetV2

func MobileNetV2(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func RandomCrop

func RandomCrop(t ts.Tensor, pad int64) (retVal ts.Tensor)

Pad the image using reflections and take some random crops. This expects a 4 dimension NCHW tensor and returns a tensor with an identical shape.

func RandomCutout

func RandomCutout(t ts.Tensor, sz int64) (retVal ts.Tensor)

Applies cutout: randomly remove some square areas in the original images. https://arxiv.org/abs/1708.04552

func RandomFlip

func RandomFlip(t ts.Tensor) (retVal ts.Tensor)

RandomFlip randomly applies horizontal flips This expects a 4 dimension NCHW tensor and returns a tensor with an identical shape.

func ResNet18

func ResNet18(path nn.Path, numClasses int64) (retVal nn.FuncT)

Creates a ResNet-18 model.

func ResNet18NoFinalLayer

func ResNet18NoFinalLayer(path nn.Path) (retVal nn.FuncT)

func ResNet34

func ResNet34(path nn.Path, numClasses int64) (retVal nn.FuncT)

func ResNet34NoFinalLayer

func ResNet34NoFinalLayer(path nn.Path) (retVal nn.FuncT)

func ResNet50

func ResNet50(path nn.Path, numClasses int64) (retVal ts.ModuleT)

func ResNet50NoFinalLayer

func ResNet50NoFinalLayer(path nn.Path) (retVal ts.ModuleT)

func ResNet101

func ResNet101(path nn.Path, numClasses int64) (retVal ts.ModuleT)

func ResNet101NoFinalLayer

func ResNet101NoFinalLayer(path nn.Path) (retVal ts.ModuleT)

func ResNet150NoFinalLayer

func ResNet150NoFinalLayer(path nn.Path) (retVal ts.ModuleT)

func ResNet152

func ResNet152(path nn.Path, numClasses int64) (retVal ts.ModuleT)

func Resize

func Resize(t ts.Tensor, outW int64, outH int64) (retVal ts.Tensor, err error)

Resize resizes an image.

This expects as input a tensor of shape [channel, height, width] and returns a tensor of shape [channel, out_h, out_w].

func ResizePreserveAspectRatio

func ResizePreserveAspectRatio(t ts.Tensor, outW int64, outH int64) (retVal ts.Tensor, err error)

ResizePreserveAspectRatio resizes an image, preserve the aspect ratio by taking a center crop.

This expects as input a tensor of shape [channel, height, width] and returns

func Save

func Save(tensor ts.Tensor, path string) (err error)

Save saves an image to a file.

This expects as input a tensor of shape [channel, height, width]. The image format is based on the filename suffix, supported suffixes are jpg, png, tga, and bmp. The tensor input should be of kind UInt8 with values ranging from 0 to 255.

func SqueezeNetV1_0

func SqueezeNetV1_0(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func SqueezeNetV1_1

func SqueezeNetV1_1(p nn.Path, nclasses int64) (retVal ts.ModuleT)

func VGG11

func VGG11(path nn.Path, nclasses int64) (retVal nn.SequentialT)

func VGG11BN

func VGG11BN(path nn.Path, nclasses int64) (retVal nn.SequentialT)

func VGG13

func VGG13(path nn.Path, nclasses int64) (retVal nn.SequentialT)

func VGG13BN

func VGG13BN(path nn.Path, nclasses int64) (retVal nn.SequentialT)

func VGG16

func VGG16(path nn.Path, nclasses int64) (retVal nn.SequentialT)

func VGG16BN

func VGG16BN(path nn.Path, nclasses int64) (retVal nn.SequentialT)

func VGG19

func VGG19(path nn.Path, nclasses int64) (retVal nn.SequentialT)

func VGG19BN

func VGG19BN(path nn.Path, nclasses int64) (retVal nn.SequentialT)

Types

type BlockArgs

type BlockArgs struct {
	KernelSize   int64
	NumRepeat    int64
	InputFilters int64
	OutputFilter int64
	ExpandRatio  int64
	SeRatio      float64
	Stride       int64
}

type Dataset

type Dataset struct {
	TrainImages ts.Tensor
	TrainLabels ts.Tensor
	TestImages  ts.Tensor
	TestLabels  ts.Tensor
	Labels      int64
}

func CFLoadDir

func CFLoadDir(dir string) (retVal Dataset)

func LoadMNISTDir

func LoadMNISTDir(dir string) (retVal Dataset)

LoadMNISTDir loads all MNIST data from a given directory to Dataset

func (Dataset) TestIter

func (ds Dataset) TestIter(batchSize int64) (retVal ts.Iter2)

TestIter creates an iterator of Iter type for test images and labels

func (Dataset) TrainIter

func (ds Dataset) TrainIter(batchSize int64) (retVal ts.Iter2)

TrainIter creates an iterator of Iter type for train images and labels

type ImageNet

type ImageNet struct {
	// contains filtered or unexported fields
}

func NewImageNet

func NewImageNet() ImageNet

func (ImageNet) ClassCount

func (in ImageNet) ClassCount() (retVal int64)

func (ImageNet) Classes

func (in ImageNet) Classes() (retVal []string)

func (ImageNet) LoadFromDir

func (in ImageNet) LoadFromDir(path string) (retVal Dataset, err error)

LoadFromDir loads a dataset from a directory.

NOTE: This assumes that the directory contains two subdirectories named train and val. In each of these datasets, there should be a subdirectory per class named in the same way. The ImageNet normalization is applied, image are resized to 224x224.

func (ImageNet) LoadImage

func (in ImageNet) LoadImage(path string) (retVal ts.Tensor, err error)

Load loads an image from a file and applies the ImageNet normalization.

func (ImageNet) LoadImageAndResize

func (in ImageNet) LoadImageAndResize(path string, w, h int64) (retVal ts.Tensor, err error)

LoadImageAndResize loads an image from a file and resize it to the specified width and height.

NOTE: This will apply the ImageNet normalization.

func (ImageNet) LoadImageAndResize224

func (in ImageNet) LoadImageAndResize224(path string) (retVal ts.Tensor, err error)

LoadImageAndResize224 loads an image from a file and resize it to 224x224.

NOTE: This will apply the ImageNet normalization.

func (ImageNet) Normalize

func (in ImageNet) Normalize(tensor ts.Tensor) (retVal ts.Tensor, err error)

func (ImageNet) SaveImage

func (in ImageNet) SaveImage(tensor ts.Tensor, path string) (err error)

SaveImage saves a tensor image to a path.

NOTE: This will carry out the ImageNet unnormalization.

func (ImageNet) Top

func (in ImageNet) Top(input ts.Tensor, k int64) (retVal []TopItem)

Returns the top k classes as well as the associated scores.

func (ImageNet) UnNormalize

func (in ImageNet) UnNormalize(tensor ts.Tensor) (retVal ts.Tensor, err error)

type TopItem

type TopItem struct {
	Pvalue float64
	Label  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL