This repository showcases how to use the Salesforce Einstein Vision API using an Apex based wrapper.
Please check the product documentation for general information about what the Salesforce Einstein Vision API is, how to use it and when it'll be available for you.
For running the app on your own you'll need to fulfill the following requirements:
Please find the detailed instructions for how to setup access to the Einstein Vision API here.
It is recommended to upload the source code to the org of your choice i. e. with the Force.com IDE.
You can also install the current version as an unmanaged package.
As this library is basically a wrapper for using the Salesforce Einstein Vision API it is highly recommended to checkout the API documentation.
The workflow for using Einstein Vision can be described with the following scenario.
Please check the MetaMind documentation for recommendations regarding image quality, amount of examples and so forth.
The foundation for everything is the PredictionService
. As the communication with the API is based on a valid OAuth2 token (see MetaMind documentation) you can initiate a new PredictionService in the following way.
EinsteinVision_PredictionService predictionService = new EinsteinVision_PredictionService("AASDFNSADF23423424SADSFASF");
You can predict images either by sending Base64, uploading a Blob or a remote (publicly available!) URL. See this example how to validate a remote URL.
EinsteinVision_PredictionResult result = service.predictUrl(modelId, beachUrl, "");
The returned result will give you an array of all Labels within the Dataset and their probability.
You can find two Lightning examples here in the GitHub repo.
Feel free to contribute to this project via pull requests.
For licensing see the included license file.