utils

package module
v0.0.0-...-b09a792 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: NCSA Imports: 20 Imported by: 0

README

Go TensorFlow Examples Reimagined

This repository is a collection of comprehensive examples for model inference utilising the TensorFlow Go API. More are continually being added. New contributors are encouraged to join in by enhancing existing examples or adding new simple examples. Please submit a pull request or an issue on GitHub for your contributions.

Models

TensorFlow Go API installation

Check out the instructions for installing Go TensorFlow here.

For inspecting pre-trained frozen graphs for input and output tensor names

Useful tools:

References

For additional support and information, visit these resources:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabel

func AddLabel(img *image.RGBA, x, y, class int, label string)

func DecodeJpegGraph

func DecodeJpegGraph() (graph *tf.Graph, input, output tf.Output, err error)

func DecodeJpegNormalizeGraph

func DecodeJpegNormalizeGraph(height int32, width int32) (graph *tf.Graph, input, output tf.Output, err error)

func GetLabel

func GetLabel(idx int, probabilities []float32, classes []float32, labels []string) string

func HLine

func HLine(img *image.RGBA, x1, y, x2 int, col color.Color)

HLine draws a horizontal line

func LoadLabels

func LoadLabels(labelsFile string) []string

func MakeTensorFromImage

func MakeTensorFromImage(filename string) (*tf.Tensor, image.Image, error)

func MakeTensorFromResizedImage

func MakeTensorFromResizedImage(filename string, inputSize int32) (*tf.Tensor, image.Image, int, int, error)

func NormalizeImageHWC

func NormalizeImageHWC(in *image.NRGBA, mean []float32, scale float32) ([]float32, error)

func Rect

func Rect(img *image.RGBA, x1, y1, x2, y2, width int, col color.Color)

Rect draws a rectangle utilizing HLine() and VLine()

func ReshapeTensorFloats

func ReshapeTensorFloats(data [][]float32, shape []int64) (*tf.Tensor, error)

func Segment

func Segment(img *image.RGBA, mask [][]float32, col color.Color, x1, y1, x2, y2 float32) *image.RGBA

Segment draws a rectangle utilizing HLine() and VLine()

func TensorData

func TensorData(c *C.TF_Tensor) []byte

func TensorPtrC

func TensorPtrC(t *tf.Tensor) *C.TF_Tensor

func ToPng

func ToPng(filePath string, imgByte []byte, bounds image.Rectangle)

func VLine

func VLine(img *image.RGBA, x, y1, y2 int, col color.Color)

VLine draws a veritcal line

Types

type Predictions

type Predictions struct {
	Indexes       []int
	Probabilities []float32
}

func (Predictions) Len

func (s Predictions) Len() int

Implement sort.Interface Len

func (Predictions) Less

func (s Predictions) Less(i, j int) bool

Implement sort.Interface Less

func (Predictions) Swap

func (s Predictions) Swap(i, j int)

Implment sort.Interface Swap

Jump to

Keyboard shortcuts

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