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 = "mlmodel"
SubtypeName is the name of the type of service.
Variables ¶
var API = resource.APINamespaceRDK.WithServiceType(SubtypeName)
API is a variable that identifies the ML model service resource API.
Functions ¶
func NewRPCServiceServer ¶ added in v0.2.36
func NewRPCServiceServer(coll resource.APIResourceCollection[Service]) interface{}
NewRPCServiceServer constructs a ML Model gRPC service server. It is intentionally untyped to prevent use outside of tests.
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 { resource.Resource 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.
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. |