训练自己的分类器 IBM Watson Visual Recognition Unity3d
Train own classifier IBM Watson Visual Recognition Unity3d
我已经按照安装 SDK 和配置服务凭据的步骤进行操作。问题是我无法训练自己的分类器。我收到此错误:No overload for method 'TrainClassifier' takes 5 arguments
.
void Start()
{
string m_positiveExamplesPath = Application.dataPath + "/testData/cpu_positive_examples.zip";
string m_negativeExamplesPath = Application.dataPath + "/testData/negative_examples.zip";
if(!m_VisualRecognition.TrainClassifier("components", "cpu", m_positiveExamplesPath, m_negativeExamplesPath, OnTrainClassifier))
Log.Debug("ExampleVisualRecognition", "Train classifier failed!");
}
private void OnTrainClassifier(GetClassifiersPerClassifierVerbose classifier)
{
if(classifier != null)
{
Log.Debug("ExampleVisualRecognition", "Classifier is training! " + classifier);
}
else
{
Log.Debug("ExampleVisualRecognition", "Failed to train classifier!");
}
}
Here是GitHub中SDK的link。谢谢!
您从 example page 复制了该代码,但看起来该页面上的所有内容都已过时。需要IBM更新。
VisualRecognition
class 有 2 个重载 TrainClassifier
:
public bool TrainClassifier(OnTrainClassifier callback, string classifierName, Dictionary<string, string> positiveExamples, string negativeExamplesPath = default(string), string mimeType = "application/zip", string customData = default(string))
和
public bool TrainClassifier(OnTrainClassifier callback, string classifierName, Dictionary<string, byte[]> positiveExamplesData, byte[] negativeExamplesData = null, string mimeType = "application/zip", string customData = default(string))
SDK 就在您面前。下次遇到这样的错误时,select 函数,右键单击 转到定义 。它将向您显示函数的重载,然后您将能够在其中传递正确的参数。
你的代码应该是这样的:
private VisualRecognition m_VisualRecognition = new VisualRecognition();
void Start()
{
string m_positiveExamplesPath = Application.dataPath + "/testData/cpu_positive_examples.zip";
string m_negativeExamplesPath = Application.dataPath + "/testData/negative_examples.zip";
Dictionary<string, string> positiveExamples = new Dictionary<string, string>();
positiveExamples.Add("giraffe", m_positiveExamplesPath);
if (!m_VisualRecognition.TrainClassifier(OnTrainClassifier, "unity-test-classifier-example", positiveExamples, m_negativeExamplesPath))
Log.Debug("ExampleVisualRecognition", "Train classifier failed!");
}
private void OnTrainClassifier(GetClassifiersPerClassifierVerbose classifier, string data)
{
if (classifier != null)
{
Log.Debug("ExampleVisualRecognition", "Classifier is training! " + classifier);
}
else
{
Log.Debug("ExampleVisualRecognition", "Failed to train classifier!");
}
}
如果您需要任何其他示例,不要 从 example page 中获取它。从插件附带的 Example 文件夹 中获取它。
我已经按照安装 SDK 和配置服务凭据的步骤进行操作。问题是我无法训练自己的分类器。我收到此错误:No overload for method 'TrainClassifier' takes 5 arguments
.
void Start()
{
string m_positiveExamplesPath = Application.dataPath + "/testData/cpu_positive_examples.zip";
string m_negativeExamplesPath = Application.dataPath + "/testData/negative_examples.zip";
if(!m_VisualRecognition.TrainClassifier("components", "cpu", m_positiveExamplesPath, m_negativeExamplesPath, OnTrainClassifier))
Log.Debug("ExampleVisualRecognition", "Train classifier failed!");
}
private void OnTrainClassifier(GetClassifiersPerClassifierVerbose classifier)
{
if(classifier != null)
{
Log.Debug("ExampleVisualRecognition", "Classifier is training! " + classifier);
}
else
{
Log.Debug("ExampleVisualRecognition", "Failed to train classifier!");
}
}
Here是GitHub中SDK的link。谢谢!
您从 example page 复制了该代码,但看起来该页面上的所有内容都已过时。需要IBM更新。
VisualRecognition
class 有 2 个重载 TrainClassifier
:
public bool TrainClassifier(OnTrainClassifier callback, string classifierName, Dictionary<string, string> positiveExamples, string negativeExamplesPath = default(string), string mimeType = "application/zip", string customData = default(string))
和
public bool TrainClassifier(OnTrainClassifier callback, string classifierName, Dictionary<string, byte[]> positiveExamplesData, byte[] negativeExamplesData = null, string mimeType = "application/zip", string customData = default(string))
SDK 就在您面前。下次遇到这样的错误时,select 函数,右键单击 转到定义 。它将向您显示函数的重载,然后您将能够在其中传递正确的参数。
你的代码应该是这样的:
private VisualRecognition m_VisualRecognition = new VisualRecognition();
void Start()
{
string m_positiveExamplesPath = Application.dataPath + "/testData/cpu_positive_examples.zip";
string m_negativeExamplesPath = Application.dataPath + "/testData/negative_examples.zip";
Dictionary<string, string> positiveExamples = new Dictionary<string, string>();
positiveExamples.Add("giraffe", m_positiveExamplesPath);
if (!m_VisualRecognition.TrainClassifier(OnTrainClassifier, "unity-test-classifier-example", positiveExamples, m_negativeExamplesPath))
Log.Debug("ExampleVisualRecognition", "Train classifier failed!");
}
private void OnTrainClassifier(GetClassifiersPerClassifierVerbose classifier, string data)
{
if (classifier != null)
{
Log.Debug("ExampleVisualRecognition", "Classifier is training! " + classifier);
}
else
{
Log.Debug("ExampleVisualRecognition", "Failed to train classifier!");
}
}
如果您需要任何其他示例,不要 从 example page 中获取它。从插件附带的 Example 文件夹 中获取它。