idearibosome / tf-perceptual-eusr

A TensorFlow-based image super-resolution model considering both quantitative and perceptual quality
Apache License 2.0
45 stars 10 forks source link

You must feed a value for placeholder tensor 'model/sr_input_scale' with dtype float #6

Open mhassan93 opened 3 years ago

mhassan93 commented 3 years ago

I am unable to run test.py successfully. I keep running into this error which I have not been able to figure out. Any help in this regard is highly appreciated. The error is as follows.

Error

Found 356 images

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "test.py", line 83, in main() File "test.py", line 77, in main sess.run([write_op], feed_dict={model_input_path:input_path, model_output_path:output_path}) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\client\session.py", line 956, in run run_metadata_ptr) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\client\session.py", line 1180, in _run feed_dict_tensor, options, run_metadata) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\client\session.py", line 1359, in _do_run run_metadata) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\client\session.py", line 1384, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'model/sr_input_scale' with dtype float [[node model/sr_input_scale (defined at C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\ops.py:1748) ]]

mhassan93 commented 3 years ago

This might also help

Original stack trace for 'model/sr_input_scale': File "test.py", line 80, in main() File "test.py", line 40, in main model_output = tf.compat.v1.import_graph_def(model_graph_def, name='model', input_map={'sr_input:0': image}, return_elements=['sr_output:0'])[0] File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 507, in new_func return func(*args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\importer.py", line 405, in import_graph_def producer_op_list=producer_op_list) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\importer.py", line 517, in _import_graph_def_internal _ProcessNewOps(graph) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\importer.py", line 243, in _ProcessNewOps for new_op in graph._add_new_tf_operations(compute_devices=False): # pylint: disable=protected-access File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3561, in _add_new_tf_operations for c_op in c_api_util.new_tf_operations(self) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3561, in for c_op in c_api_util.new_tf_operations(self) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3451, in _create_op_from_tf_operation ret = Operation(c_op, self) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1748, in init self._traceback = tf_stack.extract_stack()

idearibosome commented 3 years ago

Oops, sorry for the error. Can you check whether the testing works well when you change this line of the test.py?:

https://github.com/idearibosome/tf-perceptual-eusr/blob/master/test/test.py#L34

from

model_output = tf.import_graph_def(model_graph_def, name='model', input_map={'sr_input:0': image}, return_elements=['sr_output:0'])[0]

to

model_output = tf.import_graph_def(model_graph_def, name='model', input_map={'sr_input:0': image, 'sr_input_scale:0': 4}, return_elements=['sr_output:0'])[0]

I am currently not available to test it on my side, but I will try to figure it out in a few days.

mhassan93 commented 3 years ago

Thanks for the response. The code does run without an error now but it terminates without writing any images to the target folder. The final print statement also doesn't get executed.

idearibosome commented 3 years ago

Sorry for the late response. The main problem of the test code is the lack of providing upscaling factor, which is defined as sr_input_scale:0 in the trained model.

I've updated test.py (via this commit) to support both our pretrained models and models trained via our code. With the new testing code, the frozen graph should be loaded successfully.