1. TextureGrowth
  2. VGG16_0
    1. 1 steps
    2. 2 steps
    3. 5 steps
  3. VGG16_1a
    1. 1 steps
    2. 2 steps
    3. 5 steps
  4. VGG16_1b1
    1. 1 steps
    2. 2 steps
    3. 5 steps
  5. VGG16_1b2
    1. 1 steps
    2. 2 steps
    3. 5 steps
  6. VGG16_1c1
    1. 1 steps
    2. 2 steps
    3. 5 steps
  7. VGG16_1c2
    1. 1 steps
    2. 2 steps
    3. 5 steps
  8. VGG16_1c3
    1. 1 steps
    2. 2 steps
    3. 5 steps
  9. VGG16_1d1
    1. 1 steps
    2. 2 steps
    3. 5 steps
  10. VGG16_1d2
    1. 1 steps
    2. 2 steps
    3. 5 steps
  11. VGG16_1d3
    1. 1 steps
    2. 2 steps
    3. 5 steps
  12. VGG16_1e1
    1. 1 steps
    2. 2 steps
    3. 5 steps
  13. VGG16_1e2
    1. 1 steps
    2. 2 steps
    3. 5 steps
  14. VGG16_1e3
    1. 1 steps
    2. 2 steps
    3. 5 steps
  15. VGG16_2
    1. 1 steps
    2. 2 steps
    3. 5 steps
  16. VGG16_3a
    1. 1 steps
    2. 2 steps
    3. 5 steps
  17. VGG16_3b
    1. 1 steps
    2. 2 steps
    3. 5 steps

TextureGrowth

Paints a texture using a variety of resolution schedules, each with:
  1. A single input image to define style
  2. Random noise initialization
  3. Standard VGG16 layers to define the style
  4. Operators to match content and constrain and enhance style
Demonstrates the effect of iteratively repainting while magnifying an image.

Code from TextureGrowth.scala:72 executed in 0.00 seconds (0.000 gc):

      implicit val _ = log
      log.setArchiveHome(URI.create(s"s3://$s3bucket/${getClass.getSimpleName.stripSuffix("$")}/${log.getId}/"))
      log.onComplete(() => upload(log): Unit)
      log.out(log.jpg(ImageArtUtil.load(log, styleUrl, (maxResolution * Math.sqrt(magnification)).toInt), "Input Style"))
      val renderedCanvases = new ArrayBuffer[() => BufferedImage]
      val registration = registerWithIndexGIF(renderedCanvases.map(_ ()), delay = animationDelay)
      NotebookRunner.withMonitoredGif(() => {
        renderedCanvases.map(_ ())
      }, delay = animationDelay) {
        try {
          val pipeline = VGG16.getVisionPipeline
          import scala.collection.JavaConverters._
          for (layer <- pipeline.getLayers.asScala.keys) {
            log.h1(layer.name())
            for (numberOfSteps <- List(1, 2, 5)) {
              log.h2(s"$numberOfSteps steps")
              val canvas = new AtomicReference[Tensor](null)
              renderedCanvases += (() => {
                val image = ImageUtil.resize(canvas.get().toImage, maxResolution)
                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)
                  graphics.drawString(s"$numberOfSteps steps", 10, image.getHeight - 10)
                  image
                }
              })
              withMonitoredJpg(() => Option(canvas.get()).map(_.toRgbImage).orNull) {
                var steps = 0
                Try {
                  log.subreport(s"$numberOfSteps steps", (sub: NotebookOutput) => {
                    paint(styleUrl, initUrl, canvas, new VisualStyleNetwork(
                      styleLayers = List(layer),
                      styleModifiers = List(
                        new GramMatrixEnhancer(),
                        new MomentMatcher()
                      ),
                      styleUrl = List(styleUrl),
                      magnification = magnification
                    ), new BasicOptimizer {
                      override val trainingMinutes: Int = 60 / numberOfSteps
                      override val trainingIterations: Int = 30 / numberOfSteps
                      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 = minResolution
                      override val max: Double = maxResolution
                      override val steps = numberOfSteps
                    }.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

VGG16_0

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1a

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1b1

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1b2

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1c1

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1c2

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1c3

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1d1

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1d2

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1d3

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1e1

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1e2

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_1e3

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_2

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_3a

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps

VGG16_3b

1 steps

Subreport: 1 steps

2 steps

Subreport: 2 steps

5 steps

Subreport: 5 steps