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
import argparse | |
import time | |
import torch | |
import numpy as np | |
def int_list(s): | |
return [int(x) for x in s.split(',')] | |
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
# Installs 375.66 for CUDA 8 on Ubuntu 16.04 | |
wget http://us.download.nvidia.com/tesla/375.66/nvidia-diag-driver-local-repo-ubuntu1604_375.66-1_amd64.deb | |
sudo dpkg -i nvidia-diag-driver-local-repo-ubuntu1604_375.66-1_amd64.deb | |
sudo apt-get update | |
sudo apt-get --allow-unauthenticated --assume-yes install cuda-drivers | |
sudo reboot now |
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
def bilinear_sample(feats, X, Y, idx): | |
""" | |
Perform bilinear sampling on the features in feats using the sampling grid | |
given by X and Y. | |
Inputs: | |
- feats: Tensor (or Variable) holding input feature map, of shape (N, C, H, W) | |
- X, Y: Tensors (or Variables) holding x and y coordinates of the sampling | |
grids; both have shape shape (B, HH, WW). Elements in X should be in the | |
range [0, W - 1] and elements in Y should be in the range [0, H - 1]. |
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
import argparse | |
import torch | |
import torch.nn as nn | |
from torch.autograd import Variable | |
from torch.utils.data import DataLoader | |
import torchvision | |
import torchvision.transforms as T | |
from torchvision.datasets import ImageFolder |
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
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) |
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
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 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 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 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 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') |
NewerOlder