How to convert photos to paintings with Deep Learning in Node.js

For this exercise, our goal is to automatically convert a photograph like this one:

Image for post
Image for post

Into interpretive, stylistic works of art like these — digital art:

Image for post
Image for post
Image for post
Image for post

To get started, we need to add a reference to the library we will use:

"dependencies": {
"cloudmersive-image-api-client": "^1.1.4"
}

Now, all we need to do is call the right method, artisticPainting:

var CloudmersiveImageApiClient = require('cloudmersive-image-api-client');
var defaultClient = CloudmersiveImageApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveImageApiClient.ArtisticApi();var style = "udnie"; // String | The style of the painting to apply.var imageFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile.jpg").buffer); // File | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.artisticPainting(style, imageFile, callback);

That’s it! Here are some examples generated using this approach:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store