taki0112 / UGATIT

Official Tensorflow implementation of U-GAT-IT: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation (ICLR 2020)
MIT License
6.17k stars 1.05k forks source link

Technical question #86

Open paulhigazi opened 4 years ago

paulhigazi commented 4 years ago

Question 1: Hey I use google Colab and tried to test it the way you claimed. Cloning the repo and just using the command:!python /content/UGATIT/main.py --dataset /content/dataset

In dataset i have 4 folders named (testA,testB,trainA,trainB) with 3 JPG images each. Actually calling this command leads to an error:

Traceback (most recent call last):
  File "/content/UGATIT/main.py", line 106, in <module>
    main()
  File "/content/UGATIT/main.py", line 92, in main
    gan.build_model()
  File "/content/UGATIT/UGATIT.py", line 355, in build_model
    trainA = trainA.apply(shuffle_and_repeat(self.dataset_num)).apply(map_and_batch(Image_Data_Class.image_processing, self.batch_size, num_parallel_batches=16, drop_remainder=True)).apply(prefetch_to_device(gpu_device, None))
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/data/ops/dataset_ops.py", line 1990, in apply
    return DatasetV1Adapter(super(DatasetV1, self).apply(transformation_func))
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/data/ops/dataset_ops.py", line 1378, in apply
    dataset = transformation_func(self)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/data/experimental/ops/batching.py", line 197, in _apply_fn
    num_parallel_calls, drop_remainder)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/data/experimental/ops/batching.py", line 274, in __init__
    use_legacy_function=use_legacy_function)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/data/ops/dataset_ops.py", line 2713, in __init__
    self._function = wrapper_fn._get_concrete_function_internal()
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/eager/function.py", line 1853, in _get_concrete_function_internal
    *args, **kwargs)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/eager/function.py", line 1847, in _get_concrete_function_internal_garbage_collected
    graph_function, _, _ = self._maybe_define_function(args, kwargs)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/eager/function.py", line 2147, in _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/eager/function.py", line 2038, in _create_graph_function
    capture_by_value=self._capture_by_value),
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/func_graph.py", line 915, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/data/ops/dataset_ops.py", line 2707, in wrapper_fn
    ret = _wrapper_helper(*args)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/data/ops/dataset_ops.py", line 2652, in _wrapper_helper
    ret = autograph.tf_convert(func, ag_ctx)(*nested_args)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/autograph/impl/api.py", line 237, in wrapper
    raise e.ag_error_metadata.to_exception(e)
TypeError: in converted code:
/content/UGATIT/utils.py:15 image_processing
    x = tf.read_file(filename)
/tensorflow-1.15.2/python3.6/tensorflow_core/python/ops/gen_io_ops.py:626 read_file
    "ReadFile", filename=filename, name=name)
/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/op_def_library.py:551 _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 tried to fix it, but couldnt get through. Maybe you have an idea

Question 2: Can you explain me how you train the auxilary Classificator? I read the paper about CAM and understoof the global max pooling and so on. But if i would like to implement this idea in my own code, like a keras model, what would be the ground truth for the auxilary classificator ? Thank you for your time