predictor

package
v0.2.23-0...-4aaa12c Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: NCSA Imports: 29 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultInputLayerName   = "input"
	DefaultOutputLayerNames = []string{"output"}
)

Functions

This section is empty.

Types

type Base

type Base struct {
	Framework dlframework.FrameworkManifest
	Model     dlframework.ModelManifest
	WorkDir   string
	Options   *options.Options
}

func (Base) BatchSize

func (b Base) BatchSize() int

func (Base) FeatureLimit

func (b Base) FeatureLimit() int

func (Base) GPUMetrics

func (b Base) GPUMetrics() string

func (Base) GetFeaturesUrl

func (p Base) GetFeaturesUrl() string

func (Base) GetGraphChecksum

func (p Base) GetGraphChecksum() string

func (Base) GetGraphPath

func (p Base) GetGraphPath() string

func (Base) GetGraphUrl

func (p Base) GetGraphUrl() string

func (Base) GetPredictionOptions

func (b Base) GetPredictionOptions() (*options.Options, error)

func (Base) GetPreprocessOptions

func (p Base) GetPreprocessOptions() (PreprocessOptions, error)

func (Base) GetTypeParameter

func (p Base) GetTypeParameter(typeParameters map[string]*dlframework.ModelManifest_Type_Parameter, name string) (string, error)

func (Base) GetWeightsChecksum

func (p Base) GetWeightsChecksum() string

func (Base) GetWeightsPath

func (p Base) GetWeightsPath() string

func (Base) GetWeightsUrl

func (p Base) GetWeightsUrl() string

func (Base) Modality

func (b Base) Modality() (dlframework.Modality, error)

func (Base) TraceLevel

func (b Base) TraceLevel() tracer.Level

func (Base) UseGPU

func (b Base) UseGPU() bool

type ImagePredictor

type ImagePredictor struct {
	Base
	Metadata map[string]interface{}
}

func (ImagePredictor) Close

func (p ImagePredictor) Close() error

func (ImagePredictor) CreateBoundingBoxFeatures

func (p ImagePredictor) CreateBoundingBoxFeatures(ctx context.Context, probabilities0 interface{}, classes0 interface{}, boxes0 interface{}, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) CreateBoundingBoxFeaturesFlattened

func (p ImagePredictor) CreateBoundingBoxFeaturesFlattened(ctx context.Context, probabilities []float32, classes []float32, boxes []float32, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) CreateBoundingBoxFeaturesUnflattened

func (p ImagePredictor) CreateBoundingBoxFeaturesUnflattened(ctx context.Context, probabilities [][]float32, classes [][]float32, boxes [][][]float32, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) CreateClassificationFeatures

func (p ImagePredictor) CreateClassificationFeatures(ctx context.Context, probabilities0 interface{}, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) CreateClassificationFeaturesFrom1D

func (p ImagePredictor) CreateClassificationFeaturesFrom1D(ctx context.Context, probabilities []float32, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) CreateClassificationFeaturesFrom2D

func (p ImagePredictor) CreateClassificationFeaturesFrom2D(ctx context.Context, probabilities [][]float32, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) CreateImageFeatures

func (p ImagePredictor) CreateImageFeatures(ctx context.Context, images [][][][]float32) ([]dlframework.Features, error)

func (ImagePredictor) CreateInstanceSegmentFeatures

func (p ImagePredictor) CreateInstanceSegmentFeatures(ctx context.Context, probabilities [][]float32, classes [][]float32, boxes [][][]float32, masks [][][][]float32, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) CreateRawImageFeatures

func (p ImagePredictor) CreateRawImageFeatures(ctx context.Context, images [][][][]float32) ([]dlframework.Features, error)

func (ImagePredictor) CreateSemanticSegmentFeatures

func (p ImagePredictor) CreateSemanticSegmentFeatures(ctx context.Context, masks0 interface{}, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) CreateSemanticSegmentFeaturesFrom2D

func (p ImagePredictor) CreateSemanticSegmentFeaturesFrom2D(ctx context.Context, masks [][][]int64, labels []string) ([]dlframework.Features, error)

func (ImagePredictor) GetColorMode

func (p ImagePredictor) GetColorMode(defaultMode types.Mode) types.Mode

func (ImagePredictor) GetCropMethod

func (p ImagePredictor) GetCropMethod(defaultMethod cutter.AnchorMode) cutter.AnchorMode

func (ImagePredictor) GetCropRatio

func (p ImagePredictor) GetCropRatio(defaultCropRatio float32) float32

func (ImagePredictor) GetFeatureType

func (p ImagePredictor) GetFeatureType() dlframework.FeatureType

func (ImagePredictor) GetFeaturesChecksum

func (p ImagePredictor) GetFeaturesChecksum() string

func (ImagePredictor) GetFeaturesPath

func (p ImagePredictor) GetFeaturesPath() string

func (ImagePredictor) GetInputDimensions

func (p ImagePredictor) GetInputDimensions() ([]int, error)

func (ImagePredictor) GetInputLayerName

func (p ImagePredictor) GetInputLayerName(layer string) (string, error)

func (ImagePredictor) GetKeepAspectRatio

func (p ImagePredictor) GetKeepAspectRatio() (bool, error)

func (ImagePredictor) GetLabels

func (p ImagePredictor) GetLabels() ([]string, error)

func (ImagePredictor) GetLayout

func (p ImagePredictor) GetLayout(defaultLayout raiimage.Layout) raiimage.Layout

func (ImagePredictor) GetMaxDimension

func (p ImagePredictor) GetMaxDimension() (int, error)

func (ImagePredictor) GetMeanImage

func (p ImagePredictor) GetMeanImage() ([]float32, error)

func (ImagePredictor) GetMeanPath

func (p ImagePredictor) GetMeanPath() string

func (ImagePredictor) GetOutputLayerIndex

func (p ImagePredictor) GetOutputLayerIndex(layer string) (int, error)

func (ImagePredictor) GetPreprocessOptions

func (p ImagePredictor) GetPreprocessOptions() (PreprocessOptions, error)

func (ImagePredictor) GetProbabilitiesTransform

func (p ImagePredictor) GetProbabilitiesTransform() string

func (ImagePredictor) GetScale

func (p ImagePredictor) GetScale() ([]float32, error)

func (ImagePredictor) Reset

func (p ImagePredictor) Reset(ctx context.Context) error

type Predictor

type Predictor interface {
	// Gets framework and model manifests
	Info() (dlframework.FrameworkManifest, dlframework.ModelManifest, error)
	// Gets predictor's Modality
	Modality() (dlframework.Modality, error)
	// Downloads model from manifest
	Download(ctx context.Context, model dlframework.ModelManifest, opts ...options.Option) error
	// Load model from manifest
	Load(ctx context.Context, model dlframework.ModelManifest, opts ...options.Option) (Predictor, error)
	// Returns the prediction options
	GetPredictionOptions() (*options.Options, error)
	// Returns the preprocess options
	GetPreprocessOptions() (PreprocessOptions, error)
	// Returns the handle to features
	Predict(ctx context.Context, data interface{}, opts ...options.Option) error
	// Returns the features
	ReadPredictedFeatures(ctx context.Context) ([]dlframework.Features, error)
	// Clears the internal state of a predictor
	Reset(ctx context.Context) error

	io.Closer
}

type PreprocessOptions

type PreprocessOptions struct {
	ElementType     string
	MeanImage       []float32
	Scale           []float32
	Dims            []int
	MaxDimension    *int
	KeepAspectRatio *bool
	ColorMode       types.Mode
	Layout          raiimage.Layout
	CropMethod      cutter.AnchorMode
	CropRatio       float32
}

type RawPredictor

type RawPredictor struct {
	Base
	Metadata map[string]interface{}
}

func (RawPredictor) Close

func (p RawPredictor) Close() error

func (RawPredictor) GetInputDataByIdx

func (p RawPredictor) GetInputDataByIdx(idx int) ([]interface{}, error)

func (RawPredictor) GetInputParams

func (p RawPredictor) GetInputParams(name string) ([]string, error)

func (RawPredictor) GetInputParamsByIdx

func (p RawPredictor) GetInputParamsByIdx(idx int, name string) (string, error)

func (RawPredictor) GetInputURLs

func (p RawPredictor) GetInputURLs() ([]string, error)

func (RawPredictor) GetOutputLayerName

func (p RawPredictor) GetOutputLayerName(layer string) (string, error)

func (RawPredictor) ReadPredictedFeatures

func (p RawPredictor) ReadPredictedFeatures(ctx context.Context) ([]dlframework.Features, error)

func (RawPredictor) Reset

func (p RawPredictor) Reset(ctx context.Context) error

Jump to

Keyboard shortcuts

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