diggerdu / Vincent

the tensorflow implementation of adain:arbitrary image style transfer
2 stars 0 forks source link

Training the network #1

Closed AakashKumarNain closed 7 years ago

AakashKumarNain commented 7 years ago

As per your code in the beta directory, we need decoder.npy, to train the model, but you haven't described how you generated it. Did you initialized it randomly ? Here is a snippet from your code:

class vincent:
    def __init__(self, r=0., lr=1e-4, vgg19_npy_path=None):
        self.decoder_data_dict = np.load('decoder.npy', encoding='latin1').item()
        print("npy file loaded")
        self.r = r
        self.lr = lr

Also, I changed the main.py in the following way:

import numpy as np
import tensorflow as tf
from vincent import vincent
import batch_gen

V = vincent(vgg19_npy_path='vgg19.npy')
# content_holder = tf.placeholder(tf.float32, shape=[8, 512, 512, 3])
# style_holder = tf.placeholder(tf.float32, shape=[8, 512, 512, 3])
content_holder = tf.placeholder(tf.float32, shape=[1, 224, 224, 3])
style_holder = tf.placeholder(tf.float32, shape=[1, 224, 224, 3])
V.build(content_holder, style_holder)

init = tf.global_variables_initializer()

with tf.Session as sess:
    sess.run(init)
    for i in range(20):
        for (content_input, style_input) in batch_gen.load_images_and_styles(batch_pair_size=1):
            sess.run(feed_dict ={content_holder : content_input, style_holder: style_input})

Can you please elaborate what am I doing wrong here ?

diggerdu commented 7 years ago

decoder.npy is export from t7 file I use a module called torchfile https://github.com/xunhuang1995/AdaIN-style

AakashKumarNain commented 7 years ago

Okay. Thanks for the info. Few more questions :

  1. With torchfile, I can load the t7 object but there is no documentation on how to convert it into .npy.
  2. As you said in an issue that the decoder is trainable, then why did you use the decoder from the original code? Why didn't you train it from scratch?
  3. What were the values you used for hyperparameters, especially value for l2, coeff of style_loss and lr?
diggerdu commented 7 years ago

1 I will upload the decoder.npy

2 Becasuse I can't train a model which can give reasonable output.

diggerdu commented 7 years ago

I would be happy if you are willing to continue this work.

AakashKumarNain commented 7 years ago

Yeah, I am going to continue it but before that can you elaborate your second statement Becasuse I can't train a model which can give reasonable output.

diggerdu commented 7 years ago

I have tried to train a model in little dataset(8 image and 8 style) but the loss didn't come down and the output is white noise. I downloaded the data which the original author used, but my tutor push me in my paper, so i can't continue in this month. The npy file This file is a python dict, I merged the vgg19 and decoder in it.

AakashKumarNain commented 7 years ago

Okay. Thanks for the .npy file. I will share the results once I am done with it.