fidler-lab / polyrnn-pp

Inference Code for Polygon-RNN++ (CVPR 2018)
GNU General Public License v3.0
736 stars 161 forks source link

Visualizing the polygon model #15

Closed AidanRocke closed 6 years ago

AidanRocke commented 6 years ago

I had some trouble attempting to visualise the 'poly' model using tensorboard although I can visualise the evalnet and the ggnn model. It still isn't clear to me that I made an error so I'll list the steps I followed before trying to load the polygon model meta graph.

  1. On my Macbook air(OS Sierra), I setup a virtual environment using Conda as follows:

conda create -n tf13 python=3.6 anaconda

  1. I then proceeded to install tensorflow version 1.3 as follows:

pip install --ignore-installed --upgrade tensorflow==1.3

  1. Once in the environment, I cloned your repository and tried to install requirements. Everything installed without a problem except for tensorflow-gpu==1.3:

Collecting tensorflow-gpu==1.3.0 Could not find a version that satisfies the requirement tensorflow-gpu==1.3.0 (from versions: 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0) No matching distribution found for tensorflow-gpu==1.3.0

  1. Now, I proceed to launch iPython and execute the following:
import tensorflow as tf

g = tf.Graph() 

model_path = './polyrnn-pp/models/poly/polygonplusplus.ckpt.meta'

with g.as_default() as g: 
    tf.train.import_meta_graph(model_path) 

this returns the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-9aa8b0584d3e> in <module>()
     10 ## restoring checkpoints:
     11 tf.reset_default_graph()
---> 12 imported_meta = tf.train.import_meta_graph(model_path)

~/anaconda/envs/tf13/lib/python3.6/site-packages/tensorflow/python/training/saver.py in import_meta_graph(meta_graph_or_file, clear_devices, import_scope, **kwargs)
   1696                                       clear_devices=clear_devices,
   1697                                       import_scope=import_scope,
-> 1698                                       **kwargs)
   1699   if meta_graph_def.HasField("saver_def"):
   1700     return Saver(saver_def=meta_graph_def.saver_def, name=import_scope)

~/anaconda/envs/tf13/lib/python3.6/site-packages/tensorflow/python/framework/meta_graph.py in import_scoped_meta_graph(meta_graph_or_file, clear_devices, graph, import_scope, input_map, unbound_inputs_col_name, restore_collections_predicate)
    654     importer.import_graph_def(
    655         input_graph_def, name=(import_scope or ""), input_map=input_map,
--> 656         producer_op_list=producer_op_list)
    657 
    658     scope_to_prepend_to_names = "/".join(

~/anaconda/envs/tf13/lib/python3.6/site-packages/tensorflow/python/framework/importer.py in import_graph_def(graph_def, input_map, return_elements, name, op_dict, producer_op_list)
    283       # Set any default attr values that aren't present.
    284       if node.op not in op_dict:
--> 285         raise ValueError('No op named %s in defined operations.' % node.op)
    286       op_def = op_dict[node.op]
    287       for attr_def in op_def.attr:

ValueError: No op named GatherTree in defined operations.
  1. When I do the exact same thing for the evalnet model or the ggnn model, I don't encounter this problem.

Update: I checked issues 2 and 3 and can confirm that besides using TF version 1.3.0 I'm also using CUDA version 8.0:

(tf13) Aidans-MacBook-Air:models aidanrockea$ (tf13) Aidans-MacBook-Air:models aidanrockea$ cat /usr/local/cuda/version.txt CUDA Version 8.0.62

amlankar commented 6 years ago

Checkout: https://github.com/tensorflow/tensorflow/issues/12927

@davidjesusacu, any ideas?

Max-Fu commented 6 years ago

Hi AidanRocke,

Is it possible for you to redo the experiment in python 2.7.x environment? It worked for me when running python 2.7.x in a virtualenv (w and w/o gpu). [Though most likely this problem might not due to the difference in python versions]

Best, Max

davidjesusacu commented 6 years ago

yeah, it seems you are using python3.6. try using python 2.7 and tf1.3 it should work

AidanRocke commented 6 years ago

@amlankar @Max-Fu @davidjesusacu

I tried the following:

  1. Used Python 2.7 and TF 1.3 as recommended, which returned the same error.
  2. A friend then suggested that I modify my graph loading script as follows:
from tensorflow.contrib.seq2seq.python.ops import beam_search_ops
import tensorflow as tf

g = tf.Graph() 

model_path = './polyrnn-pp/models/poly/polygonplusplus.ckpt.meta'

with g.as_default() as g: 
    tf.train.import_meta_graph(model_path) 

beam_search_ops should take care of the GatherTree operation but I now have the following error:

ValueError: NodeDef expected inputs 'int32, int32, int32, int32' do not match 3 inputs specified; Op<name=GatherTree; signature=step_ids:T, parent_ids:T, max_sequence_lengths:int32, end_token:T -> beams:T; attr=T:type,allowed=[DT_INT32]>; NodeDef: GatherTree = GatherTree[T=DT_INT32, _output_shapes=[[?,1,8]], _device="/device:GPU:0"](TensorArrayStack_1/TensorArrayGatherV3, TensorArrayStack_2/TensorArrayGatherV3, Select_69)

  1. I think this might be related to the problem of installing the requirement 'tensorflow-gpu==1.3.0':
  Could not find a version that satisfies the requirement tensorflow-gpu==1.3.0 (from -r requirements.txt (line 26)) (from versions: 0.12.0rc1, 0.12.0, 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0)
No matching distribution found for tensorflow-gpu==1.3.0 (from -r requirements.txt (line 26))
amlankar commented 6 years ago

I just made a new virtualenv and ran pip install -r requirements.txt and got no issue for tensorflow-gpu==1.3.0. Here's the final output that I got:

screenshot

AidanRocke commented 6 years ago

So the problem appears to be that I'm using a Mac: https://stackoverflow.com/questions/49728797/pip-install-package-version-failed-in-installing-tensorflow-gpu-in-mac-which

amlankar commented 6 years ago

Makes sense! Totally overlooked that, thanks for letting us know!