HasnainRaz / FC-DenseNet-TensorFlow

Fully Convolutional DenseNet (A.K.A 100 layer tiramisu) for semantic segmentation of images implemented in TensorFlow.
MIT License
123 stars 41 forks source link

Cant read Inputfiles #19

Closed michaelwachter closed 5 years ago

michaelwachter commented 5 years ago

I've set the default Path, in the main.py script, to my Dataset Folder:

parser.add_argument("--train_data", default="./dataset/img", help="Directory for training images")

My folder sctruture inside the project looks like this:

When i call the main.py script without arguments, i get the error: TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.

HasnainRaz commented 5 years ago

It seems your file_paths list somehow has floats instead of filepath strings. Can you share the full error message? Also, what format are your images?

michaelwachter commented 5 years ago

` (bachelor) c:\Users\MiHi\GitHub\FC-DenseNet2ClassificationNN_tensorflow\FC-DenseNet-TensorFlow>python main.py WARNING: Logging before flag parsing goes to stderr. W0902 11:21:51.432162 15556 deprecation_wrapper.py:119] From c:\Users\MiHi\GitHub\FC-DenseNet2ClassificationNN_tensorflow\FC-DenseNet-TensorFlow\utility.py:5: The name tf.read_file is deprecated. Please use tf.io.read_file instead.

Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 527, in _apply_op_helper preferred_dtype=default_dtype) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\framework\ops.py", line 1224, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\framework\ops.py", line 1018, in _TensorTensorConversionFunction (dtype.name, t.dtype.name, str(t))) ValueError: Tensor conversion requested dtype string for Tensor with dtype float32: 'Tensor("args_0:0", shape=(), dtype=float32)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 44, in main() File "main.py", line 38, in main FLAGS.batch_size, FLAGS.epochs, FLAGS.learning_rate) File "c:\Users\MiHi\GitHub\FC-DenseNet2ClassificationNN_tensorflow\FC-DenseNet-TensorFlow\model.py", line 281, in train train_image_paths, train_mask_paths, batch_size) File "c:\Users\MiHi\GitHub\FC-DenseNet2ClassificationNN_tensorflow\FC-DenseNet-TensorFlow\utility.py", line 89, in data_batch num_parallel_calls=num_threads).prefetch(30) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1776, in map self, map_func, num_parallel_calls, preserve_cardinality=False)) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 3228, in init use_legacy_function=use_legacy_function) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 2555, in init self._function = wrapper_fn._get_concrete_function_internal() File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\eager\function.py", line 1355, in _get_concrete_function_internal *args, *kwargs) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\eager\function.py", line 1349, in _get_concrete_function_internal_garbage_collected graphfunction, , _ = self._maybe_define_function(args, kwargs) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\eager\function.py", line 1652, in _maybe_define_function graph_function = self._create_graph_function(args, kwargs) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\eager\function.py", line 1545, in _create_graph_function capture_by_value=self._capture_by_value), File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\framework\func_graph.py", line 715, in func_graph_from_py_func func_outputs = python_func(func_args, *func_kwargs) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 2549, in wrapper_fn ret = _wrapper_helper(args) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 2489, in _wrapper_helper ret = func(*nested_args) File "c:\Users\MiHi\GitHub\FC-DenseNet2ClassificationNN_tensorflow\FC-DenseNet-TensorFlow\utility.py", line 5, in _parse_data_infer image_content = tf.read_file(image_paths) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 626, in read_file "ReadFile", filename=filename, name=name) File "C:\ProgramData\Anaconda3\envs\bachelor\lib\site-packages\ten`

My Images are in JPG format, i did use the JPG decoder Function from Tensorflow though.

michaelwachter commented 5 years ago

Ok, so i converted the JPG's to PNG, now it runs fine. But i get a OOM Error while running it. I'll open a new issue and close this one.

HasnainRaz commented 5 years ago

You could also change the read png function to the read jpeg function in utility.py

OOM errors are common with Tiramisu, since it's memory usage grows quadratically. You can either reduce the batch size, your image size, or the number of layers in the model to resolve them.