orml-image-classifier
provides image classification and embedding based on ImageNet labelings.
orml-image-classifier
performs two tasks: image classification and image embedding. Image classification finds
which (predefined) classes best match an input image.
Image embedding finds a high dimensional vector (1001 dimensions) that can be seen as a fingerprint for the image. The idea is that similar images result in similar fingerprints.
First load the classifier model.
val classifier = ImageClassifier.load()
To classify an image we ask the classifier
for classification scores for all classes.
val scores = classifier.classify(image)
Here scores
is a FloatArray
for which the i-th element describes the score for the i-th label in imagenetLabels
.
val scoredLabels = (scores zip imagenetLabels)
To get the image embedding:
val embedding = classifier.embed(image)
In DemoClassifier.kt we show the complete process for classifying an image.
In DemoEmbedding.kt we demonstrate how to find an image embedding and show a simple way to visualize the embedding as a grid of circles.
Based on
- Pretrained MobileNetv3
- Simple Imagenet labels from @anishathalye (GitHub)