Skip to content

Commit 1606f4e

Browse files
committed
chore(visual recognition): Apply manual changes
1 parent 1ecb7b8 commit 1606f4e

File tree

2 files changed

+0
-237
lines changed

2 files changed

+0
-237
lines changed

src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IVisualRecognitionService.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ public partial interface IVisualRecognitionService
2424
{
2525
ClassifiedImages Classify(System.IO.FileStream imagesFile = null, string acceptLanguage = null, string url = null, float? threshold = null, List<string> owners = null, List<string> classifierIds = null, string imagesFileContentType = null, Dictionary<string, object> customData = null);
2626
DetectedFaces DetectFaces(System.IO.FileStream imagesFile = null, string url = null, string imagesFileContentType = null, Dictionary<string, object> customData = null);
27-
Classifier CreateClassifier(string name, System.IO.FileStream classnamePositiveExamples, System.IO.FileStream negativeExamples = null, Dictionary<string, object> customData = null);
2827
BaseModel DeleteClassifier(string classifierId, Dictionary<string, object> customData = null);
2928
Classifier GetClassifier(string classifierId, Dictionary<string, object> customData = null);
3029
Classifiers ListClassifiers(bool? verbose = null, Dictionary<string, object> customData = null);
31-
Classifier UpdateClassifier(string classifierId, System.IO.FileStream classnamePositiveExamples = null, System.IO.FileStream negativeExamples = null, Dictionary<string, object> customData = null);
32-
System.IO.MemoryStream GetCoreMlModel(string classifierId, Dictionary<string, object> customData = null);
3330
BaseModel DeleteUserData(string customerId, Dictionary<string, object> customData = null);
3431
}
3532
}

src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/VisualRecognitionService.cs

Lines changed: 0 additions & 234 deletions
Original file line numberDiff line numberDiff line change
@@ -291,102 +291,6 @@ public DetectedFaces DetectFaces(System.IO.FileStream imagesFile = null, string
291291

292292
return result;
293293
}
294-
/// <summary>
295-
/// Create a classifier.
296-
///
297-
/// Train a new multi-faceted classifier on the uploaded image data. Create your custom classifier with positive
298-
/// or negative examples. Include at least two sets of examples, either two positive example files or one
299-
/// positive and one negative file. You can upload a maximum of 256 MB per call.
300-
///
301-
/// Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier
302-
/// and class names). The service assumes UTF-8 encoding if it encounters non-ASCII characters.
303-
/// </summary>
304-
/// <param name="name">The name of the new classifier. Encode special characters in UTF-8.</param>
305-
/// <param name="classnamePositiveExamples">A .zip file of images that depict the visual subject of a class in
306-
/// the new classifier. You can include more than one positive example file in a call.
307-
///
308-
/// Specify the parameter name by appending `_positive_examples` to the class name. For example,
309-
/// `goldenretriever_positive_examples` creates the class **goldenretriever**.
310-
///
311-
/// Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels.
312-
/// The maximum number of images is 10,000 images or 100 MB per .zip file.
313-
///
314-
/// Encode special characters in the file name in UTF-8.</param>
315-
/// <param name="negativeExamples">A .zip file of images that do not depict the visual subject of any of the
316-
/// classes of the new classifier. Must contain a minimum of 10 images.
317-
///
318-
/// Encode special characters in the file name in UTF-8. (optional)</param>
319-
/// <param name="customData">Custom data object to pass data including custom request headers.</param>
320-
/// <returns><see cref="Classifier" />Classifier</returns>
321-
public Classifier CreateClassifier(string name, System.IO.FileStream classnamePositiveExamples, System.IO.FileStream negativeExamples = null, Dictionary<string, object> customData = null)
322-
{
323-
if (string.IsNullOrEmpty(name))
324-
throw new ArgumentNullException(nameof(name));
325-
if (classnamePositiveExamples == null)
326-
throw new ArgumentNullException(nameof(classnamePositiveExamples));
327-
328-
if(string.IsNullOrEmpty(VersionDate))
329-
throw new ArgumentNullException("versionDate cannot be null.");
330-
331-
Classifier result = null;
332-
333-
try
334-
{
335-
var formData = new MultipartFormDataContent();
336-
337-
if (name != null)
338-
{
339-
var nameContent = new StringContent(name, Encoding.UTF8, HttpMediaType.TEXT_PLAIN);
340-
nameContent.Headers.ContentType = null;
341-
formData.Add(nameContent, "name");
342-
}
343-
344-
if (classnamePositiveExamples != null)
345-
{
346-
var classnamePositiveExamplesContent = new ByteArrayContent((classnamePositiveExamples as Stream).ReadAllBytes());
347-
System.Net.Http.Headers.MediaTypeHeaderValue contentType;
348-
System.Net.Http.Headers.MediaTypeHeaderValue.TryParse("application/octet-stream", out contentType);
349-
classnamePositiveExamplesContent.Headers.ContentType = contentType;
350-
formData.Add(classnamePositiveExamplesContent, "classname_positive_examples", classnamePositiveExamples.Name);
351-
}
352-
353-
if (negativeExamples != null)
354-
{
355-
var negativeExamplesContent = new ByteArrayContent((negativeExamples as Stream).ReadAllBytes());
356-
System.Net.Http.Headers.MediaTypeHeaderValue contentType;
357-
System.Net.Http.Headers.MediaTypeHeaderValue.TryParse("application/octet-stream", out contentType);
358-
negativeExamplesContent.Headers.ContentType = contentType;
359-
formData.Add(negativeExamplesContent, "negative_examples", negativeExamples.Name);
360-
}
361-
362-
IClient client;
363-
if(_tokenManager == null)
364-
{
365-
client = this.Client;
366-
}
367-
else
368-
{
369-
client = this.Client.WithAuthentication(_tokenManager.GetToken());
370-
}
371-
var restRequest = client.PostAsync($"{this.Endpoint}/v3/classifiers");
372-
373-
restRequest.WithArgument("version", VersionDate);
374-
restRequest.WithArgument("api_key", ApiKey);
375-
restRequest.WithBodyContent(formData);
376-
if (customData != null)
377-
restRequest.WithCustomData(customData);
378-
result = restRequest.As<Classifier>().Result;
379-
if(result == null)
380-
result = new Classifier();
381-
result.CustomData = restRequest.CustomData;
382-
}
383-
catch(AggregateException ae)
384-
{
385-
throw ae.Flatten();
386-
}
387-
388-
return result;
389-
}
390294

391295
/// <summary>
392296
/// Delete a classifier.
@@ -529,144 +433,6 @@ public Classifiers ListClassifiers(bool? verbose = null, Dictionary<string, obje
529433
return result;
530434
}
531435

532-
/// <summary>
533-
/// Update a classifier.
534-
///
535-
/// Update a custom classifier by adding new positive or negative classes (examples) or by adding new images to
536-
/// existing classes. You must supply at least one set of positive or negative examples. For details, see
537-
/// [Updating custom
538-
/// classifiers](https://console.bluemix.net/docs/services/visual-recognition/customizing.html#updating-custom-classifiers).
539-
///
540-
/// Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier
541-
/// and class names). The service assumes UTF-8 encoding if it encounters non-ASCII characters.
542-
///
543-
/// **Tip:** Don't make retraining calls on a classifier until the status is ready. When you submit retraining
544-
/// requests in parallel, the last request overwrites the previous requests. The retrained property shows the
545-
/// last time the classifier retraining finished.
546-
/// </summary>
547-
/// <param name="classifierId">The ID of the classifier.</param>
548-
/// <param name="classnamePositiveExamples">A .zip file of images that depict the visual subject of a class in
549-
/// the classifier. The positive examples create or update classes in the classifier. You can include more than
550-
/// one positive example file in a call.
551-
///
552-
/// Specify the parameter name by appending `_positive_examples` to the class name. For example,
553-
/// `goldenretriever_positive_examples` creates the class `goldenretriever`.
554-
///
555-
/// Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels.
556-
/// The maximum number of images is 10,000 images or 100 MB per .zip file.
557-
///
558-
/// Encode special characters in the file name in UTF-8. (optional)</param>
559-
/// <param name="negativeExamples">A .zip file of images that do not depict the visual subject of any of the
560-
/// classes of the new classifier. Must contain a minimum of 10 images.
561-
///
562-
/// Encode special characters in the file name in UTF-8. (optional)</param>
563-
/// <param name="customData">Custom data object to pass data including custom request headers.</param>
564-
/// <returns><see cref="Classifier" />Classifier</returns>
565-
public Classifier UpdateClassifier(string classifierId, System.IO.FileStream classnamePositiveExamples = null, System.IO.FileStream negativeExamples = null, Dictionary<string, object> customData = null)
566-
{
567-
if (string.IsNullOrEmpty(classifierId))
568-
throw new ArgumentNullException(nameof(classifierId));
569-
570-
if(string.IsNullOrEmpty(VersionDate))
571-
throw new ArgumentNullException("versionDate cannot be null.");
572-
573-
Classifier result = null;
574-
575-
try
576-
{
577-
var formData = new MultipartFormDataContent();
578-
579-
if (classnamePositiveExamples != null)
580-
{
581-
var classnamePositiveExamplesContent = new ByteArrayContent((classnamePositiveExamples as Stream).ReadAllBytes());
582-
System.Net.Http.Headers.MediaTypeHeaderValue contentType;
583-
System.Net.Http.Headers.MediaTypeHeaderValue.TryParse("application/octet-stream", out contentType);
584-
classnamePositiveExamplesContent.Headers.ContentType = contentType;
585-
formData.Add(classnamePositiveExamplesContent, "classname_positive_examples", classnamePositiveExamples.Name);
586-
}
587-
588-
if (negativeExamples != null)
589-
{
590-
var negativeExamplesContent = new ByteArrayContent((negativeExamples as Stream).ReadAllBytes());
591-
System.Net.Http.Headers.MediaTypeHeaderValue contentType;
592-
System.Net.Http.Headers.MediaTypeHeaderValue.TryParse("application/octet-stream", out contentType);
593-
negativeExamplesContent.Headers.ContentType = contentType;
594-
formData.Add(negativeExamplesContent, "negative_examples", negativeExamples.Name);
595-
}
596-
597-
IClient client;
598-
if(_tokenManager == null)
599-
{
600-
client = this.Client;
601-
}
602-
else
603-
{
604-
client = this.Client.WithAuthentication(_tokenManager.GetToken());
605-
}
606-
var restRequest = client.PostAsync($"{this.Endpoint}/v3/classifiers/{classifierId}");
607-
608-
restRequest.WithArgument("version", VersionDate);
609-
restRequest.WithArgument("api_key", ApiKey);
610-
restRequest.WithBodyContent(formData);
611-
if (customData != null)
612-
restRequest.WithCustomData(customData);
613-
result = restRequest.As<Classifier>().Result;
614-
if(result == null)
615-
result = new Classifier();
616-
result.CustomData = restRequest.CustomData;
617-
}
618-
catch(AggregateException ae)
619-
{
620-
throw ae.Flatten();
621-
}
622-
623-
return result;
624-
}
625-
/// <summary>
626-
/// Retrieve a Core ML model of a classifier.
627-
///
628-
/// Download a Core ML model file (.mlmodel) of a custom classifier that returns <tt>"core_ml_enabled":
629-
/// true</tt> in the classifier details.
630-
/// </summary>
631-
/// <param name="classifierId">The ID of the classifier.</param>
632-
/// <param name="customData">Custom data object to pass data including custom request headers.</param>
633-
/// <returns><see cref="System.IO.FileStream" />System.IO.FileStream</returns>
634-
public System.IO.MemoryStream GetCoreMlModel(string classifierId, Dictionary<string, object> customData = null)
635-
{
636-
if (string.IsNullOrEmpty(classifierId))
637-
throw new ArgumentNullException(nameof(classifierId));
638-
639-
if(string.IsNullOrEmpty(VersionDate))
640-
throw new ArgumentNullException("versionDate cannot be null.");
641-
642-
System.IO.MemoryStream result = null;
643-
644-
try
645-
{
646-
IClient client;
647-
if(_tokenManager == null)
648-
{
649-
client = this.Client;
650-
}
651-
else
652-
{
653-
client = this.Client.WithAuthentication(_tokenManager.GetToken());
654-
}
655-
var restRequest = client.GetAsync($"{this.Endpoint}/v3/classifiers/{classifierId}/core_ml_model");
656-
657-
restRequest.WithArgument("version", VersionDate);
658-
restRequest.WithArgument("api_key", ApiKey);
659-
if (customData != null)
660-
restRequest.WithCustomData(customData);
661-
result = new System.IO.MemoryStream(restRequest.AsByteArray().Result);
662-
}
663-
catch(AggregateException ae)
664-
{
665-
throw ae.Flatten();
666-
}
667-
668-
return result;
669-
}
670436
/// <summary>
671437
/// Delete labeled data.
672438
///

0 commit comments

Comments
 (0)