0

I'm new to the Clarifai. I'm trying sample demo code using java in Clarifai portal. Below is my code. I'm getting the errors. I don't have any idea. can someone please help me.

package com.demo.clarifia;

import java.util.List;

import clarifai2.api.ClarifaiBuilder;
import clarifai2.api.ClarifaiClient;
import clarifai2.api.ClarifaiResponse;
import clarifai2.dto.input.ClarifaiInput;
import clarifai2.dto.model.ConceptModel;
import clarifai2.dto.model.ModelVersion;
import okhttp3.OkHttpClient;
import clarifai2.dto.model.output.ClarifaiOutput;
import clarifai2.dto.prediction.Prediction;



public class TestDemo {

private static ClarifaiClient client;

public static void main(String[] args) {
    // TODO Auto-generated method stub

    //      System.err.println("Hello Maven");

    new ClarifaiBuilder("6f890249d808461a90258289f65c792f")
    .client(new OkHttpClient()) // OPTIONAL. Allows customization of OkHttp by the user
    .buildSync(); // or use .build() to get a Future<ClarifaiClient>

    ConceptModel model = client.getDefaultModels().generalModel();
    ModelVersion modelVersion = model.getVersionByID("the-version").executeSync().get();

    ClarifaiResponse<List<ClarifaiOutput<Prediction>>> response = client.predict(model.id())
        .withInputs(ClarifaiInput.forImage("http://www.google.com"))
        .withVersion("aa7f35c01e0642fda5cf400f543e7c40") //Error here
        .executeSync();

    }

}

1 Answers1

1

So the method withVersion requires a parameter of type ModelVersion, but you gave it a String. So create a ModelVersion object from your String.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142