Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where were the style transfer example models taken from? #49

Closed
AndreJFBico opened this issue Jul 24, 2017 · 26 comments
Closed

Where were the style transfer example models taken from? #49

AndreJFBico opened this issue Jul 24, 2017 · 26 comments

Comments

@AndreJFBico
Copy link

Hi, if possible, do you guys know from what example the q_and_w.pb and g_and_w2.pb files were taken from. Im trying to get similar style transfer models to work with bender but the list of unsupported operations varies widely.

If you trained them yourself it would be helpful to know more information about those models.

PS:i would have posted this on stack-overflow but i don't have the rep to create the bender tag.
Thanks in advance!

@bryant1410
Copy link
Member

I think those protobufs were generated from fast-style-transfer.

Just out of curiosity, which are the unsupported operations that you ran into? Also, remember that you can try implementing them yourself. It's not that hard 😅 We can provide help 👼

I don't have the enough rep to create a tag either 😞 But you can go ahead and ask without the tag. Hopefully, the community will create it some day.

@AndreJFBico
Copy link
Author

AndreJFBico commented Jul 25, 2017

Hey ok ill try it and if i run into issues ill post them, ill close this issue in the meantime, as the question has been answered.

Thanks!

@backnotprop
Copy link

@bryant1410 would you be willing to share how you generated the protobufs from fast-style-transfer?

I've created a model using the same library, but that only generates checkpoint files and no graphs

@bryant1410
Copy link
Member

I don't have them at hand now. I suggest you use https://github.com/xmartlabs/benderthon in conjunction with fast-style-transfer. If you are blocked, please tell me and maybe I can help you out.

@backnotprop
Copy link

Ok thanks, my only blocker right now is generating the pb file. Currently Im using the approach in this SO answer here

But need to see how I can generate the output node names in fast-style-transfer

@backnotprop
Copy link

I guess my next approach would be to use Benderthon, but would need to create the single checkpoint file, as I currently have the 3 (meta, index, data)

@bryant1410
Copy link
Member

I guess my next approach would be to use Benderthon, but would need to create the single checkpoint file, as I currently have the 3 (meta, index, data)

You don't need a single one, you can with 3. You just need to pass the common prefix (like "file.ckpt")

@bryant1410
Copy link
Member

And with respect to the output node name, you just need to check its name

@backnotprop
Copy link

backnotprop commented Sep 19, 2017

Do you recall what it was for fast-style-transfer? it doesnt seem to be explicitly set: https://github.com/lengstrom/fast-style-transfer/search?utf8=%E2%9C%93&q=name%3D&type=

@backnotprop
Copy link

saver = tf.train.import_meta_graph(/path/to/meta/graph)
sess = tf.Session()
saver.resore(sess, /path/to/checkpoints)
graph = sess.graph
print([node.name for node in graph.as_graph_def().node])

produces a ton of different output

@bryant1410
Copy link
Member

saver = tf.train.import_meta_graph(/path/to/meta/graph)
sess = tf.Session()
saver.resore(sess, /path/to/checkpoints)
graph = sess.graph
print([node.name for node in graph.as_graph_def().node])
produces a ton of different output

That yields every node name in the graph, not necessarily output.

@bryant1410
Copy link
Member

The output is in: https://github.com/lengstrom/fast-style-transfer/blob/master/src/transform.py#L18

It's automatically named by TF, probably by the Add operation, something like "AddN" (where N is the number of the last unnamed addition operation, 0-based).

@backnotprop
Copy link

backnotprop commented Sep 19, 2017

ah thanks, looks like I was able to find it in the evaluate function and the restore of the graph:
Tensor("add_37:0", shape=(1, 720, 884, 3), dtype=float32, device=/device:GPU:0)

now when running benderthon tf-freeze checkpoints/fns.ckpt tiger.pb add_37:0 I get error:
AttributeError: 'module' object has no attribute 'freeze_graph_with_def_protos'

@bryant1410
Copy link
Member

can you pass a complete stacktrace?

@bryant1410
Copy link
Member

what version of tf are you using?

@backnotprop
Copy link

version 1.1.0

Traceback (most recent call last):
  File "/home/ubuntu/anaconda2/bin/benderthon", line 11, in <module>
    sys.exit(main())
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/benderthon/cmdline.py", line 39, in main
    tf_freeze.freeze_from_checkpoint(args.input_checkpoint, args.output_path, args.output_node_names.split(','))
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/benderthon/tf_freeze.py", line 25, in freeze_from_checkpoint
    freeze_graph.freeze_graph_with_def_protos(input_graph_def=sess.graph_def, input_saver_def=None,
AttributeError: 'module' object has no attribute 'freeze_graph_with_def_protos'

@backnotprop
Copy link

backnotprop commented Sep 19, 2017

sorry just saw the 1.2 req, really appreciate your help thus far

@backnotprop
Copy link

backnotprop commented Sep 19, 2017

Thanks again. I was able to get the pb file.

So far in my iOS style-transfer I can only get g_and_w2.pb (from Bender example) to work. Seeing some nil errors with my transferred pb's. Will update when I find out more. My file is 5mb larger that g_and_w.

@backnotprop
Copy link

ah the nil error was my b.

But the newest error is one I believe I saw in another issue:
assertion failed: Add works for two layers:

@j005u
Copy link

j005u commented Oct 26, 2017

Having the same issue
assertion failed: Add works for two layers:
Here's my protobuf: https://www.dropbox.com/s/k4i8ccn0ak0kac9/c.pb?dl=0
Generated with benderthon from a checkpoint trained with https://github.com/lengstrom/fast-style-transfer

This is NOT the same as #50.

@bryant1410
Copy link
Member

@j005u why is not the same issue?

@j005u
Copy link

j005u commented Oct 26, 2017

Because the error is Add works for two layers rather than Add works for two layers of the same size

More specifically incoming.count = 0

@j005u
Copy link

j005u commented Oct 26, 2017

@bryant1410 Uploaded the original checkpoint to https://www.dropbox.com/s/h2ck8xf8h576kvx/check.ckpt.zip?dl=0

The output layer is add_37.

Also of note (although I'm guessing it doesn't matter?), the model was originally trained for cloud GPUs at 1980x1080 and with much older Tensorflow. Predicts fine on 1.3.0 though.

Maybe that helps.

@j005u
Copy link

j005u commented Oct 31, 2017

@bryant1410 Any tips on debugging this?

I've tried old version of benderthon and Tensorflow. I also tried quantising the graph, but that just results in a conv2d layer having 0 inputs. Could the trained input size be an issue, should I try to retrain at 256x256? Is there a tool I could use to visually explore the .pb and try to figure out where things break down? As far as I can tell the very first Add layer has 0 inputs.

@mdramos Did you ever figure this out by any chance?

As far as I can tell there's no way to use fast-style-transfer with Bender currently. There's even an open branch on this https://github.com/xmartlabs/Bender/commits/tf-converted-fst-add-layer-0-inputs

@bryant1410
Copy link
Member

Sorry for the delay. Quantizing the graph won't work, as Bender currently doesn't support int8. The input size is not a problem usually. To explore the .pb you can use TensorBoard.

We still have to fix the bug of the branch you cited

@backnotprop
Copy link

@j005u sorry for the late reply. I did this using google's converter and making some adjustments/additions:

https://medium.com/@rambossa/diy-prisma-fast-style-transfer-app-with-coreml-and-tensorflow-817c3b90dacd

https://github.com/mdramos/fast-style-transfer-coreml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants