Salesforce recently released the Salesforce Predictive Vision Services Pilot. You can watch the corresponding webinar.
I went through the Apex Quick Start steps and thought I could simplify them a bit. At the end of the process you should have the basic Apex and a visualforce page to test image predictions against.
Steps
- Sign up for a predictive services account using a Developer Org. The instructions here are fairly straight forward.
Go to https://metamind.io/ and use the Free Sign Up link. OAuth to your dev org. Download the resulting predictive_services.pem file that contains your private key and make note of the "you've signed up with" email address. You will need the file later and the email address if your org users email address differs.
- Note: the signup is associated with the Users Email address, not the username. So you might get conflicts between multiple dev orgs sharing the same email address.
- Upload your predictive_services.pem private key to the same developer org into Files and title it 'predictive_services'. This title is used to get the details of the private key by the Apex Code.
- The Spring '17 release has the Long Text Areas in Custom Metadata Types (Pilot) which would allow a custom metadata setting to store the 2KB private key. Until then Content seems to be the easiest place to keep it.
- Install the unmanaged package that I created (Requires Spring '17).
I've pulled the required parts together from https://github.com/salesforceidentity/jwt and https://github.com/MetaMind/apex-utils. I've also made some modifications to the Visualforce page and corresponding controller to give more flexibility defining the image URL. - Browse to the PredictService Visualforce Tab.
- Press the [Vision From Url] button.
- Examine the predictions against the General Image Model Class List.
- Change the Image URL to something publicly accessible and repeat the previous couple of steps as required.