0

I am trying to use Clarifai API in my application, but getting an error saying that "cannot resolve symbol"

final List<ClarifaiOutput<Concept>> predictionResults = Clarifai.getDefaultModels()
.generalModel()
.predict()
.withInputs(
     ClarifaiInput.forImage(
         ClarifaiImage.of("https://samples.clarifai.com/metro-north.jpg")
     )
).executeSync()

It is saying

not able to resolve symbol Clarifai

Dovydas Šopa
  • 2,282
  • 8
  • 26
  • 34

2 Answers2

0

It looks like something wasn't imported correctly here. Make sure you're following all of the steps outlined at:

https://github.com/Clarifai/clarifai-java

Jared
  • 111
  • 1
  • 8
0

Clarifai is not a class in that repository... https://github.com/Clarifai/clarifai-java

AFAIK, you need to use create a ClarifaiBuilder, then call build() on that, and then you can call getDefaultModels()


From the unit tests.

  @NotNull final ClarifaiClient client = new ClarifaiBuilder(appID, appSecret)
      .baseURL(baseURL)
      .client(new OkHttpClient.Builder()
          .connectTimeout(60, TimeUnit.SECONDS)
          .readTimeout(60, TimeUnit.SECONDS)
          .writeTimeout(60, TimeUnit.SECONDS)
          .addInterceptor(new HttpLoggingInterceptor(System.out::println).setLevel(HttpLoggingInterceptor.Level.BODY))
          .build()
      )
      .buildSync();

...

  @Test public void quickStartPredict() {
    final ClarifaiResponse<List<ClarifaiOutput<Concept>>> predictionResults =
        client.getDefaultModels().generalModel() // You can also do client.getModelByID("id") to get custom models
            .predict()
            .withInputs(
                ClarifaiInput.forImage(ClarifaiImage.of("@@sampleTrain"))
            )
            .executeSync();
  }
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245