This file contains hidden or 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
| require 'torch' | |
| local utils = require 'utils' | |
| require 'DataLoader' | |
| local cmd = torch.CmdLine() | |
| cmd:option('-train_data_h5', 'data/vg-regions-720.h5', 'path to the h5file containing the preprocessed dataset') | |
| cmd:option('-train_data_json', 'data/vg-regions-720-dicts.json', 'path to the json file containing additional info') | |
| cmd:option('-use_split_indicator', 1) |
This file contains hidden or 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
| require 'torch' | |
| local utils = require 'utils' | |
| require 'DataLoader' | |
| local cmd = torch.CmdLine() | |
| cmd:option('-train_data_h5', 'data/vg-regions-720.h5', 'path to the h5file containing the preprocessed dataset') | |
| cmd:option('-train_data_json', 'data/vg-regions-720-dicts.json', 'path to the json file containing additional info') | |
| cmd:option('-use_split_indicator', 1) |
This file contains hidden or 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
| require 'nn' | |
| print(nn.SpatialReflectionPadding) | |
| local m = nn.SpatialReflectionPadding(2, 2, 2, 2) | |
| print(m) | |
| local x = torch.randn(2, 3, 4, 5) | |
| local y = m:forward(x) |
This file contains hidden or 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
| require 'torch' | |
| require 'nn' | |
| require 'image' | |
| local hdf5 = require 'hdf5' | |
| local cmd = torch.CmdLine() | |
| cmd:option('-image_list', '') | |
| cmd:option('-model', '') | |
| cmd:option('-layer', 30) -- Last ReLU for VGG-16 |
This file contains hidden or 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
| import argparse, os | |
| import numpy as np | |
| from scipy.misc import imread, imresize | |
| from skimage.filters import gaussian | |
| import h5py | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--train_dir', default='data/yang-91') | |
| parser.add_argument('--val_dir', default='data/set5') |
This file contains hidden or 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
| import argparse, os | |
| import numpy as np | |
| from scipy.misc import imread, imsave | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--template_dir', required=True) # Low-res images | |
| parser.add_argument('--source_dir', required=True) # Outputs from CNN | |
| parser.add_argument('--output_dir', required=True) | |
| args = parser.parse_args() |
This file contains hidden or 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
| STYLE_WEIGHT=5e2 | |
| STYLE_SCALE=1.0 | |
| th neural_style.lua \ | |
| -content_image examples/inputs/hoovertowernight.jpg \ | |
| -style_image starry_night_gigapixel.jpg \ | |
| -style_scale $STYLE_SCALE \ | |
| -print_iter 1 \ | |
| -style_weight $STYLE_WEIGHT \ | |
| -image_size 256 \ |
This file contains hidden or 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
| def index(x, axis, idxs): | |
| """ | |
| Inputs: | |
| - x: torch.Tensor with x.dim() == N | |
| - axis: Integer with 0 <= axis < N | |
| - idxs: List of integers, with 0 <= idxs[i] < x.size(axis) | |
| Returns: | |
| y: torch.Tensor satisfying | |
This file contains hidden or 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
| from __future__ import print_function | |
| import argparse | |
| import json | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--questions_file', required=True) | |
| parser.add_argument('--answers_file', required=True) | |
This file contains hidden or 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
| from __future__ import print_function | |
| import argparse | |
| import json | |
| from collections import defaultdict | |
| import numpy as np | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--questions_file', required=True) | |
| parser.add_argument('--answers_file', required=True) |