marcbelmont / gan-image-similarity

InfoGAN inspired neural network trained on zap50k images (using Tensorflow + tf-slim). Intermediate layers of the discriminator network are used to do image similarity.
GNU General Public License v3.0
116 stars 14 forks source link

zip object has no attribute pop in main.py #3

Closed 0xMH closed 6 years ago

0xMH commented 6 years ago

I get this issue when starting main.py

[root@MLmodel gan-image-similarity]# python3 main.py --logdir=logs/exp1 --batch_size=128 --file_pattern="ut-zap50k-images/*/*/*/*.jpg"
2018-01-21 20:24:02.777606: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
Traceback (most recent call last):
  File "main.py", line 378, in <module>
    tf.app.run()
  File "/usr/lib/python3.4/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 374, in main
    gan(dataset, sess)
  File "main.py", line 154, in gan
    g_model = generator(z, latent_c)
  File "main.py", line 68, in generator
    size = sizes.pop(0)
AttributeError: 'zip' object has no attribute 'pop'
marcbelmont commented 6 years ago

It's because, it's a Python2 code. You can do: sizes = list(sizes) to make it compatible.

Feel free to send a pull request with fixes.

0xMH commented 6 years ago

I got this even with python2

2018-01-22 17:40:34.125294: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
Traceback (most recent call last):
  File "main.py", line 379, in <module>
    tf.app.run()
  File "/usr/lib/python3.4/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 375, in main
    gan(dataset, sess)
  File "main.py", line 155, in gan
    g_model = generator(z, latent_c)
  File "main.py", line 70, in generator
    net = tf.concat(1, [z, latent_c])
  File "/usr/lib/python3.4/site-packages/tensorflow/python/ops/array_ops.py", line 1096, in concat
    dtype=dtypes.int32).get_shape().assert_is_compatible_with(
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 836, in convert_to_tensor
    as_ref=False)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 926, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/constant_op.py", line 229, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/constant_op.py", line 208, in constant
    value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/tensor_util.py", line 383, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/tensor_util.py", line 303, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead
marcbelmont commented 6 years ago

You may be using a recent version of Tensorflow that is not compatible with this code. Can you do pip freeze and paste the output?

0xMH commented 6 years ago
Babel==0.9.6
backports.ssl-match-hostname==3.4.0.2
backports.weakref==1.0.post1
bleach==1.5.0
chardet==2.2.1
cloud-init==0.7.9
configobj==4.7.2
decorator==3.4.0
enum34==1.1.6
funcsigs==1.0.2
futures==3.2.0
html5lib==0.9999999
iniparse==0.4
IPy==0.75
Jinja2==2.7.2
jsonpatch==1.2
jsonpointer==1.9
kitchen==1.1.1
Markdown==2.6.11
MarkupSafe==0.11
mock==2.0.0
numpy==1.14.0
pbr==3.1.1
perf==0.1
policycoreutils-default-encoding==0.1
prettytable==0.7.2
protobuf==3.5.1
pycurl==7.19.0
pygobject==3.22.0
pygpgme==0.3
pyliblzma==0.5.3
pyserial==2.6
python-linux-procfs==0.4.9
pyudev==0.15
pyxattr==0.5.1
PyYAML==3.10
requests==2.6.0
schedutils==0.4
scipy==1.0.0
seobject==0.1
sepolicy==1.1
six==1.11.0
tensorflow==1.4.1
tensorflow-tensorboard==0.4.0
urlgrabber==3.10
urllib3==1.10.2
Werkzeug==0.14.1

[root@MLmodel gan-image-similarity]# pip install tensorflow==0.11.0rc0
Collecting tensorflow==0.11.0rc0
  Could not find a version that satisfies the requirement tensorflow==0.11.0rc0 (from versions: 0.12.0rc0, 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, 1.2.0rc0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.4.1, 1.5.0rc0, 1.5.0rc1)
No matching distribution found for tensorflow==0.11.0rc0
marcbelmont commented 6 years ago

Maybe it will work with 0.12. An alternative is to use this fork https://github.com/lsheiba/gan-image-similarity it is using TF 1.2