Giter VIP home page Giter VIP logo

fast-neural-style's Introduction

I like to build.

fast-neural-style's People

Contributors

abhiskk avatar jingweiz avatar thibaultserti avatar uditsaxena avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fast-neural-style's Issues

train doesn't run: ValueError: not enough values to unpack (expected 3, got 2)

Hello. train doesn't run:

danusya@werewolf:~/fast-neural-style$ python3 neural_style/neural_style.py train --dataset ~/dataset/ --style-image ~/Caleido/Color_Kaleidoscope_2017-6-24_15141.png  --vgg-model-dir caleido_vgg --save-model-dir caleido_model --epochs 2 --cuda 0
/usr/local/lib/python3.5/dist-packages/torchvision/transforms/transforms.py:156: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
  "please use transforms.Resize instead.")
Traceback (most recent call last):
  File "neural_style/neural_style.py", line 210, in <module>
    main()
  File "neural_style/neural_style.py", line 204, in main
    train(args)
  File "neural_style/neural_style.py", line 50, in train
    style = utils.preprocess_batch(style)
  File "/home/danusya/fast-neural-style/neural_style/utils.py", line 59, in preprocess_batch
    (r, g, b) = torch.chunk(batch, 3)
ValueError: not enough values to unpack (expected 3, got 2)

How to set output_image_size when Eval

Hi
1、Can you explain what's different of the image_size of "content and style" when Train and Eval?
2、How to set output_image_size when Eval? (if your default setting is 1080,can you show me where you set in your code?)
3、Really thanks for your work

Runtime error while trying out the toy example

I am getting a runtime error w.r.t tensor size while trying out the toy example.

RuntimeError: The expanded size of the tensor (1080) must match the existing size (32) at non-singleton dimension 2. at /opt/conda/conda-bld/pytorch_1502001039157/work/torch/lib/TH/generic/THTensor.c:308

I am using Python 2.7 and used conda install pytorch torchvision -c soumith to install pytorch

Stack trace

File "~/envs/py27/lib/python2.7/site-packages/torch/nn/modules/module.py", line 224, in __call__ result = self.forward(*input, **kwargs) File "~/fast-neural-style/neural_style/transformer_net.py", line 131, in forward mean = torch.mean(t, 2).unsqueeze(2).expand_as(x) File "~/envs/py27/lib/python2.7/site-packages/torch/autograd/variable.py", line 725, in expand_as return Expand.apply(self, (tensor.size(),)) File "~/envs/py27/lib/python2.7/site-packages/torch/autograd/_functions/tensor.py", line 111, in forward result = i.expand(*new_size)

Could you upload vgg16.weight file?

Hi,

I'm trying to train new styles images on Windows (anaconda, pytorch 0.3).
Using vgg.t7 file gives me the following error messages:

... ...
File "c:\Anaconda3\envs\py36torch\lib\site-packages\torch\utils\serialization\read_lua_file.py", line 572, in read_table
v = self.read()
File "c:\Anaconda3\envs\py36torch\lib\site-packages\torch\utils\serialization\read_lua_file.py", line 598, in read
"corrupted.".format(typeidx))
torch.utils.serialization.read_lua_file.T7ReaderException: unknown type id 1056626884. The file may be corrupted.

I assume this is due to linux/windows compatibility and would like to try with vgg16.weight file.

Thank you for your code.

some question in utils.py

def tensor_save_rgbimage(tensor, filename, cuda=False):
    if cuda:
        img = tensor.clone().cpu().clamp(0, 255).numpy()
    else:
        img = tensor.clone().clamp(0, 255).numpy()
    img = img.transpose(1, 2, 0).astype('uint8')
    img = Image.fromarray(img)
    img.save(filename)


def tensor_save_bgrimage(tensor, filename, cuda=False):
    (b, g, r) = torch.chunk(tensor, 3)
    tensor = torch.cat((r, g, b))
    tensor_save_rgbimage(tensor, filename, cuda)

it seems like if you use function tensor_save_bgrimage to save a tensor, it will first transform from BGR to RGB and then transform from RGB to GBR in the function tensor_save_rgbimage?

difference with jcjohnson

Hi, I found there are two differences with jcjohnson's code

  1. There is no Tanh after the output conv layer. But in the paper, section 3.1, it said there is a tanh layer after the output conv layer.
  2. In the jcjohnson's code, the style image is also scaled to the content image size (256). But here the style image is directly taken into vgg16 without resizing.

Why and what are the influences on the result?

download_styling_models.sh error

When I run download_styling_models.sh, it gets error: failed: Connection refused. I couldn't download the pretrained model from the website. Any ideas? Thanks!

Python error: <stdin> is a directory, cannot continue

DOVAN$ python neural_style/neural_style.py eval --content-image </Users/DOVAN/Desktop/WechatIMG128.jpeg> --model </Users/DOVAN/deeprely/fast-neural-style/saved-models/starry-night.pth> --output-image </Users/DOVAN/Desktop/test> --cuda 0
Python error: is a directory, cannot continue

Time for training a new style

Hi,
I am using p2.xlarge in AWS (NVIDIA K80 GPU, 61GB RAM , 128GB Space). To check it out I was using COCO's val2017(5K images). It downloaded the vgg-model file and it has been blank for a very long while.
0.How much time does it take to get trained for 5000 images?
1.Also when I am trying to kill the python process with "kill -9 PID", it is not getting killed, is it because of the multi threading ? How do I end the training process in between ?

--> I am able to run 'eval' option using cuda 1 and it takes about 1-2 seconds to generate output images. So I am assuming all the package installations are fine on my side.

Please help me resolve the issues.

About adding Tanh() at the end of the model

Hi, when adding Tanh() at the end of the transformer model, I got error during the training.
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation
Is there a way to fix this problem? Thanks!

content loss calculation is wrong?

Hi, I found the vgg16 loss network returns [relu1_2, relu2_2, relu3_3, relu4_3], and in your neural_style.py,

y = transformer(x)
features_y = vgg(y)
f_xc_c = Variable(features_xc[1].data, requires_grad=False)
content_loss = args.content_weight * mse_loss(features_y[1], f_xc_c)

the features_y is a list of loss corresponding to [relu1_2, relu2_2, relu3_3, relu4_3], the index for relu1_2, relu2_2, relu3_3 and relu4_3 is 0, 1, 2, and 3, right? In the paper, it used relu3_3 as content loss, so, here should it be the following?
f_xc_c = Variable(features_xc[2].data, requires_grad=False) content_loss = args.content_weight * mse_loss(features_y[2], f_xc_c)
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.