Skip to content

Instantly share code, notes, and snippets.

import os
import copy
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
from PIL import Image
from CaffeLoader import loadCaffemodel, ModelParallel
#!/bin/bash
fileid="1qWjJd-mVNxvHhzc9XsU6LjC0pQXIwW4t"
filename="models/VGG16-Stylized-ImageNet.pth"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}
fileid="1EU-F9ugeIeTO9ay4PinzsBXgEuCYBu0Z"
filename="models/VGG16_SOD_finetune.pth"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}
@ProGamerGov
ProGamerGov / convert_model.py
Last active November 17, 2019 18:18
Make a model's weight and bias names be compatible with neural-style-pt
import torch
from collections import OrderedDict
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-model_file", type=str, default='')
parser.add_argument("-output_name", type=str, default='')
params = parser.parse_args()
@ProGamerGov
ProGamerGov / notebook.ipynb
Last active November 16, 2019 02:06
neural-style-pt
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import copy
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
from PIL import Image
from CaffeLoader import loadCaffemodel, ModelParallel
import os
import copy
import time
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
from PIL import Image
from CaffeLoader import loadCaffemodel, ModelParallel
import os
import copy
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
from PIL import Image
from CaffeLoader import loadCaffemodel, ModelParallel
import torch
import torch.nn as nn
class VGG(nn.Module):
def __init__(self, features, num_classes=1000):
super(VGG, self).__init__()
self.features = features
self.classifier = nn.Sequential(
nn.Linear(512 * 7 * 7, 4096),
# Inspired by: https://github.com/torch/nn/blob/master/GPU.lua
# And: https://github.com/jcjohnson/neural-style/blob/master/neural_style.lua#L360
# As seen in: https://github.com/ProGamerGov/neural-style-pt
import torch
import torch.nn as nn
class ModelParallel(nn.Module):
r"""Splits a sequential network across multiple devices.

Multiscale Resolution Scripts

Setup

First download the linear-color-transfer.py, and lum-transfer.py scripts from Neural-Tools:

wget -c https://raw.githubusercontent.com/ProGamerGov/Neural-Tools/master/linear-color-transfer.py

wget -c https://raw.githubusercontent.com/ProGamerGov/Neural-Tools/master/lum-transfer.py