Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
choas committed Oct 5, 2018
1 parent f2e7247 commit 52416b0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 33 deletions.
12 changes: 6 additions & 6 deletions examples/image_feature_extraction.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";

const leonardo = require('sap-leonardo');

// set the API_KEY in the console, e.g. export API_KEY=abc123
var imageFeatureExtraction = new leonardo.ImageFeatureExtraction(process.env.API_KEY);

imageFeatureExtraction.featureExtraction("./testdata/chucks-153310_640.png")

.then(body => {
console.log("RESULT:", body.predictions[0].featureVectors.length, 'vectors')
// RESULT: 2048 vectors
.then((body) => {
console.log("result:", body.predictions[0].featureVectors.length, 'vectors');
// result: 2048 vectors
})
.catch(err => { console.error(err) });
.catch((err) => { console.error(err); });
12 changes: 6 additions & 6 deletions examples/imageclassification.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use strict";

const leonardo = require('sap-leonardo');

// set the API_KEY in the console, e.g. export API_KEY=abc123
var imageclassification = new leonardo.Imageclassification(process.env.API_KEY);

imageclassification.classification("./testdata/elephant-114543_640.jpg")
.then(body => {
console.log(JSON.stringify(body, null, " "));
.then((body) => {
var firstResult = body.predictions[0].results[0];
console.log("RESULT:", firstResult.label, firstResult.score)
// RESULT: tusker 0.7052137851715088
console.log("result:", firstResult.label, firstResult.score);
// result: tusker 0.7052137851715088
})
.catch(err => { console.error(err) });
.catch((err) => { console.error(err); });
12 changes: 6 additions & 6 deletions examples/multi_instance_image_segmentation.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";

const leonardo = require('sap-leonardo');

// set the API_KEY in the console, e.g. export API_KEY=abc123
var multiInstanceImageSegmentation = new leonardo.MultiInstanceImageSegmentation(process.env.API_KEY);

multiInstanceImageSegmentation.instanceSegmentor("testdata/juice-1271881_640.jpg")
.then(body => {
//console.log(JSON.stringify(body, null, " "));
console.log("RESULT:", body.predictions[0].results.length, 'segmentations');
// RESULT: 4 segmentations
.then((body) => {
console.log("result:", body.predictions[0].results.length, 'segmentations');
// result: 4 segmentations
})
.catch(err => { console.error(err) });
.catch((err) => { console.error(err); });
43 changes: 28 additions & 15 deletions examples/similarity_scoring.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
"use strict";

const leonardo = require('sap-leonardo');

// set the API_KEY in the console, e.g. export API_KEY=abc123

var similarityScoring = new leonardo.SimilarityScoring(process.env.API_KEY);

const data =
{
"0": [
{
"id": "vector_0",
"vector": [0.28340766699907016, 0.9207926435655764, 0.26789935106091334, 0.318534020870441, 0.8788578877488213, 0.4509478663720774, 0.3771976033350821, 0.8324932893262449, 0.3125285189224729, 0.0012454795540639552]
"vector": [
0.28340766699907016,
0.9207926435655764,
0.26789935106091334
]
},
{
"id": "vector_1",
"vector": [0.45833237104751445, 0.32694129428557406, 0.8764997717518421, 0.15381826488593253, 0.995488727839039, 0.5471706751917085, 0.702883336443525, 0.623838711091733, 0.12306071043362388, 0.004332364690005086]
"vector": [
0.45833237104751445,
0.32694129428557406,
0.8764997717518421
]
},
{
"id": "vector_2",
"vector": [0.3556300142239819, 0.5045324288959441, 0.7577918039699381, 0.8632635582322563, 0.633311116403191, 0.2435334301982892, 0.6287482927751646, 0.7181573415502425, 0.5023501732127003, 0.18362374274429505]
"vector": [
0.3556300142239819,
0.5045324288959441,
0.7577918039699381
]
}
]
}
};

const options = JSON.stringify({ "numSimilarVectors": 2 });

similarityScoring.similarityScoring(null, JSON.stringify(data), options)
.then(body => {
console.log(JSON.stringify(body, null, " "));
.then((body) => {
console.log(
"result:",
body.predictions[0].id,
body.predictions[0].similarVectors[0].id,
body.predictions[0].similarVectors[0].score
);

var firstPrediction = body.predictions[0];
var firstSimilarVector = firstPrediction.similarVectors[0];
console.log("RESULT:", firstPrediction.id, firstSimilarVector.id, firstSimilarVector.score);
// RESULT: RESULT: vector_0 vector_2 0.849864721937753
})
.catch(err => { console.error(err) });
// result: vector_0 vector_2 0.786171751770592
})
.catch((err) => { console.error(err); });

0 comments on commit 52416b0

Please sign in to comment.