taki0112 / MUNIT-Tensorflow

Simple Tensorflow implementation of "Multimodal Unsupervised Image-to-Image Translation" (ECCV 2018)
MIT License
300 stars 90 forks source link

A little problem about dataset path #8

Closed yuangan closed 6 years ago

yuangan commented 6 years ago

I'm a newcomer to Machine Learning. It's my pleasure to run your code. But the readme has no description about your datasets, so after I run your code, I meet this problem.

Traceback (most recent call last):
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
    preferred_dtype=default_dtype)
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/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 "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 774, in _TensorTensorConversionFunction
    (dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype string for Tensor with dtype float32: 'Tensor("arg0:0", shape=(), dtype=float32)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 112, in <module>
    main()
  File "main.py", line 93, in main
    gan.build_model()
  File "/media/gy/E/work/2018paper/2D_style_transfer/code/MUNIT/MUNIT.py", line 243, in build_model
    trainA = trainA.prefetch(self.batch_size).shuffle(self.dataset_num).map(Image_Data_Class.image_processing, num_parallel_calls=8).apply(batch_and_drop_remainder(self.batch_size)).repeat()
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 714, in map
    return ParallelMapDataset(self, map_func, num_parallel_calls)
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1410, in __init__
    super(ParallelMapDataset, self).__init__(input_dataset, map_func)
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1385, in __init__
    self._map_func.add_to_graph(ops.get_default_graph())
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 486, in add_to_graph
    self._create_definition_if_needed()
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 321, in _create_definition_if_needed
    self._create_definition_if_needed_impl()
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 338, in _create_definition_if_needed_impl
    outputs = self._func(*inputs)
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1360, in tf_map_func
    ret = map_func(nested_args)
  File "/media/gy/E/work/2018paper/2D_style_transfer/code/MUNIT/utils.py", line 19, in image_processing
    x = tf.read_file(filename)
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/ops/gen_io_ops.py", line 376, in read_file
    "ReadFile", filename=filename, name=name)
  File "/media/gy/E/anaconda2/envs/tensorflow1.4/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 533, in _apply_op_helper
    (prefix, dtypes.as_dtype(input_arg.type).name))
TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.

I'm also a newcomer to tensorflow and there is no tip in your readme about this problem. I changed tensorflow version from 1.7 to 1.4, but it didn't work. At last, I found this cod in MUNIT.py

self.trainA_dataset = glob('./dataset/{}/*.*'.format(self.dataset_name + '/trainA'))
self.trainB_dataset = glob('./dataset/{}/*.*'.format(self.dataset_name + '/trainB'))

So I created a file named after 'dataset', and put data files in this file. Then it worked. If somebody meets the same problem, this method may save your time. But if there are some tips in readme about dataset path, it could be better. By the way, in the original version the file name is 'datasets', so it doesn't work if just copy dataset from the original work. Thank you for your exciting work. Have a good day!

MichinariNukazawa commented 6 years ago

I also met the same problem. The Machine Learning code appears to be a culture omitting error checking. However, I made a simple check on my fork. https://github.com/MichinariNukazawa/MUNIT-Tensorflow/commit/a84975a6aae2b2c40d2413d6b5b2e8e29175d0d9 I am thinking whether to pull request.