Rank
Search By Concept
By clarifai/main App Concepts
import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.*;
// Insert here the initialization code as outlined on this page:
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
MultiSearchResponse postSearchesResponse = stub.postSearches(
PostSearchesRequest.newBuilder().setQuery(
Query.newBuilder().addAnds(
And.newBuilder().setOutput( // Setting Output indicates we search for images that have the concept(s)
// which were predicted by the General model.
Output.newBuilder().setData(
Data.newBuilder().addConcepts( // You can search by multiple concepts.
Concept.newBuilder()
.setName("people") // You could search by concept ID as well.
.setValue(1f) // Value of 0 will search for images that don't have the concept.
)
)
)
)
)
.build()
);
if (postSearchesResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Post searches failed, status: " + postSearchesResponse.getStatus());
}
System.out.println("Found inputs " + postSearchesResponse.getHitsCount() + ":");
for (Hit hit : postSearchesResponse.getHitsList()) {
System.out.printf("\tScore %.2f for %s\n", hit.getScore(), hit.getInput().getId());
}By Custom Concepts
By clarifai/main and custom concepts
By concept in another language
By Image
By Url
Last updated
Was this helpful?