package clarifai2.dto.prediction;

import clarifai2.internal.grpc.api.ConceptOuterClass;
import clarifai2.internal.grpc.api.DataOuterClass;
import clarifai2.dto.input.Crop;
import com.google.auto.value.AutoValue;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("NullableProblems")
@AutoValue
public abstract class Detection extends Prediction {

  Detection() {} // AutoValue instances only

  @NotNull public abstract Crop crop();

  @NotNull public abstract List<Concept> concepts();


  @NotNull public static Detection deserialize(DataOuterClass.Region detection) {
    Crop crop = Crop.deserialize(detection.getRegionInfo().getBoundingBox());

    List<Concept> concepts = new ArrayList<>();
    for (ConceptOuterClass.Concept concept : detection.getData().getConceptsList()) {
      concepts.add(Concept.deserialize(concept));
    }

    return new AutoValue_Detection(crop, concepts);
  }
}

@@ -166,16 +166,67 @@
 t.Crop;%0A
+import clarifai2.internal.grpc.api.FaceOuterClass;%0A
 import c
@@ -257,16 +257,16 @@
 oValue;%0A
-
 import o
@@ -596,16 +596,209 @@
 pts();%0A%0A
+  @NotNull public abstract List%3CConcept%3E ageAppearances();%0A%0A  @NotNull public abstract List%3CConcept%3E genderAppearances();%0A%0A  @NotNull public abstract List%3CConcept%3E multiculturalAppearances();%0A%0A
 %0A  @NotN
@@ -1142,16 +1142,827 @@
 %0A    %7D%0A%0A
+    List%3CConcept%3E ageAppearanceConcepts = new ArrayList%3C%3E();%0A    List%3CConcept%3E genderAppearanceConcepts = new ArrayList%3C%3E();%0A    List%3CConcept%3E multiculturalAppearanceConcepts = new ArrayList%3C%3E();%0A%0A    FaceOuterClass.Face face = detection.getData().getFace();%0A    if (face != null) %7B%0A      for (ConceptOuterClass.Concept concept : face.getAgeAppearance().getConceptsList()) %7B%0A        ageAppearanceConcepts.add(Concept.deserialize(concept));%0A      %7D%0A      for (ConceptOuterClass.Concept concept : face.getGenderAppearance().getConceptsList()) %7B%0A        genderAppearanceConcepts.add(Concept.deserialize(concept));%0A      %7D%0A      for (ConceptOuterClass.Concept concept : face.getMulticulturalAppearance().getConceptsList()) %7B%0A        multiculturalAppearanceConcepts.add(Concept.deserialize(concept));%0A      %7D%0A    %7D%0A%0A
     retu
@@ -1988,16 +1988,25 @@
 tection(
+%0A        
 crop, co
@@ -2011,16 +2011,103 @@
 concepts
+, ageAppearanceConcepts, genderAppearanceConcepts, multiculturalAppearanceConcepts%0A    
 );%0A  %7D%0A%7D

Add appearances to Detection