PredictRequest 类型中带有 Version(ModelVersion) 的方法<Prediction>不适用于参数(字符串)



我是Clarifai的新手。我正在Clarifai门户中尝试使用java的示例演示代码。下面是我的代码。我得到了错误。我不知道。有人能帮帮我吗。

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();
}
}

因此方法withVersion需要一个类型为ModelVersion的参数,但您给了它一个String。因此,从String创建一个ModelVersion对象。

相关内容

最新更新