train on my own collected data failed
aaaven opened this issue · 11 comments
Traceback (most recent call last):
File "train.py", line 112, in
a_test_pool = data.ImageData(sess, a_test_img_paths, batch_size, load_size=load_size, crop_size=crop_size)
File "/home/aven/cycleGANtf/data.py", line 35, in init
repeat)
File "/home/aven/cycleGANtf/data.py", line 69, in _image_batch
dataset = dataset.map(_parse_func, num_parallel_calls=num_threads)
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 988, in map
return ParallelMapDataset(self, map_func, num_parallel_calls)
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2230, in init
super(ParallelMapDataset, self).init(input_dataset, map_func)
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2198, in init
map_func, "Dataset.map()", input_dataset)
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1454, in init
self._function.add_to_graph(ops.get_default_graph())
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 481, in add_to_graph
self._create_definition_if_needed()
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 337, in _create_definition_if_needed
self._create_definition_if_needed_impl()
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 346, in _create_definition_if_needed_impl
self._capture_by_value, self._caller_device)
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 863, in func_graph_from_py_func
outputs = func(*func_graph.inputs)
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1392, in tf_data_structured_function_wrapper
ret = func(*nested_args)
File "/home/aven/cycleGANtf/data.py", line 57, in _parse_func
img = tf.read_file(path)
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/site-packages/tensorflow/python/ops/gen_io_ops.py", line 528, in read_file
"ReadFile", filename=filename, name=name)
File "/usr/local/anaconda3/envs/cycleGANtf/lib/python2.7/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 got it runing on the downloaded horse2zebra dataset, but if try to switch to my own collected data, it gave me the above error, try to modify the data type a bit but failed. Any suggestion here how to work it out?
@aaaven This error seems to be that your data can't be found. What's the type of your data, and where do you place your data.
Hi! Thanks for the quick response! I used jpeg and it's in "datasets/sketch2shanshui"(and when i train horse2zebra, the data is in"datasets/horse2zebra"), I then train with command "CUDA_VISIBLE_DEVICES=0 python train.py --dataset=sketch2shanshui". and it followed with the error meassage above.
And i dont think it's the path, i even tried to keep the path, the train command all the same, only replace the horse images with my own images, the same error happens, i think, might it be the data type issue? but it's beyond my tf knowledge to fix it
@aaaven My code works only for ".jpg". Is the extension of your images ".jpeg" or others?
sorry, i meant ".jpg", I am using ".jpg"
aven@PremilabServer03:~/cycleGANtf/datasets/sketch2shanshui/trainA$ ls
n02381460_0.jpg n02381460_169.jpg n02381460_239.jpg n02381460_309.jpg
@aaaven That's strange, I am sorry that I have no more idea about your error. Maybe you should check whether the glob
function above correctly returns the paths of your images.
well, i did a quick test by simply copying those images i used into the horse2zebra folder and keep everything the same, it gives the same error, so i dont think it has anything to do with the path, but somehow the data type issue. But thanks for all your help, i will try it a bit more and see if i can figure out why
will it be still the data type problem?
if i try to check the image type with $file img.jpg it will be like this:
aven@PremilabServer03:~/cycleGANtf/datasets/sketch2shanshui/trainA$ file n02381460_870.jpg
n02381460_870.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 256x256, frames 3
@aaaven I did not see any problem from such information. I still think it is the path problem, because the error tells that a string is needed but you gave a float32.
I figured out the problem! yes, you are right, it's path missing. I didn't put testA/testB in. I was too focusing on the traing data but didnt realize your implementation was testing the model during training. I thought I will only need the test data afterwards. Anyways, we can finally close this issue now! Thanks for all your help!