/** * Create an {@link AnnotatedObject} with the given object and its * annotation. * * @param <OBJECT> * Type of object. * @param <ANNOTATION> * Type of annotations * @param object * the object * @param annotation * the object's annotation. * @return the new {@link AnnotatedObject} */ public static <OBJECT, ANNOTATION> AnnotatedObject<OBJECT, ANNOTATION> create(OBJECT object, ANNOTATION annotation) { return new AnnotatedObject<OBJECT, ANNOTATION>(object, annotation); }
/** * Create an {@link AnnotatedObject} with the given object and its * annotations. * * @param <OBJECT> * Type of object. * @param <ANNOTATION> * Type of annotations * @param object * the object * @param annotations * the objects annotations. * @return the new {@link AnnotatedObject} */ public static <OBJECT, ANNOTATION> AnnotatedObject<OBJECT, ANNOTATION> create(OBJECT object, Collection<ANNOTATION> annotations) { return new AnnotatedObject<OBJECT, ANNOTATION>(object, annotations); }
/** * Convert a grouped dataset to a list of annotated objects. The annotations * correspond to the type of group. If the same object appears in multiple * groups within the dataset then it will have multiple annotations. * * @param <OBJECT> * Type of object. * @param <ANNOTATION> * Type of annotations. * @param dataset * the dataset * @return the list of annotated instances */ public static <OBJECT, ANNOTATION> List<AnnotatedObject<OBJECT, ANNOTATION>> createList( GroupedDataset<ANNOTATION, ? extends ListDataset<OBJECT>, OBJECT> dataset) { final Map<OBJECT, AnnotatedObject<OBJECT, ANNOTATION>> annotated = new HashMap<OBJECT, AnnotatedObject<OBJECT, ANNOTATION>>( dataset.numInstances()); for (final ANNOTATION grp : dataset.getGroups()) { for (final OBJECT inst : dataset.getInstances(grp)) { final AnnotatedObject<OBJECT, ANNOTATION> ao = annotated.get(inst); if (ao == null) annotated.put(inst, new AnnotatedObject<OBJECT, ANNOTATION>(inst, grp)); else ao.annotations.add(grp); } } return new ArrayList<AnnotatedObject<OBJECT, ANNOTATION>>(annotated.values()); }
recogniser.train(new AnnotatedObject<CLMDetectedFace, String>(faces.get(0), person)); } else { System.out.println("Wrong number of faces found");
recogniser.train(new AnnotatedObject<CLMDetectedFace, String>(faces.get(0), person)); } else { System.out.println("Wrong number of faces found");
recogniser.train(new AnnotatedObject<CLMDetectedFace, String>(faces.get(0), person)); } else { System.out.println("Wrong number of faces found");
recogniser.train(new AnnotatedObject<CLMDetectedFace, String>(faces.get(0), person)); } else { System.out.println("Wrong number of faces found");
/** * Train the annotator with the given grouped dataset. This method assumes * that each object only appears in a <b>single</b> group of the dataset * (i.e. a multi-class problem). Each group corresponds to the one single * annotation assigned to each object. * <p> * If your dataset contains multiple labels for each object (through an * object appearing in multiple groups) you should use * {@link #train(GroupedDataset)}. * * @param dataset * the dataset to train on */ public void trainMultiClass(GroupedDataset<ANNOTATION, ? extends ListDataset<OBJECT>, OBJECT> dataset) { for (final ANNOTATION grp : dataset.getGroups()) { for (final OBJECT inst : dataset.getInstances(grp)) { train(new AnnotatedObject<OBJECT, ANNOTATION>(inst, grp)); } } }
new AnnotatedObject<DoubleFV, String>( new DoubleFV(calculatedMFCC[0]), speechFiles?"Speech":"Non-Speech" );
new AnnotatedObject<DoubleFV, String>( new DoubleFV(calculatedMFCC[0]), speechFiles?"Speech":"Non-Speech" );