1. TextureSurvey
  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

TextureSurvey

Reconstructs an example image's texture into free-form content via each layer of the VGG19 network. Paints a texture using a variety of layers but each having:
  1. A single input image to define style
  2. Random noise initialization
  3. Operators to match content and constrain and enhance style
  4. A single resolution
It demonstrates the variety of effects that can be obtained using varied layers.

Code from TextureSurvey.scala:70 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, styleUrl, (resolution * Math.sqrt(magnification)).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("Painting", (sub: NotebookOutput) => {
                    paint(styleUrl, initUrl, canvas, new VisualStyleNetwork(
                      styleLayers = List(layer),
                      styleModifiers = List(
                        // These two operators are a good combination for a vivid yet accurate style
                        new GramMatrixEnhancer(),
                        new MomentMatcher()
                      ),
                      styleUrl = List(styleUrl),
                      magnification = magnification
                    ), new BasicOptimizer {
                      override val trainingMinutes: Int = 60
                      override val trainingIterations: Int = 25
                      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: Painting

VGG19_0b

Subreport: Painting

VGG19_1a

Subreport: Painting

VGG19_1b1

Subreport: Painting

VGG19_1b2

Subreport: Painting

VGG19_1c1

Subreport: Painting

VGG19_1c2

Subreport: Painting

VGG19_1c3

Subreport: Painting

VGG19_1c4

Subreport: Painting

VGG19_1d1

Subreport: Painting

VGG19_1d2

Subreport: Painting

VGG19_1d3

Subreport: Painting

VGG19_1d4

Subreport: Painting

VGG19_1e1

Subreport: Painting

VGG19_1e2

Subreport: Painting

VGG19_1e3

Subreport: Painting

VGG19_1e4

Subreport: Painting

VGG19_2

Subreport: Painting