tf-perceptual-eusr icon indicating copy to clipboard operation
tf-perceptual-eusr copied to clipboard

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

Open mhassan93 opened this issue 3 years ago • 4 comments

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

  • ./LR\20210331_135726.jpg -> ./SR\20210331_135726.jpg 2021-06-28 15:53:46.774187: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 3072000000 exceeds 10% of system memory. Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\client\session.py", line 1365, in _do_call return fn(*args) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\client\session.py", line 1350, in _run_fn target_list, run_metadata) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\client\session.py", line 1443, in _call_tf_sessionrun run_metadata) 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}}]]

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 avatar Jun 28 '21 11:06 mhassan93

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()

mhassan93 avatar Jun 28 '21 11:06 mhassan93

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.

idearibosome avatar Jun 30 '21 13:06 idearibosome

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.

mhassan93 avatar Jul 01 '21 06:07 mhassan93

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.

idearibosome avatar Aug 24 '21 06:08 idearibosome