diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognition.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognition.java
index 329c372c20f..b880d2ee7b1 100644
--- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognition.java
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognition.java
@@ -27,25 +27,20 @@
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectedFaces;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetClassifierOptions;
+import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.UpdateClassifierOptions;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import java.io.File;
+import java.io.InputStream;
/**
- * **Important:** As of September 8, 2017, the beta period for Similarity Search is closed. For more information, see
- * [Visual Recognition API – Similarity Search
- * Update](https://www.ibm.com/blogs/bluemix/2017/08/visual-recognition-api-similarity-search-update).
- *
* The IBM Watson Visual Recognition service uses deep learning algorithms to identify scenes, objects, and faces in
* images you upload to the service. You can create and train a custom classifier to identify subjects that suit your
* needs.
*
- * **Tip:** To test calls to the **Custom classifiers** methods with the API explorer, provide your `api_key` from your
- * IBM® Cloud service instance.
- *
* @version v3
* @see Visual Recognition
*/
@@ -169,9 +164,13 @@ public ServiceCall classify() {
/**
* Detect faces in images.
*
- * Analyze and get data about faces in images. Responses can include estimated age and gender, and the service can
- * identify celebrities. This feature uses a built-in classifier, so you do not train it on custom classifiers. The
- * Detect faces method does not support general biometric facial recognition.
+ * **Important:** On April 2, 2018, the identity information in the response to calls to the Face model will be
+ * removed. The identity information refers to the `name` of the person, `score`, and `type_hierarchy` knowledge
+ * graph. For details about the enhanced Face model, see the [Release
+ * notes](https://console.bluemix.net/docs/services/visual-recognition/release-notes.html#23february2018). Analyze and
+ * get data about faces in images. Responses can include estimated age and gender, and the service can identify
+ * celebrities. This feature uses a built-in classifier, so you do not train it on custom classifiers. The Detect
+ * faces method does not support general biometric facial recognition.
*
* @param detectFacesOptions the {@link DetectFacesOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link DetectedFaces}
@@ -205,9 +204,13 @@ public ServiceCall detectFaces(DetectFacesOptions detectFacesOpti
/**
* Detect faces in images.
*
- * Analyze and get data about faces in images. Responses can include estimated age and gender, and the service can
- * identify celebrities. This feature uses a built-in classifier, so you do not train it on custom classifiers. The
- * Detect faces method does not support general biometric facial recognition.
+ * **Important:** On April 2, 2018, the identity information in the response to calls to the Face model will be
+ * removed. The identity information refers to the `name` of the person, `score`, and `type_hierarchy` knowledge
+ * graph. For details about the enhanced Face model, see the [Release
+ * notes](https://console.bluemix.net/docs/services/visual-recognition/release-notes.html#23february2018). Analyze and
+ * get data about faces in images. Responses can include estimated age and gender, and the service can identify
+ * celebrities. This feature uses a built-in classifier, so you do not train it on custom classifiers. The Detect
+ * faces method does not support general biometric facial recognition.
*
* @return a {@link ServiceCall} with a response type of {@link DetectedFaces}
*/
@@ -287,7 +290,7 @@ public ServiceCall getClassifier(GetClassifierOptions getClassifierO
}
/**
- * Retrieve a list of custom classifiers.
+ * Retrieve a list of classifiers.
*
* @param listClassifiersOptions the {@link ListClassifiersOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Classifiers}
@@ -305,7 +308,7 @@ public ServiceCall listClassifiers(ListClassifiersOptions listClass
}
/**
- * Retrieve a list of custom classifiers.
+ * Retrieve a list of classifiers.
*
* @return a {@link ServiceCall} with a response type of {@link Classifiers}
*/
@@ -323,7 +326,7 @@ public ServiceCall listClassifiers() {
* (https://console.bluemix.net/docs/services/visual-recognition/customizing.html#updating-custom-classifiers).
* Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier and class
* names). The service assumes UTF-8 encoding if it encounters non-ASCII characters. **Important:** You can't update a
- * custom classifier with an API key for a Lite plan. To update a custom classifer on a Lite plan, create another
+ * custom classifier with an API key for a Lite plan. To update a custom classifier on a Lite plan, create another
* service instance on a Standard plan and re-create your custom classifier. **Tip:** Don't make retraining calls on a
* classifier until the status is ready. When you submit retraining requests in parallel, the last request overwrites
* the previous requests. The retrained property shows the last time the classifier retraining finished.
@@ -360,4 +363,23 @@ public ServiceCall updateClassifier(UpdateClassifierOptions updateCl
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
}
+ /**
+ * Retrieve a Core ML model of a classifier.
+ *
+ * Download a Core ML model file (.mlmodel) of a custom classifier that returns \"core_ml_enabled\": true in
+ * the classifier details.
+ *
+ * @param getCoreMlModelOptions the {@link GetCoreMlModelOptions} containing the options for the call
+ * @return a {@link ServiceCall} with a response type of {@link InputStream}
+ */
+ public ServiceCall getCoreMlModel(GetCoreMlModelOptions getCoreMlModelOptions) {
+ Validator.notNull(getCoreMlModelOptions, "getCoreMlModelOptions cannot be null");
+ String[] pathSegments = { "v3/classifiers", "core_ml_model" };
+ String[] pathParameters = { getCoreMlModelOptions.classifierId() };
+ RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
+ pathParameters));
+ builder.query(VERSION, versionDate);
+ return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
+ }
+
}
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifier.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifier.java
index a3a3f5d0063..36469d65ff8 100644
--- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifier.java
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifier.java
@@ -42,10 +42,13 @@ public interface Status {
private String name;
private String owner;
private String status;
+ @SerializedName("core_ml_enabled")
+ private Boolean coreMlEnabled;
private String explanation;
private Date created;
private List classes;
private Date retrained;
+ private Date updated;
/**
* Gets the classifierId.
@@ -92,6 +95,17 @@ public String getStatus() {
return status;
}
+ /**
+ * Gets the coreMlEnabled.
+ *
+ * Whether the classifier can be downloaded as a Core ML model after the training status is `ready`.
+ *
+ * @return the coreMlEnabled
+ */
+ public Boolean isCoreMlEnabled() {
+ return coreMlEnabled;
+ }
+
/**
* Gets the explanation.
*
@@ -106,7 +120,7 @@ public String getExplanation() {
/**
* Gets the created.
*
- * Date and time in Coordinated Universal Time that the classifier was created.
+ * Date and time in Coordinated Universal Time (UTC) that the classifier was created.
*
* @return the created
*/
@@ -128,12 +142,24 @@ public List getClasses() {
/**
* Gets the retrained.
*
- * Date and time in Coordinated Universal Time that the classifier was updated. Returned when verbose=`true`. Might
- * not be returned by some requests.
+ * Date and time in Coordinated Universal Time (UTC) that the classifier was updated. Returned when verbose=`true`.
+ * Might not be returned by some requests. Identical to `updated` and retained for backward compatibility.
*
* @return the retrained
*/
public Date getRetrained() {
return retrained;
}
+
+ /**
+ * Gets the updated.
+ *
+ * Date and time in Coordinated Universal Time (UTC) that the classifier was most recently updated. The field matches
+ * either `retrained` or `created`. Returned when verbose=`true`. Might not be returned by some requests.
+ *
+ * @return the updated
+ */
+ public Date getUpdated() {
+ return updated;
+ }
}
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifiers.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifiers.java
index 153558069d8..6b139bb4911 100644
--- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifiers.java
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifiers.java
@@ -17,7 +17,7 @@
import com.ibm.watson.developer_cloud.service.model.GenericModel;
/**
- * Verbose list of classifiers retrieved in the GET v2/classifiers call.
+ * List of classifiers.
*/
public class Classifiers extends GenericModel {
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java
index 3f233f16fe2..ee3cde5074e 100644
--- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java
@@ -12,9 +12,6 @@
*/
package com.ibm.watson.developer_cloud.visual_recognition.v3.model;
-import com.ibm.watson.developer_cloud.service.model.GenericModel;
-import com.ibm.watson.developer_cloud.util.Validator;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -22,17 +19,18 @@
import java.util.ArrayList;
import java.util.List;
+import com.ibm.watson.developer_cloud.service.model.GenericModel;
+import com.ibm.watson.developer_cloud.util.Validator;
+
/**
* The classify options.
*/
public class ClassifyOptions extends GenericModel {
/**
- * Specifies the language of the output class names. Can be `en` (English), `ar` (Arabic), `de` (German), `es`
- * (Spanish), `it` (Italian), `ja` (Japanese), or `ko` (Korean). Classes for which no translation is available are
- * omitted. The response might not be in the specified language under these conditions: - English is returned when the
- * requested language is not supported. - Classes are not returned when there is no translation for them. - Custom
- * classifiers returned with this method return tags in the language of the custom classifier.
+ * The language of the output class names. The full set of languages is supported only for the built-in `default`
+ * classifier ID. The class names of custom classifiers are not translated. The response might not be in the specified
+ * language when the requested language is not supported or when there is no translation for the class name.
*/
public interface AcceptLanguage {
/** en. */
@@ -43,6 +41,8 @@ public interface AcceptLanguage {
String DE = "de";
/** es. */
String ES = "es";
+ /** fr. */
+ String FR = "fr";
/** it. */
String IT = "it";
/** ja. */
@@ -277,8 +277,8 @@ public Builder newBuilder() {
*
* An image file (.jpg, .png) or .zip file with images. Maximum image size is 10 MB. Include no more than 20 images
* and limit the .zip file to 100 MB. Encode the image and .zip file names in UTF-8 if they contain non-ASCII
- * characters. The service assumes UTF-8 encoding if it encounters non-ASCII characters. You can also include images
- * with the `url` property in the **parameters** object.
+ * characters. The service assumes UTF-8 encoding if it encounters non-ASCII characters. You can also include an image
+ * with the **url** parameter.
*
* @return the imagesFile
*/
@@ -300,11 +300,9 @@ public String imagesFilename() {
/**
* Gets the acceptLanguage.
*
- * Specifies the language of the output class names. Can be `en` (English), `ar` (Arabic), `de` (German), `es`
- * (Spanish), `it` (Italian), `ja` (Japanese), or `ko` (Korean). Classes for which no translation is available are
- * omitted. The response might not be in the specified language under these conditions: - English is returned when the
- * requested language is not supported. - Classes are not returned when there is no translation for them. - Custom
- * classifiers returned with this method return tags in the language of the custom classifier.
+ * The language of the output class names. The full set of languages is supported only for the built-in `default`
+ * classifier ID. The class names of custom classifiers are not translated. The response might not be in the specified
+ * language when the requested language is not supported or when there is no translation for the class name.
*
* @return the acceptLanguage
*/
@@ -315,8 +313,8 @@ public String acceptLanguage() {
/**
* Gets the url.
*
- * A string with the image URL to analyze. Must be in .jpg, or .png format. The minimum recommended pixel density is
- * 32X32 pixels per inch, and the maximum image size is 10 MB. You can also include images in the **images_file**
+ * The URL of an image to analyze. Must be in .jpg, or .png format. The minimum recommended pixel density is 32X32
+ * pixels per inch, and the maximum image size is 10 MB. You can also include images with the **images_file**
* parameter.
*
* @return the url
@@ -328,8 +326,7 @@ public String url() {
/**
* Gets the threshold.
*
- * A floating point value that specifies the minimum score a class must have to be displayed in the response. The
- * default threshold for returning scores from a classifier is `0.5`. Set the threshold to `0.0` to ignore the
+ * The minimum score a class must have to be displayed in the response. Set the threshold to `0.0` to ignore the
* classification score and return all values.
*
* @return the threshold
@@ -341,11 +338,11 @@ public Float threshold() {
/**
* Gets the owners.
*
- * An array of the categories of classifiers to apply. Use `IBM` to classify against the `default` general classifier,
- * and use `me` to classify against your custom classifiers. To analyze the image against both classifier categories,
- * set the value to both `IBM` and `me`. The built-in `default` classifier is used if both **classifier_ids** and
- * **owners** parameters are empty. The **classifier_ids** parameter overrides **owners**, so make sure that
- * **classifier_ids** is empty.
+ * The categories of classifiers to apply. Use `IBM` to classify against the `default` general classifier, and use
+ * `me` to classify against your custom classifiers. To analyze the image against both classifier categories, set the
+ * value to both `IBM` and `me`. The built-in `default` classifier is used if both **classifier_ids** and **owners**
+ * parameters are empty. The **classifier_ids** parameter overrides **owners**, so make sure that **classifier_ids**
+ * is empty.
*
* @return the owners
*/
@@ -356,13 +353,11 @@ public List owners() {
/**
* Gets the classifierIds.
*
- * The **classifier_ids** parameter overrides **owners**, so make sure that **classifier_ids** is empty. -
- * **classifier_ids**: Specifies which classifiers to apply and overrides the **owners** parameter. You can specify
- * both custom and built-in classifiers. The built-in `default` classifier is used if both **classifier_ids** and
- * **owners** parameters are empty. The following built-in classifier IDs require no training: - `default`: Returns
- * classes from thousands of general tags. - `food`: (Beta) Enhances specificity and accuracy for images of food
- * items. - `explicit`: (Beta) Evaluates whether the image might be pornographic. Example:
- * `"classifier_ids="CarsvsTrucks_1479118188","explicit"`.
+ * Which classifiers to apply. Overrides the **owners** parameter. You can specify both custom and built-in
+ * classifiers. The built-in `default` classifier is used if both **classifier_ids** and **owners** parameters are
+ * empty. The following built-in classifier IDs require no training: - `default`: Returns classes from thousands of
+ * general tags. - `food`: (Beta) Enhances specificity and accuracy for images of food items. - `explicit`: (Beta)
+ * Evaluates whether the image might be pornographic.
*
* @return the classifierIds
*/
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/CreateClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/CreateClassifierOptions.java
index 17db9ac33db..0f36a45102a 100644
--- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/CreateClassifierOptions.java
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/CreateClassifierOptions.java
@@ -172,11 +172,10 @@ public String name() {
* Gets the class names.
*
* A .zip file of images that depict the visual subject of a class in the new classifier. You can include more than
- * one positive example file in a call. Append `_positive_examples` to the form name. The prefix is used as the class
+ * one positive example file in a call. Specify the parameter name by appending `_positive_examples` to the class
* name. For example, `goldenretriever_positive_examples` creates the class **goldenretriever**. Include at least 10
* images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. The maximum number of
- * images is 10,000 images or 100 MB per .zip file. Encode special characters in the file name in UTF-8. The API
- * explorer limits you to training only one class. To train more classes, use the API functionality.
+ * images is 10,000 images or 100 MB per .zip file. Encode special characters in the file name in UTF-8.
*
* @return the classNames
*/
@@ -197,8 +196,8 @@ public File positiveExamplesByClassName(String className) {
/**
* Gets the negativeExamples.
*
- * A compressed (.zip) file of images that do not depict the visual subject of any of the classes of the new
- * classifier. Must contain a minimum of 10 images. Encode special characters in the file name in UTF-8.
+ * A .zip file of images that do not depict the visual subject of any of the classes of the new classifier. Must
+ * contain a minimum of 10 images. Encode special characters in the file name in UTF-8.
*
* @return the negativeExamples
*/
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesBetaOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesBetaOptions.java
new file mode 100644
index 00000000000..b0b4a10f4e8
--- /dev/null
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesBetaOptions.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2018 IBM Corp. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package com.ibm.watson.developer_cloud.visual_recognition.v3.model;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import com.ibm.watson.developer_cloud.service.model.GenericModel;
+
+/**
+ * The detectFacesBeta options.
+ */
+public class DetectFacesBetaOptions extends GenericModel {
+
+ private InputStream imagesFile;
+ private String imagesFilename;
+ private String url;
+ private String imagesFileContentType;
+
+ /**
+ * Builder.
+ */
+ public static class Builder {
+ private InputStream imagesFile;
+ private String imagesFilename;
+ private String url;
+ private String imagesFileContentType;
+
+ private Builder(DetectFacesBetaOptions detectFacesBetaOptions) {
+ imagesFile = detectFacesBetaOptions.imagesFile;
+ imagesFilename = detectFacesBetaOptions.imagesFilename;
+ url = detectFacesBetaOptions.url;
+ imagesFileContentType = detectFacesBetaOptions.imagesFileContentType;
+ }
+
+ /**
+ * Instantiates a new builder.
+ */
+ public Builder() {
+ }
+
+ /**
+ * Builds a DetectFacesBetaOptions.
+ *
+ * @return the detectFacesBetaOptions
+ */
+ public DetectFacesBetaOptions build() {
+ return new DetectFacesBetaOptions(this);
+ }
+
+ /**
+ * Set the imagesFile.
+ *
+ * @param imagesFile the imagesFile
+ * @return the DetectFacesBetaOptions builder
+ */
+ public Builder imagesFile(InputStream imagesFile) {
+ this.imagesFile = imagesFile;
+ return this;
+ }
+
+ /**
+ * Set the imagesFilename.
+ *
+ * @param imagesFilename the imagesFilename
+ * @return the DetectFacesBetaOptions builder
+ */
+ public Builder imagesFilename(String imagesFilename) {
+ this.imagesFilename = imagesFilename;
+ return this;
+ }
+
+ /**
+ * Set the url.
+ *
+ * @param url the url
+ * @return the DetectFacesBetaOptions builder
+ */
+ public Builder url(String url) {
+ this.url = url;
+ return this;
+ }
+
+ /**
+ * Set the imagesFileContentType.
+ *
+ * @param imagesFileContentType the imagesFileContentType
+ * @return the DetectFacesBetaOptions builder
+ */
+ public Builder imagesFileContentType(String imagesFileContentType) {
+ this.imagesFileContentType = imagesFileContentType;
+ return this;
+ }
+
+ /**
+ * Set the imagesFile.
+ *
+ * @param imagesFile the imagesFile
+ * @return the DetectFacesBetaOptions builder
+ *
+ * @throws FileNotFoundException if the file could not be found
+ */
+ public Builder imagesFile(File imagesFile) throws FileNotFoundException {
+ this.imagesFile = new FileInputStream(imagesFile);
+ this.imagesFilename = imagesFile.getName();
+ return this;
+ }
+ }
+
+ private DetectFacesBetaOptions(Builder builder) {
+ imagesFile = builder.imagesFile;
+ imagesFilename = builder.imagesFilename;
+ url = builder.url;
+ imagesFileContentType = builder.imagesFileContentType;
+ }
+
+ /**
+ * New builder.
+ *
+ * @return a DetectFacesBetaOptions builder
+ */
+ public Builder newBuilder() {
+ return new Builder(this);
+ }
+
+ /**
+ * Gets the imagesFile.
+ *
+ * An image file or .zip file with images. Limit the .zip file to 100 MB. You can include a maximum of 15 images in a
+ * request. Encode the image and .zip file names in UTF-8 if they contain non-ASCII characters. The service assumes
+ * UTF-8 encoding if it encounters non-ASCII characters.
+ *
+ * @return the imagesFile
+ */
+ public InputStream imagesFile() {
+ return imagesFile;
+ }
+
+ /**
+ * Gets the imagesFilename.
+ *
+ * The filename for imagesFile.
+ *
+ * @return the imagesFilename
+ */
+ public String imagesFilename() {
+ return imagesFilename;
+ }
+
+ /**
+ * Gets the url.
+ *
+ * A string with the image URL to analyze. Redirects are followed, so you can use a shortened URL.
+ *
+ * @return the url
+ */
+ public String url() {
+ return url;
+ }
+
+ /**
+ * Gets the imagesFileContentType.
+ *
+ * The content type of imagesFile. Values for this parameter can be obtained from the HttpMediaType class.
+ *
+ * @return the imagesFileContentType
+ */
+ public String imagesFileContentType() {
+ return imagesFileContentType;
+ }
+}
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesOptions.java
index 75362787b60..014f98e0f8d 100644
--- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesOptions.java
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesOptions.java
@@ -12,13 +12,13 @@
*/
package com.ibm.watson.developer_cloud.visual_recognition.v3.model;
-import com.ibm.watson.developer_cloud.service.model.GenericModel;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
+import com.ibm.watson.developer_cloud.service.model.GenericModel;
+
/**
* The detectFaces options.
*/
@@ -156,9 +156,9 @@ public Builder newBuilder() {
/**
* Gets the imagesFile.
*
- * An image file (.jpg, .png) or .zip file with images. Include no more than 15 images. You can also include an image
- * with the**url** parameter. All faces are detected, but if there are more than 10 faces in an image, age and gender
- * confidence scores might return scores of 0.
+ * An image file (.jpg, .png) or .zip file with images. Include no more than 15 images. All faces are detected, but if
+ * there are more than 10 faces in an image, age and gender confidence scores might return scores of 0. You can also
+ * include an image with the **url** parameter.
*
* @return the imagesFile
*/
@@ -180,7 +180,9 @@ public String imagesFilename() {
/**
* Gets the url.
*
- * A string with the image URL to analyze.
+ * The URL of an image to analyze. Must be in .jpg, or .png format. The minimum recommended pixel density is 32X32
+ * pixels per inch, and the maximum image size is 2 MB. You can also include images with the **images_file**
+ * parameter.
*
* @return the url
*/
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceAge.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceAge.java
index 0eeac44b686..0f9d9b30a09 100644
--- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceAge.java
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceAge.java
@@ -16,7 +16,7 @@
/**
* Provides age information about a face. If there are more than 10 faces in an image, the response might return the
- * confidence score `0g.
+ * confidence score `0`.
*/
public class FaceAge extends GenericModel {
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceFaceLocation.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceFaceLocation.java
new file mode 100644
index 00000000000..8d7a6936c22
--- /dev/null
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceFaceLocation.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2017 IBM Corp. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package com.ibm.watson.developer_cloud.visual_recognition.v3.model;
+
+import com.ibm.watson.developer_cloud.service.model.GenericModel;
+
+/**
+ * FaceFaceLocation.
+ */
+public class FaceFaceLocation extends GenericModel {
+
+ private Double width;
+ private Double height;
+ private Double left;
+ private Double top;
+
+ /**
+ * Gets the width.
+ *
+ * Width in pixels of face region.
+ *
+ * @return the width
+ */
+ public Double getWidth() {
+ return width;
+ }
+
+ /**
+ * Gets the height.
+ *
+ * Height in pixels of face region.
+ *
+ * @return the height
+ */
+ public Double getHeight() {
+ return height;
+ }
+
+ /**
+ * Gets the left.
+ *
+ * x-position of top-left pixel of face region.
+ *
+ * @return the left
+ */
+ public Double getLeft() {
+ return left;
+ }
+
+ /**
+ * Gets the top.
+ *
+ * y-position of top-left pixel of face region.
+ *
+ * @return the top
+ */
+ public Double getTop() {
+ return top;
+ }
+
+ /**
+ * Sets the width.
+ *
+ * @param width the new width
+ */
+ public void setWidth(final Double width) {
+ this.width = width;
+ }
+
+ /**
+ * Sets the height.
+ *
+ * @param height the new height
+ */
+ public void setHeight(final Double height) {
+ this.height = height;
+ }
+
+ /**
+ * Sets the left.
+ *
+ * @param left the new left
+ */
+ public void setLeft(final Double left) {
+ this.left = left;
+ }
+
+ /**
+ * Sets the top.
+ *
+ * @param top the new top
+ */
+ public void setTop(final Double top) {
+ this.top = top;
+ }
+}
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/GetCoreMlModelOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/GetCoreMlModelOptions.java
new file mode 100644
index 00000000000..e3576823a01
--- /dev/null
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/GetCoreMlModelOptions.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2018 IBM Corp. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package com.ibm.watson.developer_cloud.visual_recognition.v3.model;
+
+import com.ibm.watson.developer_cloud.service.model.GenericModel;
+import com.ibm.watson.developer_cloud.util.Validator;
+
+/**
+ * The getCoreMlModel options.
+ */
+public class GetCoreMlModelOptions extends GenericModel {
+
+ private String classifierId;
+
+ /**
+ * Builder.
+ */
+ public static class Builder {
+ private String classifierId;
+
+ private Builder(GetCoreMlModelOptions getCoreMlModelOptions) {
+ classifierId = getCoreMlModelOptions.classifierId;
+ }
+
+ /**
+ * Instantiates a new builder.
+ */
+ public Builder() {
+ }
+
+ /**
+ * Instantiates a new builder with required properties.
+ *
+ * @param classifierId the classifierId
+ */
+ public Builder(String classifierId) {
+ this.classifierId = classifierId;
+ }
+
+ /**
+ * Builds a GetCoreMlModelOptions.
+ *
+ * @return the getCoreMlModelOptions
+ */
+ public GetCoreMlModelOptions build() {
+ return new GetCoreMlModelOptions(this);
+ }
+
+ /**
+ * Set the classifierId.
+ *
+ * @param classifierId the classifierId
+ * @return the GetCoreMlModelOptions builder
+ */
+ public Builder classifierId(String classifierId) {
+ this.classifierId = classifierId;
+ return this;
+ }
+ }
+
+ private GetCoreMlModelOptions(Builder builder) {
+ Validator.notEmpty(builder.classifierId, "classifierId cannot be empty");
+ classifierId = builder.classifierId;
+ }
+
+ /**
+ * New builder.
+ *
+ * @return a GetCoreMlModelOptions builder
+ */
+ public Builder newBuilder() {
+ return new Builder(this);
+ }
+
+ /**
+ * Gets the classifierId.
+ *
+ * The ID of the classifier.
+ *
+ * @return the classifierId
+ */
+ public String classifierId() {
+ return classifierId;
+ }
+}
diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/UpdateClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/UpdateClassifierOptions.java
index a811b09cbb7..df92108754e 100644
--- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/UpdateClassifierOptions.java
+++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/UpdateClassifierOptions.java
@@ -174,8 +174,8 @@ public String classifierId() {
* Gets the class names.
*
* A .zip file of images that depict the visual subject of a class in the classifier. The positive examples create or
- * update classes in the classifier. You can include more than one positive example file in a call. Append
- * `_positive_examples` to the form name. The prefix is used to name the class. For example,
+ * update classes in the classifier. You can include more than one positive example file in a call. Specify the
+ * parameter name by appending `_positive_examples` to the class name. For example,
* `goldenretriever_positive_examples` creates the class `goldenretriever`. Include at least 10 images in .jpg or .png
* format. The minimum recommended image resolution is 32X32 pixels. The maximum number of images is 10,000 images or
* 100 MB per .zip file. Encode special characters in the file name in UTF-8.
@@ -199,8 +199,8 @@ public File positiveExamplesByClassName(String className) {
/**
* Gets the negativeExamples.
*
- * A compressed (.zip) file of images that do not depict the visual subject of any of the classes of the new
- * classifier. Must contain a minimum of 10 images. Encode special characters in the file name in UTF-8.
+ * A .zip file of images that do not depict the visual subject of any of the classes of the new classifier. Must
+ * contain a minimum of 10 images. Encode special characters in the file name in UTF-8.
*
* @return the negativeExamples
*/
diff --git a/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionIT.java b/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionIT.java
index dcec4a13e18..d8d57d4cd93 100644
--- a/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionIT.java
+++ b/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionIT.java
@@ -23,6 +23,7 @@
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectedFaces;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetClassifierOptions;
+import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions;
import org.junit.Assume;
import org.junit.Before;
@@ -337,4 +338,25 @@ public void testListClassifiers() {
assertNotNull(classifier.getClasses());
assertNotNull(classifier.getCreated());
}
+
+ /**
+ * Test getting the Core ML file for a classifier.
+ */
+ @Ignore
+ @Test
+ public void testGetCoreMlModel() {
+ ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build();
+ List classifiers = service.listClassifiers(options).execute().getClassifiers();
+
+ for (Classifier classifier : classifiers) {
+ if (classifier.isCoreMlEnabled()) {
+ GetCoreMlModelOptions getCoreMlModelOptions = new GetCoreMlModelOptions.Builder()
+ .classifierId(classifier.getClassifierId())
+ .build();
+ InputStream coreMlFile = service.getCoreMlModel(getCoreMlModelOptions).execute();
+ assertNotNull(coreMlFile);
+ break;
+ }
+ }
+ }
}
diff --git a/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionTest.java b/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionTest.java
index 09cec42ccd5..03a6b820757 100644
--- a/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionTest.java
+++ b/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionTest.java
@@ -12,9 +12,11 @@
*/
package com.ibm.watson.developer_cloud.visual_recognition.v3;
+import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.ibm.watson.developer_cloud.WatsonServiceUnitTest;
+import com.ibm.watson.developer_cloud.http.HttpMediaType;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifiedImages;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifyOptions;
@@ -23,10 +25,12 @@
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectedFaces;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetClassifierOptions;
+import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.UpdateClassifierOptions;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.RecordedRequest;
+import okio.Buffer;
import org.junit.Before;
import org.junit.Test;
@@ -58,6 +62,7 @@ public class VisualRecognitionTest extends WatsonServiceUnitTest {
private static final String PATH_CLASSIFIERS = "/v3/classifiers";
private static final String PATH_CLASSIFIER = "/v3/classifiers/%s";
private static final String PATH_DETECT_FACES = "/v3/detect_faces";
+ private static final String PATH_CORE_ML = "/v3/classifiers/%s/core_ml_model";
private VisualRecognition service;
@@ -328,4 +333,26 @@ public void testGetClassifiers() throws InterruptedException, IOException {
assertEquals("GET", request.getMethod());
assertEquals(serviceResponse, classifiers);
}
+
+ @Test
+ public void testGetCoreMlModel() throws IOException, InterruptedException {
+ final File model = new File("src/test/resources/visual_recognition/custom_model.mlmodel");
+ final Buffer buffer = new Buffer().write(Files.toByteArray(model));
+
+ server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_OCTET_STREAM).setBody(buffer));
+
+ String classifierId = "classifier_id";
+ GetCoreMlModelOptions options = new GetCoreMlModelOptions.Builder()
+ .classifierId(classifierId)
+ .build();
+
+ InputStream modelFile = service.getCoreMlModel(options).execute();
+
+ RecordedRequest request = server.takeRequest();
+ String path = String.format(PATH_CORE_ML, classifierId) + "?" + VERSION_DATE + "=2016-05-20&api_key=" + API_KEY;
+
+ assertEquals(path, request.getPath());
+ assertEquals("GET", request.getMethod());
+ writeInputStreamToFile(modelFile, new File("build/model_result.mlmodel"));
+ }
}
diff --git a/visual-recognition/src/test/resources/visual_recognition/custom_model.mlmodel b/visual-recognition/src/test/resources/visual_recognition/custom_model.mlmodel
new file mode 100644
index 00000000000..35611c91142
Binary files /dev/null and b/visual-recognition/src/test/resources/visual_recognition/custom_model.mlmodel differ