ImageNet Data processing
Please go to Stack Overflow for help and support:
http://stackoverflow.com/questions/tagged/tensorflow
Also, please understand that many of the models included in this repository are experimental and research-style code. If you open a GitHub issue, here is our policy:
- It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).
- The form below must be filled out.
Here's why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.
System information
-
What is the top-level directory of the model you are using:
-
Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
-
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Redhat
-
TensorFlow installed from (source or binary): binary
-
TensorFlow version (use command below): 1.7
-
Bazel version (if compiling from source):
-
CUDA/cuDNN version: 9/6.6
-
GPU model and memory: K20 / 5.5 GB
-
Exact command to reproduce:
You can collect some of this information using our environment capture script:
https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh
You can obtain the TensorFlow version with
python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"
Describe the problem
Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request. I am trying to prepare the imagenet data for the tf_cnn_benchmarks. I am using the"download_and_preprocess_imagenet.sh" script . I worked but when it prepare for TFRECORD format I got processing errors with tf.
Source code / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.
./download_and_preprocess_newimagenet.sh /home/amalik/NEWIMAGENETDATA/ Organizing the validation data into sub-directories. Extracting bounding box information from XML. Finished downloading and preprocessing the ImageNet data. Saving results to /home/amalik/NEWIMAGENETDATA Successfully read 615299 bounding boxes across 544546 images. Determining list of input files and labels from /home/amalik/NEWIMAGENETDATA/raw-data/validation/. Finished finding files in 100 of 1000 classes. Finished finding files in 200 of 1000 classes. Finished finding files in 300 of 1000 classes. Finished finding files in 400 of 1000 classes. Finished finding files in 500 of 1000 classes. Finished finding files in 600 of 1000 classes. Finished finding files in 700 of 1000 classes. Finished finding files in 800 of 1000 classes. Finished finding files in 900 of 1000 classes. Finished finding files in 1000 of 1000 classes. Found 50000 JPEG files across 1000 labels inside /home/amalik/NEWIMAGENETDATA/raw-data/validation/. Found 0 images with bboxes out of 50000 images Launching 8 threads for spacings: [[0, 6250], [6250, 12500], [12500, 18750], [18750, 25000], [25000, 31250], [31250, 37500], [37500, 43750], [43750, 50000]] 2018-04-25 11:32:43.064265: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 0 with properties: name: Tesla K20Xm major: 3 minor: 5 memoryClockRate(GHz): 0.732 pciBusID: 0000:08:00.0 totalMemory: 5.57GiB freeMemory: 5.49GiB 2018-04-25 11:32:43.064342: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1423] Adding visible gpu devices: 0 2018-04-25 11:32:45.273683: I tensorflow/core/common_runtime/gpu/gpu_device.cc:911] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-04-25 11:32:45.273756: I tensorflow/core/common_runtime/gpu/gpu_device.cc:917] 0 2018-04-25 11:32:45.273775: I tensorflow/core/common_runtime/gpu/gpu_device.cc:930] 0: N 2018-04-25 11:32:45.274055: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 5285 MB memory) -> physical GPU (device: 0, name: Tesla K20Xm, pci bus id: 0000:08:00.0, compute capability: 3.5) Exception in thread Thread-1: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-6: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given) Exception in thread Thread-7: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-5: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-2: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given) Exception in thread Thread-3: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-4: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-8: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
2018-04-25 11:32:46.426148: Finished writing all 50000 images in data set. Determining list of input files and labels from /home/amalik/NEWIMAGENETDATA/raw-data/train/. Finished finding files in 100 of 1000 classes. Finished finding files in 200 of 1000 classes. Finished finding files in 300 of 1000 classes. Finished finding files in 400 of 1000 classes. Finished finding files in 500 of 1000 classes. Finished finding files in 600 of 1000 classes. Finished finding files in 700 of 1000 classes. Finished finding files in 800 of 1000 classes. Finished finding files in 900 of 1000 classes. Finished finding files in 1000 of 1000 classes. Found 1281167 JPEG files across 1000 labels inside /home/amalik/NEWIMAGENETDATA/raw-data/train/. Found 544546 images with bboxes out of 1281167 images Launching 8 threads for spacings: [[0, 160145], [160145, 320291], [320291, 480437], [480437, 640583], [640583, 800729], [800729, 960875], [960875, 1121021], [1121021, 1281167]] 2018-04-25 11:34:48.594990: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1423] Adding visible gpu devices: 0 2018-04-25 11:34:48.595083: I tensorflow/core/common_runtime/gpu/gpu_device.cc:911] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-04-25 11:34:48.595103: I tensorflow/core/common_runtime/gpu/gpu_device.cc:917] 0 2018-04-25 11:34:48.595116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:930] 0: N 2018-04-25 11:34:48.595422: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 5285 MB memory) -> physical GPU (device: 0, name: Tesla K20Xm, pci bus id: 0000:08:00.0, compute capability: 3.5) Exception in thread Thread-13: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given) Exception in thread Thread-12: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-14: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-11: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given) Exception in thread Thread-10: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-9: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-15: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
Exception in thread Thread-16: Traceback (most recent call last): File "/home/amalik/tenENV/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/amalik/tenENV/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 395, in _process_image_files_batch height, width) File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 214, in _convert_to_example 'image/colorspace': _bytes_feature(colorspace), File "/home/amalik/DATA/models/research/inception/inception/data/build_imagenet_data.py", line 175, in _bytes_feature value = six.binary_type(value, encoding='utf-8') TypeError: str() takes at most 1 argument (2 given)
2018-04-25 11:34:49.610442: Finished writing all 1281167 images in data set.
You can try to delete two lines below in build_imagenet_data.py
if isinstance(value, six.string_types):
value = six.binary_type(value, encoding='utf-8')
then the _bytes_feature function will be this:
def _bytes_feature(value):
"""Wrapper for inserting bytes features into Example proto."""
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
I encountered the same issue. In my case the problem was because six maps the binary_type to 'str' and 'str' doesn't accept an 'encoding' argument.
Switching to python3 fixed the problem for me.
Can you try py3 to see if it works? @abidmalik1967
Hi There, We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing. If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.