Style Transfer is a machine learning technique that allows to transfer the style of one image into another one. This is a two step process, first you need to train a model on one particular style and then you can apply this style to another image.
Quickstart :
// Create a new Style Transfer Instance
const style = ml5.styleTransfer('data/myModel/', modelLoaded);
// When the model is loaded
function modelLoaded() {
console.log('Model Loaded!');
}
// Grab a img element and generate a new image.
style.transfer(document.getElementById("img"), function(error, result) {
img.src = result.src;
});
Usage :
Initialize :
const styletransfer = ml5.styleTransfer(model, ?callback);
// OR
const styletransfer = ml5.styleTransfer(model, ?video, ?callback);
Parameters :
* model : The path to Style Transfer model.
* video : Optional. A HTML video element or a p5 video element.
* callback : Optional. A function to be called once the model is loaded. If no callback is provided, it will return a promise that will be resolved once the model has loaded.