Assets/Watson/Scripts/Services/VisualRecognition/VisualRecognition.cs
/// <summary>
/// Updates a trained classifier. The total size of all files must be below 256mb.
/// </summary>
/// <returns><c>true</c>, if classifier was updated, <c>false</c> otherwise.</returns>
/// <param name="callback">Callback.</param>
/// <param name="classifierID">Classifier identifier.</param>
/// <param name="classifierName">Classifier name.</param>
/// <param name="positiveExamples">Dictionary of class name and positive example paths.</param>
/// <param name="negativeExamplesPath">Negative example file path.</param>
Updates a trained classifier. The total size of all files must be below 256mb.
Updates a trained classifier . The total size of all files must be below 256mb .
public bool UpdateClassifier(OnTrainClassifier callback, string classifierID, string classifierName, Dictionary<string, string> positiveExamples, string negativeExamplesPath = default(string), string customData = default(string))
        {
            if (string.IsNullOrEmpty(mp_ApiKey))
                mp_ApiKey = Config.Instance.GetAPIKey(SERVICE_ID);
            if (string.IsNullOrEmpty(mp_ApiKey))
                throw new WatsonException("No API Key was found!");
            if (string.IsNullOrEmpty(classifierName))
                throw new ArgumentNullException("ClassifierName");
            if (positiveExamples.Count == 0 && string.IsNullOrEmpty(negativeExamplesPath))
                throw new ArgumentNullException("Need at least one positive example or one negative example!");
            if (callback == null)
                throw new ArgumentNullException("callback");
            Dictionary<string, byte[]> positiveExamplesData = new Dictionary<string, byte[]>();
            byte[] negativeExamplesData = null;
            if (LoadFile != null)
            {
                foreach (KeyValuePair<string, string> kv in positiveExamples)
                    positiveExamplesData.Add(kv.Key, LoadFile(kv.Value));
                if (!string.IsNullOrEmpty(negativeExamplesPath))
                    negativeExamplesData = LoadFile(negativeExamplesPath);
            }
            else
            {
#if !UNITY_WEBPLAYER
                foreach (KeyValuePair<string, string> kv in positiveExamples)
                    positiveExamplesData.Add(kv.Key, File.ReadAllBytes(kv.Value));
                if(!string.IsNullOrEmpty(negativeExamplesPath))
                    negativeExamplesData = File.ReadAllBytes(negativeExamplesPath);
#endif
            }
            if (positiveExamplesData.Count == 0 && negativeExamplesData == null)
                Log.Error("VisualRecognition", "Failed to upload positive or negative examples!");
            return UpdateClassifier(callback, classifierID, classifierName, positiveExamplesData, negativeExamplesData, customData);
        }
public bool UpdateClassifier ( OnTrainClassifier callback , string classifierID , string classifierName , Dictionary < string , string > positiveExamples , string negativeExamplesPath = default ( string ) , string customData = default ( string ) ) { if ( string . IsNullOrEmpty ( mp_ApiKey ) ) mp_ApiKey = Config . Instance . GetAPIKey ( SERVICE_ID ) ; if ( string . IsNullOrEmpty ( mp_ApiKey ) ) throw new WatsonException ( " " ) ; if ( string . IsNullOrEmpty ( classifierName ) ) throw new ArgumentNullException ( " " ) ; if ( positiveExamples . Count == 0 && string . IsNullOrEmpty ( negativeExamplesPath ) ) throw new ArgumentNullException ( " " ) ; if ( callback == null ) throw new ArgumentNullException ( " " ) ; Dictionary < string , byte [ ] > positiveExamplesData = new Dictionary < string , byte [ ] > ( ) ; byte [ ] negativeExamplesData = null ; if ( LoadFile != null ) { foreach ( KeyValuePair < string , string > kv in positiveExamples ) positiveExamplesData . Add ( kv . Key , LoadFile ( kv . Value ) ) ; if ( ! string . IsNullOrEmpty ( negativeExamplesPath ) ) negativeExamplesData = LoadFile ( negativeExamplesPath ) ; } else { if ! UNITY_WEBPLAYER foreach ( KeyValuePair < string , string > kv in positiveExamples ) positiveExamplesData . Add ( kv . Key , File . ReadAllBytes ( kv . Value ) ) ; if ( ! string . IsNullOrEmpty ( negativeExamplesPath ) ) negativeExamplesData = File . ReadAllBytes ( negativeExamplesPath ) ; endif } if ( positiveExamplesData . Count == 0 && negativeExamplesData == null ) Log . Error ( " " , " " ) ; return UpdateClassifier ( callback , classifierID , classifierName , positiveExamplesData , negativeExamplesData , customData ) ; }
Updates a trained classifier.
Updates a trained classifier .
None
callback
OnTrainClassifier
None
classifierID
string
None
classifierName
string
None
positiveExamples
Dictionary<string, string>
Dictionary of class name and positive example paths.
Dictionary of class name and positive example paths .
negativeExamplesPath
string
Negative example file path.
Negative example file path .
customData
string