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

Test Demo KeyError: 'ClipByValue' #3

Closed
kiralpoon opened this issue Aug 9, 2018 · 2 comments
Closed

Test Demo KeyError: 'ClipByValue' #3

kiralpoon opened this issue Aug 9, 2018 · 2 comments
Assignees

Comments

@kiralpoon
Copy link
Contributor

kiralpoon commented Aug 9, 2018

I was trying to run the demo follow the instructions in:
python3.6
tensorflow 1.7.0
MacOS High Sierra version 10.13.6
it gave

python inference/image_translation_infer.py \
--model_path="/Users/kiralpoon/Git/TwinGAN/256/" \
--image_hw=256 \
--input_tensor_name="sources_ph" \
--output_tensor_name="custom_generated_t_style_source:0" \
--input_image_path="./demo/inference_input/" \
--output_image_path="./demo/inference_output/"/Users/kiralpoon/anaconda/envs/tf1.6/lib/python3.6/site-packages/absl/flags/_validators.py:359: UserWarning: Flag --model_path has a non-None default value; therefore, mark_flag_as_required will pass even if flag is not specified in the command line!
  'command line!' % flag_name)
Loading inference model
2018-08-09 13:36:14.032130: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Model directory: /Users/kiralpoon/Git/TwinGAN/256/
Metagraph file: model.ckpt-100000.meta
Checkpoint file: model.ckpt-100000
start assign saver
/Users/kiralpoon/Git/TwinGAN/256/model.ckpt-100000.meta
Traceback (most recent call last):
  File "inference/image_translation_infer.py", line 128, in <module>
    tf.app.run()
  File "/Users/kiralpoon/anaconda/envs/tf1.6/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "inference/image_translation_infer.py", line 103, in main
    inferer = ImageInferer()
  File "inference/image_translation_infer.py", line 61, in __init__
    util_io.load_model(FLAGS.model_path, input_map=input_map)
  File "/Users/kiralpoon/Git/TwinGAN/util_io.py", line 172, in load_model
    saver = tf.train.import_meta_graph(metapath)
  File "/Users/kiralpoon/anaconda/envs/tf1.6/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1909, in import_meta_graph
    **kwargs)
  File "/Users/kiralpoon/anaconda/envs/tf1.6/lib/python3.6/site-packages/tensorflow/python/framework/meta_graph.py", line 737, in import_scoped_meta_graph
    producer_op_list=producer_op_list)
  File "/Users/kiralpoon/anaconda/envs/tf1.6/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 432, in new_func
    return func(*args, **kwargs)
  File "/Users/kiralpoon/anaconda/envs/tf1.6/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 431, in import_graph_def
    _RemoveDefaultAttrs(op_dict, producer_op_list, graph_def)
  File "/Users/kiralpoon/anaconda/envs/tf1.6/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 211, in _RemoveDefaultAttrs
    op_def = op_dict[node.op]
KeyError: 'ClipByValue'

I also tried to switch to tensorflow 1.6.0 but with no luck.

Here is the ls of the 256 downloaded pre-trained model

ls   
checkpoint                            flags.txt                             graph.pbtxt                           model.ckpt-100000.data-00000-of-00001 model.ckpt-100000.index               model.ckpt-100000.meta

Impressive work! I hope I will be able to run it and contribute.

@jerryli27 jerryli27 self-assigned this Aug 10, 2018
@jerryli27
Copy link
Owner

jerryli27 commented Aug 10, 2018

Hi,
I think you need to upgrade to tensorflow version >= 1.8
The latest one is 1.10 but I haven't tested on that yet.

If you look at https://github.com/tensorflow/tensorflow/blob/r1.6/tensorflow/python/ops/clip_ops.py and
https://github.com/tensorflow/tensorflow/blob/r1.8/tensorflow/python/ops/clip_ops.py you'll see that ClipByValue is added at tf1.8

Let me know if that solves the problem!

@kiralpoon
Copy link
Contributor Author

This make perfect sense! Thank you!
After I switched to tensorflow ==1.8 it works

In both my mac and window, some how the PYTHONPATH did not registered where it ran the code in the root folder, hence will give the error that cannot import util_io, so I added 2 lines of code to fix that in the image_translation_infer.py. I will try to commit it and let you review it and hope it helps.
I have created a new virtual enviornment and created a requirement.txt based on that working environment. I will also commit a requirement.txt for python package if that can helps for other.

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

2 participants