This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- modified version of @jcjohnson's neural-style | |
-- by @htoyryla 13 Feb 2018 | |
-- allows giving emphasis to nc best channel(s) in each style layer | |
-- use -style_layers to select layer as usual, using a single layer is recommended | |
-- -nc to set how many of the best channels are used per layer | |
-- during target capture, tests the model using the style image | |
-- and selects nc channels with strongest activations to be given emphasis during iterations | |
-- not tested with multiple style images | |
require 'torch' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git clone from https://github.com/tkarras/progressive_growing_of_gans | |
# download the snapshot from their Google drive | |
# use the following code in the same directory to generate random faces | |
import os | |
import sys | |
import time | |
import glob | |
import shutil | |
import operator | |
import theano |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- modified version of @jcjohnson's neural-style | |
-- by @htoyryla 14 Feb 2018 | |
-- allows exploring the effect of equalizing the activations of different channels in a style layer | |
require 'torch' | |
require 'nn' | |
require 'image' | |
require 'optim' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- this program takes in an image | |
-- and finds nc channels on a given layer | |
-- having the strongest activations | |
require 'torch' | |
require 'nn' | |
require 'image' | |
require 'loadcaffe' | |
function preprocess(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- neural-style modified by @htoyryla 27 Oct 2017 | |
-- to use both gram matrix (as a statistical evaluation) and a mean of n featuremaps (to retain spatial sturcture of the style image) | |
-- to evaluate style | |
-- StyleLoss and GramMatrix have been copied from fast-neural-style | |
-- but modified to calculate a spatial mean of the feature maps | |
-- new param mean_weight to control the amount of mean for style | |
-- loss_type to select between L2 and SmoothL1 (as in fast-neural-style) | |
-- **** style_scale no longer works, the mean calculation requires that style image is resized as the content image **** | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- this is a modified version of neural_style.lua originally by @jcjohnson | |
-- @htoyryla 24 Oct 2017 | |
-- | |
-- original neural-style includes scaling of gram matrix output and gradient in the StyleLoss | |
-- using division by the number of elements in input | |
-- this is done to make the style representations from different layers (of different size) better comparable | |
-- but it also has the effect of decreasing gradients as the image size is increased | |
-- | |
-- this version attempts to keep the gradients from style loss modules in the same range | |
-- (i.e. that what is obtained at image size 512px) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- modified version of @jcjohnson's neural-style | |
-- by @htoyryla 14 May 2017 | |
-- allows exploring th effect of giving emphasis to specific channel(s) in a style layer | |
-- use -style_layers to select layer as usual, using a single layer is recommended | |
-- -style_channels to specify one or more channels to be given emphasis, other channels will be attenuated | |
-- if a channel does not exist in a layer, it is ignored and given a warning | |
-- note: if multiple style layers are used, style_channels setting affects both | |
require 'torch' | |
require 'nn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- neural-style by jcjohnson modified by @htoyryla | |
-- 13 May 2017 | |
-- generate style variants by modifying style target Gram matrix with randomized eigenvalues | |
-- see function randomizeEigenvalues() for details | |
require 'torch' | |
require 'nn' | |
require 'image' | |
require 'optim' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- neural-style by jcjohnson modified by @htoyryla | |
-- 13 May 2017 | |
-- generate style variants by modifying style target Gram matrix with randomized eigenvalues | |
-- see function randomizeEigenvalues() for details | |
-- this version produces slight variants of a given style | |
-- by multiplying gram matrix eigenvalues by random multiplies 0.1 to 1.9 | |
require 'torch' | |
require 'nn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Neural-style modified by Hannu Töyrylä 13 Sep 2016 | |
-- according to the delta gram matrix method | |
-- as described in http://arxiv.org/abs/1606.01286v1 | |
-- | |
-- Install and use just like http://github.com/jcjohnson/neural-style/ | |
-- except for the additional parameter delta (use values 0 to 16, too large values can result in error) | |
-- | |
require 'torch' | |
require 'nn' |