Skip to content

Commit 3e217fb

Browse files
committed
chore(Visual Recognition V4): Regenerated using new mapified param feature
1 parent 5caa5fe commit 3e217fb

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,9 @@ private void OnDetectFacesResponse(RESTConnector.Request req, RESTConnector.Resp
363363
/// </summary>
364364
/// <param name="callback">The callback function that is invoked when the operation completes.</param>
365365
/// <param name="name">The name of the new classifier. Encode special characters in UTF-8.</param>
366-
/// <param name="positiveExamples">A .zip file of images that depict the visual subject of a class in the new
367-
/// classifier. You can include more than one positive example file in a call.
366+
/// <param name="positiveExamples">A dictionary that contains the value for each classname. The value is a .zip
367+
/// file of images that depict the visual subject of a class in the new classifier. You can include more than
368+
/// one positive example file in a call.
368369
///
369370
/// Specify the parameter name by appending `_positive_examples` to the class name. For example,
370371
/// `goldenretriever_positive_examples` creates the class **goldenretriever**.
@@ -423,7 +424,7 @@ public bool CreateClassifier(Callback<Classifier> callback, string name, Diction
423424
foreach (KeyValuePair<string, System.IO.MemoryStream> entry in positiveExamples)
424425
{
425426
var partName = string.Format("{0}_positive_examples", entry.Key);
426-
req.Forms[partName] = new RESTConnector.Form(entry.Value, "file.zip", "application/octet-stream");
427+
req.Forms[partName] = new RESTConnector.Form(entry.Value, entry.Key + ".zip", "application/octet-stream");
427428
}
428429
}
429430
if (negativeExamples != null)
@@ -591,16 +592,19 @@ private void OnGetClassifierResponse(RESTConnector.Request req, RESTConnector.Re
591592
}
592593
response.StatusCode = resp.HttpResponseCode;
593594

594-
try
595-
{
596-
string json = Encoding.UTF8.GetString(resp.Data);
597-
response.Result = JsonConvert.DeserializeObject<Classifier>(json);
598-
response.Response = json;
599-
}
600-
catch (Exception e)
595+
if (resp.Success)
601596
{
602-
Log.Error("VisualRecognitionService.OnGetClassifierResponse()", "Exception: {0}", e.ToString());
603-
resp.Success = false;
597+
try
598+
{
599+
string json = Encoding.UTF8.GetString(resp.Data);
600+
response.Result = JsonConvert.DeserializeObject<Classifier>(json);
601+
response.Response = json;
602+
}
603+
catch (Exception e)
604+
{
605+
Log.Error("VisualRecognitionService.OnGetClassifierResponse()", "Exception: {0}", e.ToString());
606+
resp.Success = false;
607+
}
604608
}
605609

606610
if (((RequestObject<Classifier>)req).Callback != null)
@@ -695,9 +699,9 @@ private void OnListClassifiersResponse(RESTConnector.Request req, RESTConnector.
695699
/// </summary>
696700
/// <param name="callback">The callback function that is invoked when the operation completes.</param>
697701
/// <param name="classifierId">The ID of the classifier.</param>
698-
/// <param name="positiveExamples">A .zip file of images that depict the visual subject of a class in the
699-
/// classifier. The positive examples create or update classes in the classifier. You can include more than one
700-
/// positive example file in a call.
702+
/// <param name="positiveExamples">A dictionary that contains the value for each classname. The value is a .zip
703+
/// file of images that depict the visual subject of a class in the classifier. The positive examples create or
704+
/// update classes in the classifier. You can include more than one positive example file in a call.
701705
///
702706
/// Specify the parameter name by appending `_positive_examples` to the class name. For example,
703707
/// `goldenretriever_positive_examples` creates the class `goldenretriever`.
@@ -746,7 +750,7 @@ public bool UpdateClassifier(Callback<Classifier> callback, string classifierId,
746750
foreach (KeyValuePair<string, System.IO.MemoryStream> entry in positiveExamples)
747751
{
748752
var partName = string.Format("{0}_positive_examples", entry.Key);
749-
req.Forms[partName] = new RESTConnector.Form(entry.Value, "file.zip", "application/octet-stream");
753+
req.Forms[partName] = new RESTConnector.Form(entry.Value, entry.Key + ".zip", "application/octet-stream");
750754
}
751755
}
752756
if (negativeExamples != null)

0 commit comments

Comments
 (0)