vision

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlexNet

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

func Augmentation

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

func DenseNet121

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

func DenseNet161

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

func DenseNet169

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

func DenseNet201

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

func EfficientNetB0

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

func EfficientNetB1

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

func EfficientNetB2

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

func EfficientNetB3

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

func EfficientNetB4

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

func EfficientNetB5

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

func EfficientNetB6

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

func EfficientNetB7

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

func InceptionV3

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

func Load

func Load(path string) (*ts.Tensor, 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) (*ts.Tensor, 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) (*ts.Tensor, error)

LoadDir loads all the images in a directory.

func MobileNetV2

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

func RandomCrop

func RandomCrop(t *ts.Tensor, pad int64) *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) *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) *ts.Tensor

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

func ResNet101

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

ResNet101 creates a ResNet-101 model.

func ResNet101NoFinalLayer

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

ResNet101 creates a ResNet-101 model without final fully connfected layer.

func ResNet150NoFinalLayer

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

ResNet150 creates a ResNet-150 model without final fully connfected layer.

func ResNet152

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

ResNet152 creates a ResNet-152 model.

func ResNet18

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

ResNet18 creates a ResNet-18 model.

func ResNet18NoFinalLayer

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

ResNet18 creates a ResNet-18 model without final fully connfected layer.

func ResNet34

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

ResNet34 creates a ResNet-34 model.

func ResNet34NoFinalLayer

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

ResNet34 creates a ResNet-34 model without final fully connfected layer.

func ResNet50

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

ResNet50 creates a ResNet-50 model.

func ResNet50NoFinalLayer

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

ResNet50 creates a ResNet-50 model without final fully connfected layer.

func Resize

func Resize(t *ts.Tensor, outW int64, outH int64) (*ts.Tensor, 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) (*ts.Tensor, 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) 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) ts.ModuleT

func SqueezeNetV1_1

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

func VGG11

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

func VGG11BN

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

func VGG13

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

func VGG13BN

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

func VGG16

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

func VGG16BN

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

func VGG19

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

func VGG19BN

func VGG19BN(path *nn.Path, nclasses int64) *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) *Dataset

func LoadMNISTDir

func LoadMNISTDir(dir string) *Dataset

LoadMNISTDir loads all MNIST data from a given directory to Dataset

func (*Dataset) TestIter

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

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

func (*Dataset) TrainIter

func (ds *Dataset) TrainIter(batchSize int64) *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() int64

func (*ImageNet) Classes

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

func (*ImageNet) LoadFromDir

func (in *ImageNet) LoadFromDir(path string) (*Dataset, 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) (*ts.Tensor, 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) (*ts.Tensor, 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) (*ts.Tensor, 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) (*ts.Tensor, error)

func (*ImageNet) SaveImage

func (in *ImageNet) SaveImage(tensor *ts.Tensor, path string) 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) []TopItem

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

func (*ImageNet) UnNormalize

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

type TopItem

type TopItem struct {
	Pvalue float64
	Label  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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