1

I'm trying to use the following code to get suggestions for tags for an image from Clarifai:

final ClarifaiClient client = new ClarifaiBuilder(CLIENT_ID, CLIENT_SECRET).buildSync(); 
final ClarifaiResponse<List<ClarifaiOutput<Concept>>> response = client.getDefaultModels().generalModel().predict().withInputs(ClarifaiInput.forImage(ClarifaiImage.of(IMAGE_URL))).executeSync(); 

However, it gives the following exception:

java.lang.IllegalArgumentException: @JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference.
at com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.getTypeAdapter(JsonAdapterAnnotationTypeAdapterFactory.java:64)
at com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.create(JsonAdapterAnnotationTypeAdapterFactory.java:46)
at com.google.gson.Gson.getAdapter(Gson.java:360)
at com.google.gson.Gson.getAdapter(Gson.java:457)
at clarifai2.internal.AutoValueTypeAdapterFactory.create(AutoValueTypeAdapterFactory.java:35)
at com.google.gson.Gson.getAdapter(Gson.java:360)
at com.google.gson.Gson.toJson(Gson.java:597)
at com.google.gson.Gson.toJsonTree(Gson.java:498)
at com.google.gson.Gson.toJsonTree(Gson.java:477)
at clarifai2.api.request.model.PredictRequest$2.call(PredictRequest.java:73)
at clarifai2.api.request.model.PredictRequest$2.call(PredictRequest.java:71)
at clarifai2.internal.JSONArrayBuilder.addAll(JSONArrayBuilder.java:60)
at clarifai2.api.request.model.PredictRequest.buildRequest(PredictRequest.java:71)
at clarifai2.api.request.ClarifaiRequest$Builder.build(ClarifaiRequest.java:180)
at clarifai2.api.request.ClarifaiRequest$Builder.executeSync(ClarifaiRequest.java:188)

What am I doing wrong?

user3429010
  • 365
  • 1
  • 3
  • 8

1 Answers1

1

I found out what the problem was, so I'll answer this myself. I had a dependency to an older version of GSON in my pom.xml file. I updated to the newest version and the code is working fine.

user3429010
  • 365
  • 1
  • 3
  • 8