Git Product home page Git Product logo

Comments (6)

morgangiraud avatar morgangiraud commented on July 30, 2024

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?

from neural_style.

luweishuang avatar luweishuang commented on July 30, 2024
  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

from neural_style.

morgangiraud avatar morgangiraud commented on July 30, 2024

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.

from neural_style.

luweishuang avatar luweishuang commented on July 30, 2024

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

from neural_style.

morgangiraud avatar morgangiraud commented on July 30, 2024

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 👍🏻

from neural_style.

DecentGradient avatar DecentGradient commented on July 30, 2024

I suspect that is the case as well

from neural_style.

Related Issues (2)

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.