Published
Edited
Jul 28, 2021
2 stars
Insert cell
Insert cell
contentImg = FileAttachment('content.jpg').image()
Insert cell
styleImg = FileAttachment('style2.jpg').image()
Insert cell
button({
label: 'Stylize',
onClick: async () => {
await model.initialize();
await clearCanvas();
output.width = contentImg.width;
output.height = contentImg.height;
model.stylize(contentImg, styleImg).then(imageData => {
ctx.putImageData(imageData, 0, 0);
});
}
})
Insert cell
output = html`<canvas height="250px"></canvas>`
Insert cell
mi = import('//cdn.skypack.dev/@magenta/image')
Insert cell
model = new mi.ArbitraryStyleTransferNetwork()
Insert cell
ctx = output.getContext('2d')
Insert cell
clearCanvas = async () => {
await mi.tf.nextFrame();
ctx.clearRect(0, 0, output.width, output.height);
await mi.tf.nextFrame();
}
Insert cell
import { renderedButton as button } from '@gnestor/react-components'
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more