我正在尝试使用以下代码来获取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();
但是,它提供了以下例外:
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)
我做错了什么?
答案 0 :(得分:0)
我发现了问题所在,所以我自己也会回答这个问题。我在我的pom.xml文件中依赖于旧版本的GSON。我更新到最新版本,代码工作正常。