use of com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionTest method testGetCoreMlModel.
@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"));
}
use of com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testGetCoreMlModel.
/**
* Test getting the Core ML file for a classifier.
*/
@Ignore
@Test
public void testGetCoreMlModel() {
ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build();
List<Classifier> 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;
}
}
}
Aggregations