Skip to content

Instantly share code, notes, and snippets.

@htoyryla
htoyryla / _ht_gan.txt
Last active Jun 11, 2018
HT-GAN including AE and growing image size
View _ht_gan.txt
code for a gan trainer
adding an encoder to assist in generator training
htoyryla 8 Jun 2018
support for progressive training with larger image size
htoyryla 11.6.2018
View neural-equalchannels.lua
-- 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'
View neural_bestchannels.lua
-- 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'
View bestchannels.lua
-- 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)
View test.py
# 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
@htoyryla
htoyryla / neural-mean2.lua
Last active Oct 27, 2017
Neural-style with additional loss through spatial mean of feature maps
View neural-mean2.lua
-- 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 ****
@htoyryla
htoyryla / neural_grad.lua
Created Oct 24, 2017
neural-style modified not to decrease style gradients when image size is increased
View neural_grad.lua
-- 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)
@htoyryla
htoyryla / neural-channels.lua
Last active May 18, 2017
Neural-style with selected channels emphasis
View neural-channels.lua
-- 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'
@htoyryla
htoyryla / nsrg-replace.lua
Created May 13, 2017
Varying style neural-style transfer by modifying gram matrix (v2 fantasy)
View nsrg-replace.lua
-- 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'
@htoyryla
htoyryla / nsrg.lua
Created May 13, 2017
Varying style neural-style transfer by modifying gram matrix (v1)
View nsrg.lua
-- 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'