本文主要是介绍跑MUNIT遇到的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
MUNIT: Multimodal UNsupervised Image-to-image Translation
这是NVIDIA和Cornell大学合作的一篇论文(论文地址在标题里),网络框架和cycleGan类似,不同的是将输入Domain编码为Style和Content,如下图所示:
结果就贴一张:
下面是跑MUNIT-tensorflow出现的问题:
```
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.
```
把tensorflow从1.7换到1.4也不起作用,后来发现是路径写错了。然后在 MUNIT.py中发现这段代码:
```
self.trainA_dataset = glob('./dataset/{}/*.*'.format(self.dataset_name + '/trainA'))
self.trainB_dataset = glob('./dataset/{}/*.*'.format(self.dataset_name + '/trainB'))
```
所以需要创建一个dataset文件夹包含数据集'**2**'才可以运行。
这篇关于跑MUNIT遇到的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!