1. ContentReconstructionSurvey
  2. VGG19_0a
  3. VGG19_0b
  4. VGG19_1a
  5. VGG19_1b1
  6. VGG19_1b2
  7. VGG19_1c1
  8. VGG19_1c2
  9. VGG19_1c3
  10. VGG19_1c4
  11. VGG19_1d1
  12. VGG19_1d2
  13. VGG19_1d3
  14. VGG19_1d4
  15. VGG19_1e1
  16. VGG19_1e2
  17. VGG19_1e3
  18. VGG19_1e4
  19. VGG19_2

ContentReconstructionSurvey

Reconstructs an example image's content via each layer of the VGG19 network. Paints an image using a variety of layers but each having:
  1. A single input image to define content via a single layer
  2. Random noise initialization
  3. Standard content matching operator
  4. A single resolution
It demonstrates the variety of effects that can be obtained using varied layers to constrain content.

Code from ContentReconstructionSurvey.scala:85 executed in 0.00 seconds (0.000 gc):

      implicit val _ = log
      // First, basic configuration so we publish to our s3 site
      log.setArchiveHome(URI.create(s"s3://$s3bucket/${getClass.getSimpleName.stripSuffix("$")}/${log.getId}/"))
      log.onComplete(() => upload(log): Unit)
      // Fetch image (user upload prompt) and display a rescaled copy
      log.out(log.jpg(ImageArtUtil.load(log, contentUrl, resolution.toInt), "Input Style"))
      val renderedCanvases = new ArrayBuffer[() => BufferedImage]
      // Execute the main process while registered with the site index
      val registration = registerWithIndexGIF(renderedCanvases.map(_ ()), delay = animationDelay)
      withMonitoredGif(() => renderedCanvases.map(_ ()), delay = animationDelay) {
        try {
          for (pipeline <- List(
            VGG19.getVisionPipeline
          )) {
            import scala.collection.JavaConverters._
            for (layer <- pipeline.getLayers.asScala.keys) {
              log.h1(layer.name())
              val canvas = new AtomicReference[Tensor](null)
              renderedCanvases += (() => {
                val image = canvas.get().toImage
                if (null == image) image else {
                  val graphics = image.getGraphics.asInstanceOf[Graphics2D]
                  graphics.setFont(new Font("Calibri", Font.BOLD, 24))
                  graphics.drawString(layer.name(), 10, 25)
                  image
                }
              })
              withMonitoredJpg(() => Option(canvas.get()).map(_.toRgbImage).orNull) {
                var steps = 0
                Try {
                  log.subreport(layer.name(), (sub: NotebookOutput) => {
                    paint(contentUrl, initUrl, canvas, new VisualStyleContentNetwork(
                      contentLayers = List(layer),
                      contentModifiers = List(
                        new ContentMatcher()
                      ),
                      precision = Precision.Double
                    ), new BasicOptimizer {
                      override val trainingMinutes: Int = 60
                      override val trainingIterations: Int = 50
                      override val maxRate = 1e9
  
                      override def onStepComplete(trainable: Trainable, currentPoint: Step): Boolean = {
                        steps = steps + 1
                        super.onStepComplete(trainable, currentPoint)
                      }
                    }, new GeometricSequence {
                      override val min: Double = resolution
                      override val max: Double = resolution
                      override val steps = 1
                    }.toStream.map(_.round.toDouble): _*)(sub)
                    null
                  })
                }
                if (steps < 3 && !renderedCanvases.isEmpty) {
                  renderedCanvases.remove(renderedCanvases.size - 1)
                }
                uploadAsync(log)
              }(log)
            }
          }
          null
        } finally {
          registration.foreach(_.stop()(s3client, ec2client))
        }
      }
    }

Returns:

    <function0>

Input Style

VGG19_0a

Subreport: VGG19_0a

VGG19_0b

Subreport: VGG19_0b

VGG19_1a

Subreport: VGG19_1a

VGG19_1b1

Subreport: VGG19_1b1

VGG19_1b2

Subreport: VGG19_1b2

VGG19_1c1

Subreport: VGG19_1c1

VGG19_1c2

Subreport: VGG19_1c2

VGG19_1c3

Subreport: VGG19_1c3

VGG19_1c4

Subreport: VGG19_1c4

VGG19_1d1

Subreport: VGG19_1d1

VGG19_1d2

Subreport: VGG19_1d2

VGG19_1d3

Subreport: VGG19_1d3

VGG19_1d4

Subreport: VGG19_1d4

VGG19_1e1

Subreport: VGG19_1e1

VGG19_1e2

Subreport: VGG19_1e2

VGG19_1e3

Subreport: VGG19_1e3

VGG19_1e4

Subreport: VGG19_1e4

VGG19_2

Subreport: VGG19_2