use of com.simiacryptus.util.test.LabeledObject in project MindsEye by SimiaCryptus.
the class ImageCategoryDatasetDemo method run.
/**
* Test.
*
* @param log the log
*/
public void run(@Nonnull NotebookOutput log) {
log.h3("Loading Data");
List<LabeledObject<SupplierWeakCache<BufferedImage>>> testData = getTrainingStream(log).sorted(getShuffleComparator()).collect(Collectors.toList());
log.h3("Categories");
log.code(() -> {
testData.stream().collect(Collectors.groupingBy(x -> x.label, Collectors.counting())).forEach((k, v) -> ImageCategoryDatasetDemo.logger.info(String.format("%s -> %d", k, v)));
});
log.h3("Sample Data");
log.p(log.code(() -> {
return testData.stream().map(labeledObj -> {
@Nullable BufferedImage img = labeledObj.data.get();
img = TestUtil.resize(img, 224, true);
return log.image(img, labeledObj.label);
}).limit(20).reduce((a, b) -> a + b).get();
}, 256 * 1024));
}
Aggregations