Java Face Embedder Example¶
Initialize face embedder model
import org.sertiscorp.oneml.face.*;
FaceEmbedder embedder = new FaceEmbedder();
Initialize face embedder model with licensing
import org.sertiscorp.oneml.face.*;
LicenseManager licenseManager = new LicenseManager();
licenseManager.setKey("LICENSE_KEY_VALUE_HERE");
licenseManager.activateKey();
FaceEmbedder embedder = new FaceEmbedder(licenseManager);
Initialize oneML’s Utils
Utils utils = new Utils();
Initialize oneML’s Utils with licensing
Utils utils = new Utils(licenseManager);
Read input as BufferedImage
BufferedImage img = getImage(path);
int width = img.getWidth();
int height = img.getHeight();
short depth = (short) img.getColorModel().getPixelSize();
byte[] byteArray = toRGBByteArray(img);
ImageBatch batch = new ImageBatch().add(byteArray, width, height, depth);
Read input as oneML’s Image
Image img = utils.readImageCV(filePath);
Run the model
FaceEmbedderResultList results = embedder.embed(batch);
or
FaceEmbedderResult result = embedder.embed(img);
To enable flipped image embedding, run
FaceEmbedderResult result = embedder.embed(img, true);
And get the output
float[] emb = result.getEmbedding();
int status = result.getReturnStatus();
Cleanup
embedder.delete();
utils.delete();