I'm trained a custom model for image recognition and it works well along with response of the concept and value i tried to get the custom meta data which i added to the concepts but unable to get the meta data it return null while debugging. How do i get the custom meta data along with the response?
for (BufferedImage bufferedImage : croppedImages)
{
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
ImageIO.write(bufferedImage, "jpg", byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
// byte[] bytes = image.getBytes();
ByteString imageContent = ByteString.copyFrom(bytes);
Input input = Input.newBuilder()
.setData(Data.newBuilder()
.setImage(com.clarifai.grpc.api.Image.newBuilder()
.setBase64(imageContent)
.build())
.build()).build();
inputs.add(input);
}catch (IOException e) {
System.err.println("Error processing cropped image: " + e.getMessage());
}
}
}
MultiOutputResponse postModelOuputResponse = stub.postModelOutputs(
PostModelOutputsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setModelId(MODEL_ID)
.setVersionId(MODEL_VERSION_ID)
.addAllInputs(inputs)
.build()
);
if (postModelOuputResponse.getStatus().getCode() != StatusCode.SUCCESS)
{
throw new RuntimeException("post model output failed, status: "+postModelOuputResponse.getStatus());
}
List<Product> productList = new ArrayList<>();
for (Output output : postModelOuputResponse.getOutputsList()) {
System.out.println("meta "+output.getData().getMetadata().getFieldsMap());
for (Concept concept : output.getData().getConceptsList()) {
if (concept.getValue()*100 >= 70.00) {
System.out.printf("%s %.2f%n", concept.getName(), concept.getValue());
System.out.println(concept.getValue() * 100);
Product product = productRepository.findByKeyName(concept.getName());
if (product == null)
continue;
product.setConfidenceScore(String.valueOf(concept.getValue()*100));
Serializable serializable = product.name != null ? productList.add(product) : "";
}
}
}
Need to get the meta data along with the response