sap-leonardo
Advanced tools
Comparing version 0.5.7 to 0.5.8
@@ -5,4 +5,8 @@ # CHANGELOG | ||
## next | ||
## 0.5.8 | ||
- image classification service handles filenames and buffers | ||
## 0.5.7 | ||
- rename image_classification | ||
@@ -9,0 +13,0 @@ - more examples |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { Promise } from "es6-promise"; | ||
@@ -6,4 +7,5 @@ export declare class Imageclassification { | ||
constructor(apiKey: any, baseUrl?: string); | ||
classification(files: string): Promise<any>; | ||
classification(files: string | Buffer): Promise<any>; | ||
customizable(modelName: string, version: string, files: string): Promise<any>; | ||
private call; | ||
} |
@@ -15,21 +15,13 @@ "use strict"; | ||
return new es6_promise_1.Promise((resolve, reject) => { | ||
fs.readFile(files, {}, (fileErr, fileData) => { | ||
if (fileErr) { | ||
return reject(fileErr); | ||
} | ||
const formData = { | ||
files: { value: fileData, options: files }, | ||
}; | ||
const headers = { | ||
APIKey: this.apiKey, | ||
Accept: "application/json", | ||
}; | ||
const url = this.baseUrl + "/ml/imageclassification/classification"; | ||
request.post({ url, formData, headers }, (err, response, body) => { | ||
if (err) { | ||
return reject(err); | ||
if (Buffer.isBuffer(files)) { | ||
this.call(resolve, reject, "image.jpg", files); | ||
} | ||
else { | ||
fs.readFile(files, {}, (fileErr, fileData) => { | ||
if (fileErr) { | ||
return reject(fileErr); | ||
} | ||
resolve(JSON.parse(body)); | ||
this.call(resolve, reject, files, fileData); | ||
}); | ||
}); | ||
} | ||
}); | ||
@@ -44,3 +36,19 @@ } | ||
} | ||
call(resolve, reject, files, fileData) { | ||
const formData = { | ||
files: { value: fileData, options: files }, | ||
}; | ||
const headers = { | ||
APIKey: this.apiKey, | ||
Accept: "application/json", | ||
}; | ||
const url = this.baseUrl + "/ml/imageclassification/classification"; | ||
request.post({ url, formData, headers }, (err, response, body) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
resolve(JSON.parse(body)); | ||
}); | ||
} | ||
} | ||
exports.Imageclassification = Imageclassification; |
{ | ||
"name": "sap-leonardo", | ||
"version": "0.5.7", | ||
"version": "0.5.8", | ||
"description": "NPM module for SAP Leonardo Machine Learning Foundation - Functional Services https://api.sap.com/package/SAPLeonardoMLFunctionalServices", | ||
@@ -54,3 +54,3 @@ "main": "dist/index.js", | ||
"coveralls": "^3.0.2", | ||
"eslint": "^5.9.0", | ||
"eslint": "^5.13.0", | ||
"istanbul": "^1.1.0-alpha.1", | ||
@@ -60,5 +60,5 @@ "log4js": "^3.0.6", | ||
"ts-node": "^7.0.1", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.6" | ||
"tslint": "^5.12.1", | ||
"typescript": "^3.3.1" | ||
} | ||
} |
@@ -62,3 +62,3 @@ # SAP Leonardo Machine Learning Foundation - Functional Services | ||
- [Inference Service for Language Detection](https://api.sap.com/api/language_detection_api/resource) | ||
- ~~[Inference Service for Customizable Object Detection](https://api.sap.com/api/object_detection_api/resource)~~ | ||
- ~~[Inference Service for Customizable Object Detection](https://api.sap.com/api/object_detection_api/resource)~~ (API Sandbox is not available) | ||
- [Inference Service for Optical Character Recognition (OCR)](https://api.sap.com/api/ocr_api/resource) | ||
@@ -65,0 +65,0 @@ |
54069
880