Skip to content

Instantly share code, notes, and snippets.

@ProGamerGov
ProGamerGov / neural-channels.lua
Last active May 18, 2017 22:16 — forked from htoyryla/neural-channels.lua
Neural-style with selected channels emphasis
-- 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'
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@ProGamerGov
ProGamerGov / neural_style_seg.lua
Last active December 27, 2018 03:02
Working Multi-Region Spatial Control in Neural-Style. Also known as "masked style transfer", and "semantic/segmented style transfer".
-- Original mask related code from: https://github.com/martinbenson/deep-photo-styletransfer
-- Modified mask code by github.com/ProGamerGov
require 'torch'
require 'nn'
require 'image'
require 'optim'
require 'loadcaffe'
-- Original DeepDream code by github.com/jcjohnson
-- Simaltaneous DeepDream and style transfer modifications by github.com/ProGamerGov
-- The FC layers as content layers feature, and the label file features come from:
-- github.com/htoyryla's gist.github.com/htoyryla/806ca4d978f0528114282cd00022ad71
-- Indepdent layer weights from: https://github.com/htoyryla/neural-style/blob/master/neural_style.lua
-- Torch model and architecture support from https://github.com/szagoruyko/neural-style/tree/torch
-- A script like this one is requires for making Torch models compatible: https://gist.github.com/szagoruyko/8828e09cc4687afd324d
require 'torch'
require 'nn'
require 'image'
require 'optim'
require 'loadcaffe'
local cmd = torch.CmdLine()
-- Original DeepDream code by github.com/jcjohnson
-- Simaltaneous DeepDream and style transfer modifications by github.com/ProGamerGov
-- The FC layers as content layers feature, and the label file features come from:
-- github.com/htoyryla's gist.github.com/htoyryla/806ca4d978f0528114282cd00022ad71
-- Indepdent layer weights from: https://github.com/htoyryla/neural-style/blob/master/neural_style.lua
-- Torch model and architecture support from https://github.com/szagoruyko/neural-style/tree/torch
-- Matting laplacian code from: github.com/martinbenson/deep-photo-styletransfer/
@ProGamerGov
ProGamerGov / laplacian.py
Last active April 21, 2017 10:39
Working Laplacian Creator
# Standalone version of the Matting Laplacian code from here: https://github.com/martinbenson/deep-photo-styletransfer
# Usage: python3 laplacian.py -in_dir <directory> -lap_dir <directory> -width <value>
# Install the depdendencies with: pip3 install numpy scipy Pillow
# This script is intended for use with artistic style transfer neural networks, and Deep Photo Style Transfer.
import argparse
import glob
import os
import shutil
import multiprocessing
@ProGamerGov
ProGamerGov / cuda_utils.cu
Last active June 11, 2017 23:22
Neural-Style with the laplacian feature from deep-photo-styletransfer. See the comments for setting up and using the new feature.
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
#include "luaT.h"
#include "THC.h"
#include <stdio.h>
@ProGamerGov
ProGamerGov / neural_style_l2_dd_fc_labels_t7.lua
Last active June 11, 2017 22:33
New features include ".t7" Torch7 model support, Inception, ResNet, etc... architecture support, DeepDream, FC layers (caffemodels only) can be used as content layers and DeepDream layers, the ability to use label files, and an experimental pixel decay/L2 latent state regularizer.
-- Original DeepDream code by github.com/jcjohnson
-- Simaltaneous DeepDream and style transfer modifications by github.com/ProGamerGov
-- The FC layers as content layers feature, and the label file features come from:
-- github.com/htoyryla's gist.github.com/htoyryla/806ca4d978f0528114282cd00022ad71
-- Torch model and architecture support from https://github.com/szagoruyko/neural-style/tree/torch
require 'torch'
require 'nn'
@ProGamerGov
ProGamerGov / neural_style_criterion.lua
Created March 2, 2017 23:15
Testing a new "criterion" parameter
require 'torch'
require 'nn'
require 'image'
require 'optim'
require 'loadcaffe'
local cmd = torch.CmdLine()