taki0112 / BigGAN-Tensorflow

Simple Tensorflow implementation of "Large Scale GAN Training for High Fidelity Natural Image Synthesis" (BigGAN)
MIT License
262 stars 74 forks source link

TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string #1

Closed me2beats closed 5 years ago

me2beats commented 5 years ago

Do I need to download celebaHQ dataset or do something else before training on it? I used Google Colab, python3, GPU:

!git clone https://github.com/taki0112/BigGAN-Tensorflow.git
!python main.py --phase train --dataset celebA-HQ --gan_type hinge

And I got an error

##### Information #####
# BigGAN 512
# gan type :  hinge
# dataset :  celebA-HQ
# dataset number :  0
# batch_size :  2048
# epoch :  50
# iteration per epoch :  10000

##### Generator #####
# spectral normalization :  True
# learning rate :  5e-05

##### Discriminator #####
# the number of critic :  2
# spectral normalization :  True
# learning rate :  0.0002
WARNING:tensorflow:From /content/BigGAN-Tensorflow/BigGAN_512.py:219: shuffle_and_repeat (from tensorflow.contrib.data.python.ops.shuffle_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.data.experimental.shuffle_and_repeat(...)`.
WARNING:tensorflow:From /content/BigGAN-Tensorflow/BigGAN_512.py:220: map_and_batch (from tensorflow.contrib.data.python.ops.batching) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.data.experimental.map_and_batch(...)`.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
    preferred_dtype=default_dtype)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1146, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 983, 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 132, in <module>
    main()
  File "main.py", line 113, in main
    gan.build_model()
  File "/content/BigGAN-Tensorflow/BigGAN_512.py", line 220, in build_model
    apply(map_and_batch(Image_Data_Class.image_processing, self.batch_size, num_parallel_batches=16, drop_remainder=True)).\
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py", line 1190, in apply
    dataset = transformation_func(self)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/experimental/ops/batching.py", line 667, in _apply_fn
    num_parallel_calls, drop_remainder)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/experimental/ops/batching.py", line 578, in __init__
    super(_MapAndBatchDataset, self).__init__(input_dataset, map_func)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py", line 2611, in __init__
    map_func, "Dataset.map()", input_dataset)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py", line 1860, in __init__
    self._function.add_to_graph(ops.get_default_graph())
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/function.py", line 479, in add_to_graph
    self._create_definition_if_needed()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/function.py", line 335, in _create_definition_if_needed
    self._create_definition_if_needed_impl()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/function.py", line 344, in _create_definition_if_needed_impl
    self._capture_by_value, self._caller_device)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/function.py", line 864, in func_graph_from_py_func
    outputs = func(*func_graph.inputs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py", line 1794, in tf_data_structured_function_wrapper
    ret = func(*nested_args)
  File "/content/BigGAN-Tensorflow/utils.py", line 22, in image_processing
    x = tf.read_file(filename)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_io_ops.py", line 531, in read_file
    "ReadFile", filename=filename, name=name)
  File "/usr/local/lib/python3.6/dist-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.
taki0112 commented 5 years ago

Yes. You need to download the celebA-HQ images. Then create the celebA-HQ folder in the dataset folder. And, insert the downloaded images here.