Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const spawnSync = require('spawn-sync');
- const walk = require('walk');
- const url = require("url");
- const fs = require('fs');
- const learnRounds = 500;
- var walker = walk.walk('./images/in', { followLinks: false });
- walker.on('file', function(root, stat, next) {
- var path = root.replace("./images/in", "");
- var folderPath = path + '/' + stat.name;
- var totalPath = folderPath.replace(/ /g,"\\ ");
- console.log('Total: ' + totalPath);
- if (!fs.existsSync("images/out"+path)) {
- fs.mkdirSync("images/out"+path);
- console.log("Created images/out"+path);
- } else {
- console.log("Skipping creation of images/out"+path);
- }
- if (!fs.existsSync('images/out/' + totalPath)) {
- var result = spawnSync('th', [
- 'neural_style.lua',
- '-style_image',
- 'images/style.jpg',
- '-content_image',
- 'images/in' + totalPath,
- '-gpu',
- '0',
- '-backend',
- 'cudnn',
- '-output_image',
- 'images/out/' + totalPath,
- '-num_iterations',
- learnRounds // 500
- ], {input: ''});
- if (result.status !== 0) {
- next();
- } else {
- next();
- }
- } else {
- console.log("File exists in out, skipping");
- next();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement