gabrieleilertsen / hdrcnn

HDR image reconstruction from a single exposure using deep CNNs
https://computergraphics.on.liu.se/hdrcnn/
BSD 3-Clause "New" or "Revised" License
502 stars 101 forks source link

Dependencies unclear, list plz? #53

Closed xav-ie closed 5 months ago

xav-ie commented 1 year ago

After hours of toiling away to install openexr on Mac, I find that I do not have the correct tensorflow version installed because I am getting messages like:

Traceback (most recent call last):
  File "/Users/xavierruiz/Projects/hdrcnn/hdrcnn_predict.py", line 65, in <module>
    FLAGS = tf.flags.FLAGS
AttributeError: module 'tensorflow' has no attribute 'flags

:(

Please, can someone who got this working share their environment? I also found I had to install opencv-python and matplotlib, which were not mentioned.

I attempted to fix this error by just changing the offending lines ~65-70:

# Settings, using TensorFlow arguments
FLAGS = tf.compat.v1.flags.FLAGS
tf.compat.v1.flags.DEFINE_integer("width", "1024", "Reconstruction image width")
tf.compat.v1.flags.DEFINE_integer("height", "768", "Reconstruction image height")
tf.compat.v1.flags.DEFINE_string("im_dir", "data", "Path to image directory or an individual image")
tf.compat.v1.flags.DEFINE_string("out_dir", "out", "Path to output directory")
tf.compat.v1.flags.DEFINE_string("params", "hdrcnn_params.npz", "Path to trained CNN weights")
tf.compat.v1.flags.DEFINE_float("scaling", "1.0", "Pre-scaling, which is followed by clipping, in order to remove compression artifacts close to highlights")
tf.compat.v1.flags.DEFINE_float("gamma", "1.0", "Gamma/exponential curve applied before, and inverted after, prediction. This can be used to control the boost of reconstructed pixels.")

Then you get another error:

Traceback (most recent call last):
  File "/Users/xavierruiz/Projects/hdrcnn/hdrcnn_predict.py", line 108, in <module>
    x = tf.compat.v1.placeholder(tf.float32, shape=[1, sy, sx, 3])
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/tensorflow/python/ops/array_ops.py", line 3343, in placeholder
    raise RuntimeError("tf.placeholder() is not compatible with "
RuntimeError: tf.placeholder() is not compatible with eager execution.

So then I try to disable eager execution by adding tf.compat.v1.disable_eager_execution() because it was not enabled in V1 (I think?) and then I get a very cryptic error:

Traceback (most recent call last):
  File "/Users/xavierruiz/Projects/hdrcnn/hdrcnn_predict.py", line 113, in <module>
    net = network.model(x)
  File "/Users/xavierruiz/Projects/hdrcnn/network.py", line 49, in model
    net_in = tl.layers.InputLayer(x_in, name='input_layer')
  File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/tensorlayer/layers/deprecated.py", line 178, in InputLayer
    raise NonExistingLayerError("InputLayer(x, name='a') --> Input(name='a')(x)" + __log__)
tensorlayer.layers.deprecated.NonExistingLayerError: InputLayer(x, name='a') --> Input(name='a')(x)
 Hint: 1) downgrade TF and TL from version 2.x to 1.x. 2) check the documentation of TF and TL version 2.x

So, can someone please share what worked for them by running pip freeze in an environment that works and sending it here? I really wish to use this package.

gabrieleilertsen commented 1 year ago

The code uses tensorflow 1, so not directly compatible with tensorflow 2. I'm not sure if it is possible to make it work with tensorflow 2 using the tf.compat.v1 (you could try changing "import tensorflow as tf" to "import tensorflow.compat.v1 as tf"), but it seems like you encountered some problems with tensorlayer that are more difficult to solve.

Perhaps the easiest is to simply downgrade to tensorflow 1?

ghost commented 11 months ago

For that it would also require a lower version of Python. Has anyone tried this git? Does it work?

xav-ie commented 5 months ago

bankrupting this