2
以下のコードをNode.jsに書き込んで分類器を作成し、Visual Recognition APIバージョン3を使用して画像を分類します。作成された分類子。IBM Visual Recognition APIバージョン3を使用して画像を分類する方法
以前のバージョンと同じコードが動作しています。あなたの考えを共有してください。
ありがとうございます!
var visual_recognition, params;
var ONE_HOUR = 3600000;
var CLASSIFIERID = [];
// Create the service wrapper
visual_recognition = watson.visual_recognition({
version: 'v3',
api_key: process.env.API_KEY || '<api-key>',
version_date: '2015-05-19'
});
作成classfier:
params = {
name: constants.DRIVERNAME,
driverOne_positive_examples: fs.createReadStream('./public/positive.zip'),
negative_examples: fs.createReadStream('./public/negative.zip')
};
visual_recognition.createClassifier(params, function(err, classifier) {
if (err){
res.render('showError',{title:constants.TITLE1,
err:'Something went wrong!'
});
}
else{
CLASSIFIERID.push(classifier.classifier_id);
}
});
分類の画像:あなたは、配列を使用してclassifier_ids
を指定する必要が
var parm = {
images_file: img_classify,
classifier_ids: CLASSIFIERID,
threshold: 0.0
};
visual_recognition.classify(parm, function(err, results) {
var driverName,driverScore,driverId,driver;
if (err){
console.log('Error at classification!!!');
}
else{
console.log('Image has been classified!!!');
res.json(results);
}
エラーは何ですか?どんな種類のログがありますか? – joe
こんにちは、Joe、 エラーは発生していませんが、画像を分類した後で、JSONのデータが「結果」になっています。 {{"classifiers":[]、 "image": "test.jpg"}]、 "images_processed":1}のいずれかを入力してください。 – phanindra