tfsymbol

package
v0.0.0-...-5672997 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageToTensorValue

func ImageToTensorValue(img image.Image) [][][][]float32

ImageToTensorValue return an array with shape [1,50,180,4] for tensor as an input

Types

type HTTPDoer

type HTTPDoer interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPDoer is an interface that provides a way to make HTTP requests.

type LabelLookup

type LabelLookup interface {
	// BestMatch returns the label with the highest probability.
	BestMatch(probabilities []float32) (string, error)
}

LabelLookup is an interface that provides a way to look up the label of the symbol.

type Labels

type Labels []string

Labels is a slice of strings that represents the labels of the model.

func ReadLabels

func ReadLabels(labelsFile string) (Labels, error)

ReadLabels reads the labels from a file and returns them as a slice of strings.

func (Labels) BestMatch

func (s Labels) BestMatch(probabilities []float32) (string, error)

BestMatch returns the label with the highest probability.

type Option

type Option func(*options) error

Option is a function that sets an option on the RemoteResolver.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL sets the base URL of the TensorFlow Serving server. The default is http://localhost:8501.

func WithHTTPClient

func WithHTTPClient(c HTTPDoer) Option

WithHTTPClient sets the HTTP client to use for making requests to the TensorFlow Serving server. The default is http.DefaultClient.

func WithModelName

func WithModelName(name string) Option

WithModelName sets the name of the model to use for prediction.

The default is "resnet".

type RemoteResolver

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

RemoteResolver is a struct that resolves the symbol of the image using the TensorFlow Serving server.

func NewRemoteResolver

func NewRemoteResolver(labels LabelLookup, opt ...Option) (*RemoteResolver, error)

NewRemoteResolver creates a new RemoteResolver that uses the TensorFlow Serving server to resolve symbols.

func (*RemoteResolver) SymbolResolve

func (s *RemoteResolver) SymbolResolve(ctx context.Context, img image.Image) (string, error)

SymbolResolve resolves the symbol of the image using the TensorFlow Serving server.

Jump to

Keyboard shortcuts

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