Documentation
¶
Overview ¶
Package classifier is a Cifar-10 classifier. It loads a pre-trained model and offers a Classify method that will classify any image, by first resizing it to the model's input size.
To use it, create a Classifier with New(), and then simply call its Classify method with a 32x32 image.
This is an example of how to serve a model for inference.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
Classifier holds the Cifar-10 model compiled. It will use XLA with GPU if available or CPU by default. But the backend can be configured with GOMLX_BACKEND.
func New ¶
func New(checkpointDir string) (*Classifier, error)
New creates a new Classifier object that can be used to classify images using a Cifar-10 model.
func (*Classifier) Classify ¶
func (c *Classifier) Classify(img image.Image) (int32, error)
Classify takes a 32x32 image and returns a Cifar-10 classification according to the models. Use cifar.C10Labels to convert the returned class to a string name. The returned class is from 0 to 9.
TODO: resize image to 32x32, used by the model.