Code from StyleTransferSweep.scala:71 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 rescaled copies
log.p(log.jpg(ImageArtUtil.load(log, contentUrl, maxResolution), "Input Content"))
log.p(log.jpg(ImageArtUtil.load(log, styleAUrl, (maxResolution * Math.sqrt(magnification)).toInt), "Input Style A"))
log.p(log.jpg(ImageArtUtil.load(log, styleBUrl, (maxResolution * Math.sqrt(magnification)).toInt), "Input Style B"))
def frames = keyframes * 2 - 1
val canvases = (1 to frames).map(_ => new AtomicReference[Tensor](null)).toList
// Execute the main process while registered with the site index
val registration = registerWithIndexGIF_Cyclic(canvases.map(_.get()), delay = delay)
try {
animate(contentUrl, initUrl, canvases, log.eval(() => (1 to frames).map(f => {
var coeffA = Math.pow(separation, (f.toDouble / frames) - 0.5)
var coeffB = 1.0 / coeffA
val mag = coeffA + coeffB
coeffA = coeffA / mag
coeffB = coeffB / mag
f"$coeffA%.3e - $coeffB%.3e" -> {
val styleLayers = List(
// We select all the lower-level layers to achieve a good balance between speed and accuracy.
VGG16.VGG16_0,
VGG16.VGG16_1a,
VGG16.VGG16_1b1,
VGG16.VGG16_1b2,
VGG16.VGG16_1c1,
VGG16.VGG16_1c2,
VGG16.VGG16_1c3
)
new VisualStyleNetwork(
// This primary component accounts for style A
styleLayers = styleLayers,
styleModifiers = List(
// These two operators are a good combination for a vivid yet accurate style
new GramMatrixEnhancer().scale(coeffA),
new MomentMatcher().scale(coeffA)
),
styleUrl = List(styleAUrl),
magnification = magnification
) + new VisualStyleNetwork(
styleLayers = styleLayers,
styleModifiers = List(
// We use the same two operators in the alternate component, which calculates the style B
new GramMatrixEnhancer().scale(coeffB),
new MomentMatcher().scale(coeffB)
),
styleUrl = List(styleBUrl),
magnification = magnification
).withContent(
contentLayers = List(
VGG16.VGG16_1b2
),
contentModifiers = List(
new ContentMatcher()
))
}
}).toList), new BasicOptimizer {
override val trainingMinutes: Int = 60
override val trainingIterations: Int = 30
override val maxRate = 1e9
}, new GeometricSequence {
override val min: Double = minResolution
override val max: Double = maxResolution
override val steps = StyleTransferSweep.this.steps
}.toStream.map(_.round.toDouble),
delay = StyleTransferSweep.this.delay)
null
} finally {
registration.foreach(_.stop()(s3client, ec2client))
}
}
<function0>
Code from StyleTransferSweep.scala:88 executed in 0.93 seconds (0.000 gc):
var coeffA = Math.pow(separation, (f.toDouble / frames) - 0.5)
var coeffB = 1.0 / coeffA
val mag = coeffA + coeffB
coeffA = coeffA / mag
coeffB = coeffB / mag
f"$coeffA%.3e - $coeffB%.3e" -> {
val styleLayers = List(
// We select all the lower-level layers to achieve a good balance between speed and accuracy.
VGG16.VGG16_0,
VGG16.VGG16_1a,
VGG16.VGG16_1b1,
VGG16.VGG16_1b2,
VGG16.VGG16_1c1,
VGG16.VGG16_1c2,
VGG16.VGG16_1c3
)
new VisualStyleNetwork(
// This primary component accounts for style A
styleLayers = styleLayers,
styleModifiers = List(
// These two operators are a good combination for a vivid yet accurate style
new GramMatrixEnhancer().scale(coeffA),
new MomentMatcher().scale(coeffA)
),
styleUrl = List(styleAUrl),
magnification = magnification
) + new VisualStyleNetwork(
styleLayers = styleLayers,
styleModifiers = List(
// We use the same two operators in the alternate component, which calculates the style B
new GramMatrixEnhancer().scale(coeffB),
new MomentMatcher().scale(coeffB)
),
styleUrl = List(styleBUrl),
magnification = magnification
).withContent(
contentLayers = List(
VGG16.VGG16_1b2
),
contentModifiers = List(
new ContentMatcher()
))
}
List((5.935e-02 - 9.406e-01,com.simiacryptus.mindseye.art.util.VisualNetwork$$anon$2@5d5b9ecb), (2.847e-01 - 7.153e-01,com.simiacryptus.mindseye.art.util.VisualNetwork$$anon$2@1ee27d73), (7.153e-01 - 2.847e-01,com.simiacryptus.mindseye.art.util.VisualNetwork$$anon$2@5e5aafc6), (9.406e-01 - 5.935e-02,com.simiacryptus.mindseye.art.util.VisualNetwork$$anon$2@542f6803), (9.901e-01 - 9.901e-03,com.simiacryptus.mindseye.art.util.VisualNetwork$$anon$2@5583098b))