Search in sources :

Example 1 with ConvolutionListenerPersistable

use of org.deeplearning4j.ui.weights.ConvolutionListenerPersistable in project deeplearning4j by deeplearning4j.

the class ConvolutionalListenerModule method getImage.

private Result getImage() {
    if (lastTimeStamp > 0 && lastStorage != null) {
        Persistable p = lastStorage.getStaticInfo(lastSessionID, TYPE_ID, lastWorkerID);
        if (p instanceof ConvolutionListenerPersistable) {
            ConvolutionListenerPersistable clp = (ConvolutionListenerPersistable) p;
            BufferedImage bi = clp.getImg();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ImageIO.write(bi, "jpg", baos);
            } catch (IOException e) {
                log.warn("Error displaying image", e);
            }
            return ok(baos.toByteArray()).as("image/jpg");
        } else {
            return ok(new byte[0]).as("image/jpeg");
        }
    } else {
        return ok(new byte[0]).as("image/jpeg");
    }
}
Also used : Persistable(org.deeplearning4j.api.storage.Persistable) ConvolutionListenerPersistable(org.deeplearning4j.ui.weights.ConvolutionListenerPersistable) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ConvolutionListenerPersistable(org.deeplearning4j.ui.weights.ConvolutionListenerPersistable) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 Persistable (org.deeplearning4j.api.storage.Persistable)1 ConvolutionListenerPersistable (org.deeplearning4j.ui.weights.ConvolutionListenerPersistable)1