0
votes

So I want to make a java application in eclipse which the user i will be able to import .zip files. Each .zip file will represent a cat breed. I will click on a "train" button and my program will contact IBM Watson services and create a classifier. Then from a different window, i will import random cat images and the program will show what cat breed is in the image. Everything with the SDKs is fine since I ran some examples from the official Watson site and everything ran smoothly. Problem comes when I try to create my own classifiers. The code you are about to see is also from their site. For some reason the createClassifier method won't take the CreateClassifierOptions object as an argument.

import java.io.File;

import com.ibm.watson.developer_cloud.http.ServiceCall;
import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionCallback;
import com.ibm.watson.developer_cloud.visual_recognition.v3.*;
import com.ibm.watson.developer_cloud.visual_recognition.v3.model.*;


public class TrainningClassifier{

public static void main(String[] args) {


VisualRecognition service = new VisualRecognition(
          VisualRecognition.VERSION_DATE_2016_05_20
        );

        service.setApiKey("aca4433597018de62edafdeebceb2bdc1482496a");
        CreateClassifierOptions createClassifierOptions = new CreateClassifierOptions.Builder()
          .name("dogs")
          .addClass("beagle", new File("./beagle.zip"))
          .addClass("goldenretriever",new File("./golden-retriever.zip"))
          .addClass("husky", new File("./husky.zip"))
          .negativeExamples(new File("./cats.zip"))
          .build();

        Classifier dogs = service.createClassifier(createClassifierOptions).execute();
        System.out.println(dogs);  /*error is in the above line.
                                     the createClassifier method.*/
}

}

Error: Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method createClassifier(ClassifierOptions) in the type VisualRecognition is not applicable for the arguments (CreateClassifierOptions)

at testVisualRec.ForAssignment.main(ForAssignment.java:31)

Any ideas?

1

1 Answers

0
votes

Found the solution. For some reason eclipse wouldn't recommend this solution I had to experiment. I just added throws IOException in main method. I also put inside the main method System.out.println(new File(".").getAbsoluteFile()); to make sure the path was correct, and it was. (SDK used for this project is 4.0.0, not the newest one. SDK found here: https://github.com/watson-developer-cloud/java-sdk/releases)