Documentation
¶
Overview ¶
Package mlmodel defines the client and server for a service that can take in a map of input tensors/arrays, pass them through an inference engine, and then return a map output tensors/arrays.
Index ¶
Constants ¶
const ( // LabelTypeUnspecified means the label type is not known. LabelTypeUnspecified = LabelType("UNSPECIFIED") // LabelTypeTensorValue means the labels are assigned by the actual value in the tensor // e.g. for 4 results and 3 categories : [0, 1, 2, 1]. LabelTypeTensorValue = LabelType("TENSOR_VALUE") // LabelTypeTensorAxis means labels are assigned by the position within the tensor axis // e.g. for 4 results and 3 categories : [[.8, .1, .1], [.2, .7, .1], [.1, .1, .8],[.05, .9, .05]]. LabelTypeTensorAxis = LabelType("TENSOR_AXIS") )
const SubtypeName = resource.SubtypeName("mlmodel")
SubtypeName is the name of the type of service.
Variables ¶
var Subtype = resource.NewSubtype( resource.ResourceNamespaceRDK, resource.ResourceTypeService, SubtypeName, )
Subtype is a constant that identifies the ML model service resource subtype.
Functions ¶
func NewServer ¶
func NewServer(s subtype.Service) pb.MLModelServiceServer
NewServer constructs a ML Model gRPC service server.
func NewUnimplementedInterfaceError ¶
func NewUnimplementedInterfaceError(actual interface{}) error
NewUnimplementedInterfaceError is used when there is a failed interface check.
Types ¶
type File ¶
type File struct { Name string // e.g. category_labels.txt Description string LabelType LabelType // TENSOR_VALUE, or TENSOR_AXIS }
File contains information about how to interpret the numbers within the tensor/array. The label type describes how to read the tensor in order to successfully label the numbers.
type LabelType ¶
type LabelType string
LabelType describes how labels from the file are assigned to the tensors. TENSOR_VALUE means that labels are the actual value in the tensor. TENSOR_AXIS means that labels are positional within the tensor axis.
type MLMetadata ¶
type MLMetadata struct { ModelName string ModelType string // e.g. object_detector, text_classifier ModelDescription string Inputs []TensorInfo Outputs []TensorInfo }
MLMetadata contains the metadata of the model file, such as the name of the model, what kind of model it is, and the expected tensor/array shape and types of the inputs and outputs of the model.
type Service ¶
type Service interface { Infer(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error) Metadata(ctx context.Context) (MLMetadata, error) }
Service defines the ML Model interface, which takes a map of inputs, runs it through an inference engine, and creates a map of outputs. Metadata is necessary in order to build the struct that will decode that map[string]interface{} correctly.
func NewClientFromConn ¶
func NewClientFromConn(ctx context.Context, conn rpc.ClientConn, name string, logger golog.Logger) Service
NewClientFromConn constructs a new Client from connection passed in.
type TensorInfo ¶
type TensorInfo struct { Name string // e.g. bounding_boxes Description string DataType string // e.g. uint8, float32, int Shape []int // number of dimensions in the array AssociatedFiles []File Extra map[string]interface{} }
TensorInfo contains all the information necessary to build a struct from the input and output maps. it describes the name of the output field, what data type it has, and how many dimensions the array/tensor will have. AssociatedFiles points to where more information is located, e.g. in case the ints within the array/tensor need to be converted into a string.
Directories
¶
Path | Synopsis |
---|---|
Package register registers all relevant ML model services
|
Package register registers all relevant ML model services |
Package tflitecpu runs tflite model files on the host's CPU, as an implementation the ML model service.
|
Package tflitecpu runs tflite model files on the host's CPU, as an implementation the ML model service. |