The overall achitecture of this project could be found below:

(1) we build a native mobile application for end users via React-Native technology.

(2) A restful API is deployed in SAP Cloud Platform’s Cloud Foundry Environment. This API is technically implemented by default a nodejs application running in SAP Cloud Platform. Once end users make a photo by this application, the binary stream of photo will be sent to restful API, And it’s expected that the top three pictures which have the largest image similarity with the current photo are sent back.

(3) The restful API fulfills the image similarity calculation tasks by leveraging two Leonardo Machine Learning services in SAP Cloud Platform:

a. Image Feature Extraction

b. Image Similarity Scoring

The binary stream of photo taken by end users will be translated by SAP Leonardo Image Feature Extraction service into a Series of feature Vectors. You can find one example from SAP help below: help.sap.com/viewer/b04a…

The consumption of this service is implemented in The project by The file “featureExtractionService. Js” under The folder “Toolbox”.

The recognization of top 3 similar images is achieved by calling another Leonardo Machine Learning service: Image Similarity Scoring. In order to ease consumption of this service, the project exposes an endpoint /getSimilarImage defined in file “index.js”.

To consume it, you can simply specify the binary stream of a given image, and this API will call Leonardo Machine Learning “Image Similarity Scoring” to return the top 3 similar images.

The Similar Scoring service will compare the feature vector of the given image with a couple of prepared feature vectors stored in image repository of the project.

The image repository is maintained in the project consisting of two folders: refImages and refFeatureVectors, while the former stores each picture file itself, the latter stores its corresponding feature vector.

If it is required to involve more pictures, you can simply put the new picture to folder “refImages”, And its feature vector to Folder “refFeatureVectors”, Both should have the same incremental index. In the folder there is a tool “featureExtractor.js” which helps you get the corresponding feature vector of a given image by command line.

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: