Assets/Watson/Scripts/Services/VisualRecognition/VisualRecognition.cs
/// <summary>
/// Updates a classifier using byte data.
/// </summary>
/// <param name="callback">Callback.</param>
/// <param name="classifierID">Classifier identifier.</param>
/// <param name="classifierName">Classifier name.</param>
/// <param name="positiveExamplesData">Dictionary of class name and class training zip byte data.</param>
/// <param name="negativeExamplesData">Negative examples zip byte data.</param>
/// <returns></returns>
Updates a classifier using byte data.
Updates a classifier using byte data .
public bool UpdateClassifier(OnTrainClassifier callback, string classifierID, string classifierName, Dictionary<string, byte[]> positiveExamplesData, byte[] negativeExamplesData = null, 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 (positiveExamplesData.Count == 0 && negativeExamplesData == null)
                throw new ArgumentNullException("Need at least one positive example or one negative example!");
            if (callback == null)
                throw new ArgumentNullException("callback");
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_CLASSIFIERS + "/" + classifierID);
            if (connector == null)
                return false;
            TrainClassifierReq req = new TrainClassifierReq();
            req.Callback = callback;
            req.OnResponse = OnTrainClassifierResp;
            req.Timeout = REQUEST_TIMEOUT;
            req.Parameters["api_key"] = mp_ApiKey;
            req.Parameters["version"] = VisualRecognitionVersion.Version;
            req.Forms = new Dictionary<string, RESTConnector.Form>();
            req.Forms["name"] = new RESTConnector.Form(classifierName);
            foreach (KeyValuePair<string, byte[]> kv in positiveExamplesData)
                req.Forms[kv.Key + "_positive_examples"] = new RESTConnector.Form(kv.Value, kv.Key + "_positive_examples.zip", "application/zip");
            if (negativeExamplesData != null)
                req.Forms["negative_examples"] = new RESTConnector.Form(negativeExamplesData, "negative_examples.zip", "application/zip");
            return connector.Send(req);
        }
public bool UpdateClassifier ( OnTrainClassifier callback , string classifierID , string classifierName , Dictionary < string , byte [ ] > positiveExamplesData , byte [ ] negativeExamplesData = null , 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 ( positiveExamplesData . Count == 0 && negativeExamplesData == null ) throw new ArgumentNullException ( " " ) ; if ( callback == null ) throw new ArgumentNullException ( " " ) ; RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , SERVICE_CLASSIFIERS + " " + classifierID ) ; if ( connector == null ) return false ; TrainClassifierReq req = new TrainClassifierReq ( ) ; req . Callback = callback ; req . OnResponse = OnTrainClassifierResp ; req . Timeout = REQUEST_TIMEOUT ; req . Parameters [ " " ] = mp_ApiKey ; req . Parameters [ " " ] = VisualRecognitionVersion . Version ; req . Forms = new Dictionary < string , RESTConnector . Form > ( ) ; req . Forms [ " " ] = new RESTConnector . Form ( classifierName ) ; foreach ( KeyValuePair < string , byte [ ] > kv in positiveExamplesData ) req . Forms [ kv . Key + " " ] = new RESTConnector . Form ( kv . Value , kv . Key + " " , " " ) ; if ( negativeExamplesData != null ) req . Forms [ " " ] = new RESTConnector . Form ( negativeExamplesData , " " , " " ) ; return connector . Send ( req ) ; }
Updates a classifier using byte data.
Updates a classifier using byte data .
None
callback
OnTrainClassifier
None
classifierID
string
None
classifierName
string
None
positiveExamplesData
Dictionary<string, byte[]>
Dictionary of class name and class training zip byte data.
Dictionary of class name and class training zip byte data .
negativeExamplesData
byte[]
Negative examples zip byte data.
Negative examples zip byte data .
customData
string