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

Can't compress own file with pretrained model or self trained model #42

Open
gullibleretorted opened this issue May 20, 2021 · 0 comments

Comments

@gullibleretorted
Copy link

Hi there,

first of all, thanks a lot for your reimplementation on the paper!

I wanted to see how it works on compressing an image of mine. I downloaded the pretrained model and wanted to use the compress.py script as mentioned in the read.me. This didn't work, so I saw a closed issue here, that for using the compression it needed the checkpoint file. So I trained the model to get such a checkpoint file. Now I tried to run the command with compress.py again:

python compress.py -r ./checkpoints/best/my_network_epoch34.ckpt-34 -i ./pic.jpeg -o ./pic_out.jpeg

I get the following error message:

Traceback (most recent call last): File "compress.py", line 85, in <module> main() File "compress.py", line 82, in main single_compress(config_test, args) File "compress.py", line 53, in single_compress new_saver = tf.train.import_meta_graph('{}.meta'.format(args.restore_path)) File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 1453, in import_meta_graph **kwargs)[0] File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 1477, in _import_meta_graph_with_return_elements **kwargs)) File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/framework/meta_graph.py", line 810, in import_scoped_meta_graph_with_return_elements return_elements=return_elements) File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/framework/importer.py", line 405, in import_graph_def producer_op_list=producer_op_list) File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/framework/importer.py", line 505, in _import_graph_def_internal raise ValueError(str(e)) ValueError: Cannot add function '__inference_Dataset_map__parser_56' because a different function with the same name already exists.

My venv:
Package Version


absl-py 0.12.0
appnope 0.1.2
astor 0.8.1
backports-abc 0.5
backports.functools-lru-cache 1.6.4
backports.shutil-get-terminal-size 1.0.0
backports.weakref 1.0.post1
bleach 1.5.0
cachetools 3.1.1
certifi 2020.12.5
chardet 4.0.0
cycler 0.10.0
decorator 4.4.2
enum34 1.1.10
funcsigs 1.0.2
functools32 3.2.3.post2
futures 3.3.0
gast 0.2.2
google-auth 1.30.0
google-auth-oauthlib 0.4.1
google-pasta 0.2.0
grpcio 1.37.1
h5py 2.10.0
html5lib 0.9999999
idna 2.10
ipykernel 4.10.1
ipython 5.10.0
ipython-genutils 0.2.0
jupyter-client 5.3.5
jupyter-core 4.6.3
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.2
kiwisolver 1.1.0
Markdown 3.1.1
matplotlib 2.2.5
mock 3.0.5
numexpr 2.7.3
numpy 1.16.6
oauthlib 3.1.0
opt-einsum 2.3.2
pandas 0.24.2
pathlib2 2.3.5
pexpect 4.8.0
pickleshare 0.7.5
pip 20.3.4
prompt-toolkit 1.0.18
protobuf 3.17.0
ptyprocess 0.7.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
Pygments 2.5.2
pyparsing 2.4.7
python-dateutil 2.8.1
pytz 2021.1
pyzmq 19.0.2
requests 2.25.1
requests-oauthlib 1.3.0
rsa 4.5
scandir 1.10.0
scipy 1.2.2
seaborn 0.9.1
setuptools 44.1.1
simplegeneric 0.8.1
singledispatch 3.6.1
six 1.16.0
subprocess32 3.5.4
tables 3.5.2
tensorboard 1.15.0
tensorflow 1.8.0
tensorflow-cpu 1.15.0
tensorflow-cpu-estimator 1.15.1
tensorflow-estimator 2.1.0
termcolor 1.1.0
tornado 5.1.1
traitlets 4.3.3
urllib3 1.26.4
wcwidth 0.2.5
Werkzeug 1.0.1
wheel 0.36.2
wrapt 1.12.1


I also tried to just add the checkpoint file to the checkpoints folder where the pretrained model is and got the following error:

`Sampling noise...
('Real image shape:', [None, None, None, 3])
('Reconstruction shape:', [None, 512, 1024, 3])
2021-05-20 11:55:08.755659: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2021-05-20 11:55:08.790379: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7f911c318720 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-05-20 11:55:08.790421: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2021-05-20 11:55:13.008342: W tensorflow/core/graph/graph_constructor.cc:1491] Importing a graph with a lower producer version 24 into an existing graph with producer version 134. Shape inference will have run different parts of the graph with different producer versions.
2021-05-20 11:55:25.044370: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at save_restore_v2_ops.cc:184 : Not found: Key generator/encoder_image/batch_normalization/beta not found in checkpoint
Traceback (most recent call last):
File "compress.py", line 85, in
main()
File "compress.py", line 82, in main
single_compress(config_test, args)
File "compress.py", line 54, in single_compress
new_saver.restore(sess, args.restore_path)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 1306, in restore
err, "a Variable name or other graph key that is missing")
tensorflow.python.framework.errors_impl.NotFoundError: Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key generator/encoder_image/batch_normalization/beta not found in checkpoint
[[node save/RestoreV2 (defined at /Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/framework/ops.py:1748) ]]

Original stack trace for u'save/RestoreV2':
File "compress.py", line 85, in
main()
File "compress.py", line 82, in main
single_compress(config_test, args)
File "compress.py", line 34, in single_compress
saver = tf.train.Saver()
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 828, in init
self.build()
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 840, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 878, in _build
build_restore=build_restore)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 508, in _build_internal
restore_sequentially, reshape)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 328, in _AddRestoreOps
restore_sequentially)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/training/saver.py", line 575, in bulk_restore
return io_ops.restore_v2(filename_tensor, names, slices, dtypes)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/ops/gen_io_ops.py", line 1696, in restore_v2
name=name)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/framework/op_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/framework/ops.py", line 3357, in create_op
attrs, op_def, compute_device)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/framework/ops.py", line 3426, in _create_op_internal
op_def=op_def)
File "/Users/python_envs/gan/lib/python2.7/site-packages/tensorflow_core/python/framework/ops.py", line 1748, in init
self._traceback = tf_stack.extract_stack()`


Any help would be highly appreciated!! Thanks a lot in advance!

@gullibleretorted gullibleretorted changed the title Can't compress own file Can't compress own file with pretrained model or self trained model May 20, 2021
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

1 participant