Peter Litvak
Peter Litvak

Reputation: 95

How do I set MaxConcepts for when calling postModelOutputs in latest version of Java API?

Can anyone point me to the documentation or an example on the subject? I'm using one of the standard models so I assume there should be away to set this as a parameter. I've tried to set it as follows:

generalModel = Model.newBuilder(generalModel)
                    .setOutputInfo(OutputInfo.newBuilder(model.getOutputInfo())
                        .setOutputConfig(OutputConfig.newBuilder(model.getOutputInfo().getOutputConfig())
                            .setMaxConcepts(200)
                            .build())
                        .build())
                    .build()

but it doesn't respect the MaxConcepts count

Upvotes: 0

Views: 40

Answers (1)

mimarcel
mimarcel

Reputation: 695

I found this documentation: Prediction Parameters.

The example from this documentation, includes this code:

MultiOutputResponse postModelOutputsResponse = stub.postModelOutputs(
    PostModelOutputsRequest.newBuilder()
        .setModelId("aaa03c23b3724a16a56b629203edc62c")  // This is model ID of the clarifai/main General model.
        .addInputs(
            Input.newBuilder().setData(
                Data.newBuilder().setImage(
                    Image.newBuilder().setUrl("https://samples.clarifai.com/metro-north.jpg")
                )
            )
        )
        .setModel(
            Model.newBuilder().setOutputInfo(
                OutputInfo.newBuilder().setOutputConfig(
                    OutputConfig.newBuilder().setMaxConcepts(3)
                )
            )
        )
        .build()
);

It seems the main difference is that they call build() only once. I haven't tested it, but I guess that shouldn't bring any change.

Upvotes: 0

Related Questions