-
Notifications
You must be signed in to change notification settings - Fork 110
/
inference.go
37 lines (29 loc) · 1.24 KB
/
inference.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Package inference allows users to do inference through tflite (tf, pytorch, etc in the future)
package inference
import (
"github.com/pkg/errors"
"go.viam.com/rdk/ml"
)
// MLModel represents a trained machine learning model.
type MLModel interface {
// Infer takes an already ordered input tensor as an array,
// and makes an inference on the model, returning an output tensor map
Infer(inputTensors ml.Tensors) (ml.Tensors, error)
// Metadata gets the entire model metadata structure from file
Metadata() (interface{}, error)
// Close closes the model and interpreter that allows inferences to be made, opens up space in memory.
// All models must be closed when done using
Close() error
}
// FailedToLoadError is the default error message for when expected resources for inference fail to load.
func FailedToLoadError(name string) error {
return errors.Errorf("failed to load %s", name)
}
// FailedToGetError is the default error message for when expected information will be fetched fails.
func FailedToGetError(name string) error {
return errors.Errorf("failed to get %s", name)
}
// MetadataDoesNotExistError returns a metadata does not exist error.
func MetadataDoesNotExistError() error {
return errors.New("metadata does not exist")
}