1. HighResStyleTransfer
  2. Resolution 200.0
  3. Resolution 400.0
  4. Resolution 600.0
  5. Resolution 800.0
  6. Resolution 1024.0
  7. Resolution 1280.0
  8. Resolution 1600.0
  9. Resolution 2000.0
  10. Resolution 2828.0
  11. Resolution 4000.0

HighResStyleTransfer

Paints an image in the style of another using multiple resolution phases, each with tuned parameters. The result is a high resolution, high quality rendered painting.

Code from HighResStyleTransfer.scala:55 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 input images (user upload prompts) and display a rescaled copies
      log.p(log.jpg(ImageArtUtil.load(log, styleUrl, (1200 * Math.sqrt(2)).toInt), "Input Style"))
      log.p(log.jpg(ImageArtUtil.load(log, contentUrl, 1200), "Input Content"))
      val canvas = new AtomicReference[Tensor](null)
      // Execute the main process while registered with the site index
      val registration = registerWithIndexJPG(canvas.get())
      try {
        // Display an additional image inside the report itself
        withMonitoredJpg(() => canvas.get().toImage) {
          paint(contentUrl, initUrl, canvas, new VisualStyleContentNetwork(
            styleLayers = List(
              VGG16.VGG16_1b1,
              VGG16.VGG16_1b2,
              VGG16.VGG16_1c1,
              VGG16.VGG16_1c2,
              VGG16.VGG16_1c3,
              VGG16.VGG16_1d1,
              VGG16.VGG16_1d2,
              VGG16.VGG16_1d3
            ),
            styleModifiers = List(
              new GramMatrixEnhancer(),
              new MomentMatcher()
            ),
            styleUrl = List(styleUrl),
            contentLayers = List(
              VGG16.VGG16_1c1
            ),
            contentModifiers = List(
              new ContentMatcher().scale(1e1)
            ),
            magnification = 9
          ) + new VisualStyleNetwork(
            styleLayers = List(
              VGG16.VGG16_0a
            ),
            styleModifiers = List(
              new GramMatrixEnhancer(),
              new MomentMatcher()
            ).map(_.scale(1e2)),
            styleUrl = List(contentUrl),
            magnification = 9
          ), new BasicOptimizer {
            override val trainingMinutes: Int = 60
            override val trainingIterations: Int = 20
            override val maxRate = 1e9
          }, new GeometricSequence {
            override val min: Double = 200
            override val max: Double = 400
            override val steps = 2
          }.toStream.map(_.round.toDouble): _*)
          paint(contentUrl, initUrl, canvas, new VisualStyleContentNetwork(
            styleLayers = List(
              VGG16.VGG16_1a,
              VGG16.VGG16_1b1,
              VGG16.VGG16_1b2,
              VGG16.VGG16_1c1,
              VGG16.VGG16_1c2,
              VGG16.VGG16_1c3,
              VGG16.VGG16_1d1,
              VGG16.VGG16_1d2,
              VGG16.VGG16_1d3,
              VGG16.VGG16_1e1,
              VGG16.VGG16_1e2,
              VGG16.VGG16_1e3,
              VGG16.VGG16_2
            ),
            styleModifiers = List(
              new GramMatrixEnhancer(),
              new MomentMatcher()
            ),
            styleUrl = List(styleUrl),
            contentLayers = List(
              VGG16.VGG16_1b2.prependAvgPool(2)
            ),
            contentModifiers = List(
              new ContentMatcher().scale(1e1)
            ),
            magnification = 4
          ) + new VisualStyleNetwork(
            styleLayers = List(
              VGG16.VGG16_0a
            ),
            styleModifiers = List(
              new GramMatrixEnhancer(),
              new MomentMatcher()
            ).map(_.scale(1e2)),
            styleUrl = List(contentUrl),
            magnification = 9
          ), new BasicOptimizer {
            override val trainingMinutes: Int = 60
            override val trainingIterations: Int = 20
            override val maxRate = 1e9
          }, new GeometricSequence {
            override val min: Double = 600
            override val max: Double = 800
            override val steps = 2
          }.toStream.map(_.round.toDouble): _*)
          paint(contentUrl, initUrl, canvas, new VisualStyleContentNetwork(
            styleLayers = List(
              VGG16.VGG16_1a,
              VGG16.VGG16_1b1,
              VGG16.VGG16_1b2,
              VGG16.VGG16_1c1,
              VGG16.VGG16_1c2,
              VGG16.VGG16_1c3,
              VGG16.VGG16_1d1,
              VGG16.VGG16_1d2,
              VGG16.VGG16_1d3,
              VGG16.VGG16_1e1,
              VGG16.VGG16_1e2,
              VGG16.VGG16_1e3
            ),
            styleModifiers = List(
              new MomentMatcher()
            ),
            styleUrl = List(styleUrl),
            contentLayers = List(
              VGG16.VGG16_1b2.prependAvgPool(4)
            ),
            contentModifiers = List(
              new ContentMatcher().scale(1e1)
            )
          ) + new VisualStyleNetwork(
            styleLayers = List(
              VGG16.VGG16_0a
            ),
            styleModifiers = List(
              new GramMatrixEnhancer(),
              new MomentMatcher()
            ).map(_.scale(1e2)),
            styleUrl = List(contentUrl),
            magnification = 9
          ), new BasicOptimizer {
            override val trainingMinutes: Int = 90
            override val trainingIterations: Int = 20
            override val maxRate = 1e9
          }, new GeometricSequence {
            override val min: Double = 1024
            override val max: Double = 1600
            override val steps = 3
          }.toStream.map(_.round.toDouble): _*)
          paint(contentUrl, initUrl, canvas, new VisualStyleContentNetwork(
            styleLayers = List(
              VGG16.VGG16_1a,
              VGG16.VGG16_1b1,
              VGG16.VGG16_1b2
            ),
            styleModifiers = List(
              new MomentMatcher()
            ),
            styleUrl = List(styleUrl),
            contentLayers = List(
              VGG16.VGG16_1b2.prependAvgPool(8).appendMaxPool(2)
            ),
            contentModifiers = List(
              new ContentMatcher().scale(1e1)
            )
          ), new BasicOptimizer {
            override val trainingMinutes: Int = 120
            override val trainingIterations: Int = 20
            override val maxRate = 1e9
          }, new GeometricSequence {
            override val min: Double = 2000
            override val max: Double = 4000
            override val steps = 3
          }.toStream.map(_.round.toDouble): _*)
        }
        null
      } finally {
        registration.foreach(_.stop()(s3client, ec2client))
      }
    }

Returns:

    <function0>

Input Style

Input Content

Resolution 200.0

Subreport: Optimization

Resolution 400.0

Subreport: Optimization

Resolution 600.0

Subreport: Optimization

Resolution 800.0

Subreport: Optimization

Resolution 1024.0

Subreport: Optimization

Resolution 1280.0

Subreport: Optimization

Resolution 1600.0

Subreport: Optimization

Resolution 2000.0

Subreport: Optimization

Resolution 2828.0

Subreport: Optimization

Resolution 4000.0

Subreport: Optimization