confused about the full structure
I am a newer to keras and tensorflow. I just very confused about your full project's structure. At the fourth step, pretrain_model.py , what I found it has done is to fit training imags to training images, using this to initialize model's parameter? And the fifth step, I do some training about '/paintings/edvard_munch-the_scream.jpg', why I get some like frozen effect at the end other than the_scream's effect.

where is the wrong with this project
Hi, First, make sure you pulled the very last version of the project.
This project has pretty complicated structure because i've left all the work i made to facilitate my iteration on different models.
I don't really know about the "frozen effect" but this looks like "RGB <-> BGR" problem. Have you changed something to the code?
you are right, it is the problem about "RGB <-> BGR" and I have solved this problem.
I got another question about ConvolutionTranspose2D.py in model's directory. For the using of "tf.nn.conv2d_transpose", exactly the using of tf.pack to outshape,
it leads to the input image size must be the same as traing dataset when doing forward only. For example, if I used an image of 640_480 to do style transforming, but 512_512 for training, it will send errors like "InvalidArgumentError: Conv2DCustomBackpropInput: Size of out_backprop doesn't match computed: actual = 188, computed = 250". Is there any method to solve this problem or it just can process image size equal to training dataSet
Since the models are fully convolutionnal, you should be able to train and predict on different image sizes: Also the input_shape for prediction is built dynamically from the image_size. Make sure the input_shape is well defined.
Also, i've never tested with rectangular shapes (non squared), there could be a bug there. Check with a squared image to see if you still have the problem.
Thanks for your reply. perphase my statement is not very ckearly. I used "export_keras_model.py" to convert tensorflow's chkp and meta model files to pb format, and do forward using the pb format's model file. Just like you do in mobile_app directory. some code as follows:
def create_graph(pbModelPath): with tf.gfile.FastGFile(pbModelPath, 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) _ = tf.import_graph_def(graph_def, name='')
def forward_test(imagePath, pbModelPath,imgOutPath): img_src = Image.open(imagePath).convert('RGB') img = np.asarray(img_src, dtype=np.float32) batch = img.reshape((1,) + img.shape)
device_ = '/cpu:0'
with tf.device(device_):
create_graph(pbModelPath)
with tf.Session() as sess:
out_tensor = sess.graph.get_tensor_by_name("mul:0") # "add_35" could handle any input image size, "mul" can't
in_tensor = sess.graph.get_tensor_by_name("input_node:0")
outputs = sess.run(out_tensor, feed_dict={in_tensor:batch})
print outputs.shape
outputs = outputs.reshape((outputs.shape[1:]))
imgOut = Image.fromarray(np.uint8(outputs))
imgOut.save(imgOutPath)
when I set "out_tensor = sess.graph.get_tensor_by_name("add_35:0")", it can handle any input image size. but when i set it to "out_tensor = sess.graph.get_tensor_by_name("mul:0")", which should be the correct output tensor, it strictly need input image size == training using image size. I almostly sure the problem is th.nn.conv2d_transpose 's outshape, could you give some solutions
Hum, maybe something changed in keras or tensorflow which my layer implementation of conv2d_transpose doesn't handle anymore.
I'm sorry i won't be able to dig on this issue but if you found out what is happening, i'll be glad to merge a PR on your issue 👍🏻
I suspect that is the case as well