-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed with my own tfrecords. #2
Comments
The trace log is: ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/iterator_ops.py in next(self) ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/iterator_ops.py in next(self) ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/iterator_ops.py in _next_internal(self) ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_dataset_ops.py in iterator_get_next_sync(iterator, output_types, output_shapes, name) ~/anaconda3/lib/python3.6/site-packages/six.py in raise_from(value, from_value) InvalidArgumentError: Input to reshape is a tensor with 37686 values, but the requested shape has 37632 |
I fixed it by comment out one line code: It runs ok now. Thank you. |
Thank you for your share.
I got a problem when I run it with my own data.
I make bmp files to tfrecords with code below:
import tensorflow as tf
import cv2
import numpy as np
datalistfile = './images/data'
''' format of datalistfile
0 ./images/cgh_0.bmp ./images/cgh_10.bmp
0 ./images/cgh_10.bmp ./images/cgh_11.bmp
'''
dataf = open(datalistfile,'r')
writer = tf.python_io.TFRecordWriter("test.tfrecords")
def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value = [value]))
def _bytes_feature(value):
return tf.train.Feature(bytes_list=tf.train.BytesList(value = [value]))
data = dataf.readlines()
for i in range(len(data)):
line = data[i]
line = line.strip()
line = line.split(" ")
Xi = tf.gfile.FastGFile(line[1], 'rb').read() # image data type is string
Xj = tf.gfile.FastGFile(line[2], 'rb').read() # image data type is string
image_shape = cv2.imread(line[1]).shape
width = image_shape[1]
height = image_shape[0]
label = int(line[0])
features = {
'Xi': _bytes_feature(Xi),
'Xj': _bytes_feature(Xj),
"label": _int64_feature(label),
"height": _int64_feature(height),
"width": _int64_feature(width)
}
example = tf.train.Example(features = tf.train.Features(feature=features))
writer.write(example.SerializeToString())
writer.close()
So , can you tell me how do you make your test_v2.tfrecords from images?
The text was updated successfully, but these errors were encountered: