models icon indicating copy to clipboard operation
models copied to clipboard

Windows fatal exception: access violation error (generate_tfrecord.py )

Open beyzanurkaya opened this issue 7 years ago • 15 comments

Hi all I need your help a lot. I've been dealing with this problem for about 3 days. Moreover, I have to solve this problem in 1-2 days at the latest.

"(RobotaksiTespit) D:\RobotaksiTespit\model\research\object_detection>python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record " after a certain time error is coming.

Windows fatal exception: access violation

Current thread 0x00000708 (most recent call first): File "C:\Users\otobil\Anaconda3\envs\RobotaksiTespit\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 84 in _preread_check File "C:\Users\otobil\Anaconda3\envs\RobotaksiTespit\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 122 in read File "generate_tfrecord.py", line 78 in create_tf_example File "generate_tfrecord.py", line 123 in main File "C:\Users\otobil\Anaconda3\envs\RobotaksiTespit\lib\site-packages\absl\app.py", line 250 in _run_main File "C:\Users\otobil\Anaconda3\envs\RobotaksiTespit\lib\site-packages\absl\app.py", line 299 in run File "C:\Users\otobil\Anaconda3\envs\RobotaksiTespit\lib\site-packages\tensorflow\python\platform\app.py", line 40 in run File "generate_tfrecord.py", line 132 in

data size in my train folder : 151 GB the size of created record file: 22,8 GB

in summary, the record file is a bit generated, and then the error occurs and the record file does not occur in full size

please help me !

system: Windows10 Intel Coffee Lake Core i7-9700K 8GB GDDR6 Nvidia RTX2070 256 Bit error

16GB (2x8GB) DDR4 2666MHz

beyzanurkaya avatar Sep 01 '19 15:09 beyzanurkaya

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. What is the top-level directory of the model you are using Have I written custom code OS Platform and Distribution TensorFlow installed from TensorFlow version Bazel version CUDA/cuDNN version GPU model and memory Exact command to reproduce

tensorflowbutler avatar Sep 02 '19 12:09 tensorflowbutler

thanks for your reply.

steps:

conda create -n RobotaksiTespit pip python=3.6 conda activate RobotaksiTespit pip install --upgrade tensorflow-gpu pip install "numpy<1.17" conda install -c anaconda protobuf pip install pillow pip install lxml pip install jupyter pip install matplotlib pip install pandas pip install opencv-python D: set PYTHONPATH=D:\RobotaksiTespit\model;D:\RobotaksiTespit\model\research;D:\RobotaksiTespit\model\research\slim

(RobotaksiTespit) D:>cd RobotaksiTespit\model\research

protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto .\object_detection\protos\calibration.proto

python setup.py build

python setup.py install

cd object_detection

python xml_to_csv.py

python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record

""" Usage:

From tensorflow/models/

Create train data:

python generate_tfrecord.py --csv_input=images/train_labels.csv --image_dir=images/train --output_path=train.record

Create test data:

python generate_tfrecord.py --csv_input=images/test_labels.csv --image_dir=images/test --output_path=test.record """ from future import division from future import print_function from future import absolute_import

import os import io import pandas as pd import tensorflow as tf

from PIL import Image from object_detection.utils import dataset_util from collections import namedtuple, OrderedDict

flags = tf.app.flags flags.DEFINE_string('csv_input', '', 'Path to the CSV input') flags.DEFINE_string('image_dir', '', 'Path to the image directory') flags.DEFINE_string('output_path', '', 'Path to output TFRecord') FLAGS = flags.FLAGS

generate_tfrecord.py

TO-DO replace this with label map

def class_text_to_int(row_label): if row_label == 'dur': return 1 elif row_label == 'durak': return 2 elif row_label == 'girilmez': return 3 elif row_label == 'hiz_otuz': return 4 elif row_label == 'hiz_yirmi': return 5 elif row_label == 'hiz_yirmi_son': return 6 elif row_label == 'ileri_ve_saga_mecburi': return 7 elif row_label == 'ileri_ve_sola_mecburi': return 8 elif row_label == 'ileriden_sag': return 9 elif row_label == 'ileriden_sol': return 10 elif row_label == 'kirmizi': return 11 elif row_label == 'park': return 12 elif row_label == 'park_yasak': return 13 elif row_label == 'sag_yasak': return 14 elif row_label == 'sol_yasak': return 15 elif row_label == 'trafige_kapali': return 16 elif row_label == 'yesil': return 17 else: None

def split(df, group): data = namedtuple('data', ['filename', 'object']) gb = df.groupby(group) return [data(filename, gb.get_group(x)) for filename, x in zip(gb.groups.keys(), gb.groups)]

def create_tf_example(group, path): with tf.gfile.GFile(os.path.join(path, '{}'.format(group.filename)), 'rb') as fid: encoded_jpg = fid.read() encoded_jpg_io = io.BytesIO(encoded_jpg) image = Image.open(encoded_jpg_io) width, height = image.size

filename = group.filename.encode('utf8')
image_format = b'jpg'
xmins = []
xmaxs = []
ymins = []
ymaxs = []
classes_text = []
classes = []

for index, row in group.object.iterrows():
    xmins.append(row['xmin'] / width)
    xmaxs.append(row['xmax'] / width)
    ymins.append(row['ymin'] / height)
    ymaxs.append(row['ymax'] / height)
    classes_text.append(row['class'].encode('utf8'))
    classes.append(class_text_to_int(row['class']))

tf_example = tf.train.Example(features=tf.train.Features(feature={
    'image/height': dataset_util.int64_feature(height),
    'image/width': dataset_util.int64_feature(width),
    'image/filename': dataset_util.bytes_feature(filename),
    'image/source_id': dataset_util.bytes_feature(filename),
    'image/encoded': dataset_util.bytes_feature(encoded_jpg),
    'image/format': dataset_util.bytes_feature(image_format),
    'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
    'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
    'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
    'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
    'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
    'image/object/class/label': dataset_util.int64_list_feature(classes),
}))
return tf_example

def main(_): writer = tf.python_io.TFRecordWriter(FLAGS.output_path) path = os.path.join(os.getcwd(), FLAGS.image_dir) examples = pd.read_csv(FLAGS.csv_input) grouped = split(examples, 'filename') for group in grouped: tf_example = create_tf_example(group, path) writer.write(tf_example.SerializeToString())

writer.close()
output_path = os.path.join(os.getcwd(), FLAGS.output_path)
print('Successfully created the TFRecords: {}'.format(output_path))

if name == 'main': tf.app.run()

CUDA 10.0 CUDNN 7.4.2 for CUDA tool kit 10.0 Windows 10 Pro Intel Coffee Lake Core i7-9700K 8GB GDDR6 Nvidia RTX2070 256 Bit RAM: 16GB

beyzanurkaya avatar Sep 02 '19 12:09 beyzanurkaya

did you find a solution for this problem please?

Yazmaz98 avatar Nov 26 '19 20:11 Yazmaz98

I'm facing exactly the same issue... Using Windows10, Python3.7.5, TF 1.15, Cuda 10.0.

viniciusov avatar Dec 17 '19 14:12 viniciusov

Any solution to this issue?

abdelazizmirasoft avatar Feb 04 '20 14:02 abdelazizmirasoft

Check if all images in csv-file are .jpg (or same format with connected image)

YAKOVLENKO avatar Feb 06 '20 15:02 YAKOVLENKO

Guys, I had the same problem, tried to solved for it 2 weeks, finally I changed my versions and it worked. Use it Cuda 10.0 , cdNN 7.4.2 , tensorflow(pip install 1.13.2) , tensorflow(model version 1.13( 2 of proto are missing, copy from other models)) Good luck.

FurkanDemirbag avatar Mar 07 '20 15:03 FurkanDemirbag

Guys, I had the same problem, tried to solved for it 2 weeks, finally I changed my versions and it worked. Use it Cuda 10.0 , cdNN 7.4.2 , tensorflow(pip install 1.13.2) , tensorflow(model version 1.13( 2 of proto are missing, copy from other models)) Good luck.

Hi bro, I met the same problem and it still exists after installing tf 1.13.2. What does "tensorflow(model version 1.13( 2 of proto are missing, copy from other models))" means?

Thanks

WenzelWu avatar Mar 19 '20 07:03 WenzelWu

Guys, I had the same problem, tried to solved for it 2 weeks, finally I changed my versions and it worked. Use it Cuda 10.0 , cdNN 7.4.2 , tensorflow(pip install 1.13.2) , tensorflow(model version 1.13( 2 of proto are missing, copy from other models)) Good luck.

Hi bro, I met the same problem and it still exists after installing tf 1.13.2. What does "tensorflow(model version 1.13( 2 of proto are missing, copy from other models))" means?

Thanks

Hi, in the new tensorflow version, we encounter a 'contrib' library error, but in tensorflow 1.13 version this error is not encountered. here is the link; https://github.com/tensorflow/models/tree/r1.13.0 Good luck.

FurkanDemirbag avatar Mar 19 '20 08:03 FurkanDemirbag

我正面临着完全相同的问题... 使用Windows10,Python3.7.5,TF 1.15,Cuda 10.0。

do you solve it,i have the trouble,too。why the tf can not be clear such as java

BinchaoPeng avatar Apr 15 '20 15:04 BinchaoPeng

@beyzanurkaya

Is this still an issue?. Please, close this thread if your issue was resolved.Thanks!

ravikyram avatar Jun 22 '20 11:06 ravikyram

Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!

ravikyram avatar Jul 22 '20 07:07 ravikyram

i had the same problem on windows10 tf1.15 when running extract_features.py . it seems an wrtten error after all layers feature extracted successfully. i also tried to run this script on linux with same config and tf version, it works well. maybe it's incompatible on windows platform or some wrong version packages.

shangbl avatar Jun 21 '21 15:06 shangbl

i had the same problem on windows10 tf1.15 when running extract_features.py . it seems an wrtten error after all layers feature extracted successfully. i also tried to run this script on linux with same config and tf version, it works well. maybe it's incompatible on windows platform or some wrong version packages.

i solved this problem by correct my feature output path, i had an non-exist directory

shangbl avatar Jun 22 '21 14:06 shangbl

i had the same problem on windows10 tf1.15 when running extract_features.py . it seems an wrtten error after all layers feature extracted successfully. i also tried to run this script on linux with same config and tf version, it works well. maybe it's incompatible on windows platform or some wrong version packages.

i solved this problem by correct my feature output path, i had an non-exist directory

which feature output path you corrected and where?

ojasvisancheti avatar Jul 13 '21 17:07 ojasvisancheti