Box error while running eval.py
(virtual-py3) somsukla@somsukla-Precision-Tower-7810:~/Desktop/models/research/object_detection$ python3 eval.py --logtostderr --pipeline_config_path=Vehicle_Detection/training/ssd_mobilenet_v1_coco.config --checkpoint_dir=Vehicle_Detection/training --eval_dir=Vehicle_Detection/eval/
INFO:tensorflow:depth of additional conv before box predictor: 0
INFO:tensorflow:depth of additional conv before box predictor: 0
INFO:tensorflow:depth of additional conv before box predictor: 0
INFO:tensorflow:depth of additional conv before box predictor: 0
INFO:tensorflow:depth of additional conv before box predictor: 0
INFO:tensorflow:depth of additional conv before box predictor: 0
2018-03-06 15:37:58.359462: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-03-06 15:37:58.367344: E tensorflow/stream_executor/cuda/cuda_driver.cc:406] failed call to cuInit: CUDA_ERROR_NO_DEVICE
2018-03-06 15:37:58.367384: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:158] retrieving CUDA diagnostic information for host: somsukla-Precision-Tower-7810
2018-03-06 15:37:58.367396: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: somsukla-Precision-Tower-7810
2018-03-06 15:37:58.367431: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: 384.111.0
2018-03-06 15:37:58.367456: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:369] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module 384.111 Tue Dec 19 23:51:45 PST 2017
GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
"""
2018-03-06 15:37:58.367476: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: 384.111.0
2018-03-06 15:37:58.367486: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:300] kernel version seems to match DSO: 384.111.0
INFO:tensorflow:Restoring parameters from Vehicle_Detection/training/model.ckpt-0
INFO:tensorflow:Restoring parameters from Vehicle_Detection/training/model.ckpt-0
WARNING:root:image 0 does not have groundtruth difficult flag specified
Traceback (most recent call last):
File "eval.py", line 133, in
The training is running fine. However during evaluation(eval.py), the above error is occurring. Please resolve the issue.
How did you generate the TFRecord?
Same issue here, using the same script to generate both the train and eval TFRecords. Training goes smoothly, but then running the eval script gives me:
WARNING:root:image 0 does not have groundtruth difficult flag specified
Traceback (most recent call last):
File "object_detection/eval.py", line 135, in
Was facing the same error. Turned out that it was a problem with the TFRecord generation
@prantiksen4 Hi, I had the same problem. Could you share how you solved it out? Thanks!
I was using the Pascal VOC dataset. In the annotations file, the xmin, xmax, ymin, ymax were not in proper order. So, I had to make modifications to the script used to generate TFRecords file. If you can share the script, I can tell you better.
@prantiksen4 I think I figured out the problem, thanks!
@prantiksen4, @CrazyJiawei can you please share how you solved it? I have the same problem.
@prantiksen4 I was doing (x1, y1, x2, y2) while tensorflow API does (y1, x1, y2, x2). Maybe have a check with the order. ; )
@CrazyJiawei That was exactly what I was doing wrong. @nishant842 please have a look at that
Closing this issue since its resolved. Feel free to reopen if the issue still persists. Thanks!
(virtual-py3) somsukla@somsukla-Precision-Tower-7810:/Desktop/models/research/object_detection$ python3 eval.py --logtostderr --pipeline_config_path=Vehicle_Detection/training/ssd_mobilenet_v1_coco.config --checkpoint_dir=Vehicle_Detection/training --eval_dir=Vehicle_Detection/eval/ INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 INFO:tensorflow:depth of additional conv before box predictor: 0 2018-03-06 15:37:58.359462: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA 2018-03-06 15:37:58.367344: E tensorflow/stream_executor/cuda/cuda_driver.cc:406] failed call to cuInit: CUDA_ERROR_NO_DEVICE 2018-03-06 15:37:58.367384: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:158] retrieving CUDA diagnostic information for host: somsukla-Precision-Tower-7810 2018-03-06 15:37:58.367396: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: somsukla-Precision-Tower-7810 2018-03-06 15:37:58.367431: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: 384.111.0 2018-03-06 15:37:58.367456: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:369] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module 384.111 Tue Dec 19 23:51:45 PST 2017 GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu116.04.9) """ 2018-03-06 15:37:58.367476: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: 384.111.0 2018-03-06 15:37:58.367486: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:300] kernel version seems to match DSO: 384.111.0 INFO:tensorflow:Restoring parameters from Vehicle_Detection/training/model.ckpt-0 INFO:tensorflow:Restoring parameters from Vehicle_Detection/training/model.ckpt-0 WARNING:root:image 0 does not have groundtruth difficult flag specified Traceback (most recent call last): File "eval.py", line 133, in tf.app.run() File "/home/somsukla/.virtualenvs/virtual-py3/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "eval.py", line 129, in main FLAGS.checkpoint_dir, FLAGS.eval_dir) File "/home/somsukla/Desktop/models/research/object_detection/evaluator.py", line 210, in evaluate save_graph_dir=(eval_dir if eval_config.save_graph else '')) File "/home/somsukla/Desktop/models/research/object_detection/eval_util.py", line 381, in repeated_checkpoint_run save_graph_dir) File "/home/somsukla/Desktop/models/research/object_detection/eval_util.py", line 271, in _run_checkpoint_once image_id=batch, detections_dict=result_dict) File "/home/somsukla/Desktop/models/research/object_detection/utils/object_detection_evaluation.py", line 213, in add_single_detected_image_info detection_classes) File "/home/somsukla/Desktop/models/research/object_detection/utils/object_detection_evaluation.py", line 524, in add_single_detected_image_info groundtruth_is_difficult_list, groundtruth_is_group_of_list)) File "/home/somsukla/Desktop/models/research/object_detection/utils/per_image_evaluation.py", line 95, in compute_object_detection_metrics groundtruth_is_difficult_lists, groundtruth_is_group_of_list) File "/home/somsukla/Desktop/models/research/object_detection/utils/per_image_evaluation.py", line 212, in _compute_tp_fp groundtruth_is_group_of_list_at_ith_class) File "/home/somsukla/Desktop/models/research/object_detection/utils/per_image_evaluation.py", line 280, in _compute_tp_fp_for_single_class groundtruth_boxes[~groundtruth_is_group_of_list, :]) File "/home/somsukla/Desktop/models/research/object_detection/utils/np_box_list.py", line 50, in init raise ValueError('Invalid box data. data must be a numpy array of ' ValueError: Invalid box data. data must be a numpy array of N*[y_min, x_min, y_max, x_max]
The training is running fine. However during evaluation(eval.py), the above error is occurring. Please resolve the issue.
hi,how do you solve the question?can you share with me.
I am having the same issue, even after fixing generate_Tfrecord.py file and putting coordinates in the following order: y_min, x_min, y_max, x_max.
`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('output_path', '', 'Path to output TFRecord') flags.DEFINE_string('image_dir', '', 'Path to images') FLAGS = flags.FLAGS
TO-DO replace this with label map
def class_text_to_int(row_label): if row_label == 'barcode': return 1 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'png'
ymins = []
xmins = []
ymaxs = []
xmaxs = []
classes_text = []
classes = []
# Invalid box data. data must be a numpy array of N*[y_min, x_min, y_max, x_max]
for index, row in group.object.iterrows():
ymins.append(row['ymin'] / width)
xmins.append(row['xmin'] / width)
ymaxs.append(row['ymax'] / height)
xmaxs.append(row['xmax'] / 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/ymin': dataset_util.float_list_feature(ymins),
'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
'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(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()`
By the way, is using extraneous code the only way to generate tf record from csv file?
- 🙄 For me it was a logical error, in
test_labels.csvthere were some invalid values like:
file123.jpg,134,63,3,0,0,-1029,-615
- 🏷 So, it was a labeling issue, fixing these lines solved the problem
I am facing the same issue while evaluating the model. I am using tensorflow 1.15.0, numpy 1.17.2 and running in local machine using pycharm.
2022-06-21 12:34:58.395777: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
INFO:tensorflow:Restoring parameters from /home/anish/PycharmProjects/obj_detection_ssd_mbv2/models/train2/model.ckpt-200
I0621 12:34:59.621972 140495530121024 saver.py:1284] Restoring parameters from /home/anish/PycharmProjects/obj_detection_ssd_mbv2/models/train2/model.ckpt-200
I0621 12:35:01.556645 140495530121024 evaluator.py:238] Skipping image
I0621 12:35:01.627492 140495530121024 evaluator.py:238] Skipping image
I0621 12:35:01.702031 140495530121024 evaluator.py:238] Skipping image
I0621 12:35:01.777144 140495530121024 evaluator.py:238] Skipping image
I0621 12:35:01.848348 140495530121024 evaluator.py:238] Skipping image
INFO:tensorflow:Creating detection visualizations.
I0621 12:35:02.004959 140495530121024 eval_util.py:178] Creating detection visualizations.
INFO:tensorflow:Detection visualizations written to summary with tag image-5.
I0621 12:35:02.637105 140495530121024 eval_util.py:243] Detection visualizations written to summary with tag image-5.
W0621 12:35:02.637493 140495530121024 object_detection_evaluation.py:344] image b'2009_003714_jpg.rf.b5b5bf746be303fc79734191425a0fa1.jpg' does not have groundtruth difficult flag specified
I0621 12:35:02.740075 140495530121024 evaluator.py:238] Skipping image
I0621 12:35:02.804440 140495530121024 evaluator.py:238] Skipping image
INFO:tensorflow:Creating detection visualizations.
I0621 12:35:02.864755 140495530121024 eval_util.py:178] Creating detection visualizations.
INFO:tensorflow:Detection visualizations written to summary with tag image-8.
I0621 12:35:02.918146 140495530121024 eval_util.py:243] Detection visualizations written to summary with tag image-8.
INFO:tensorflow:Creating detection visualizations.
I0621 12:35:02.977220 140495530121024 eval_util.py:178] Creating detection visualizations.
INFO:tensorflow:Detection visualizations written to summary with tag image-9.
I0621 12:35:03.015341 140495530121024 eval_util.py:243] Detection visualizations written to summary with tag image-9.
I0621 12:35:03.079769 140495530121024 evaluator.py:238] Skipping image
I0621 12:35:03.149323 140495530121024 evaluator.py:238] Skipping image
I0621 12:35:03.813362 140495530121024 evaluator.py:238] Skipping image
I0621 12:35:03.878179 140495530121024 evaluator.py:238] Skipping image
INFO:tensorflow:# success: 13
I0621 12:35:03.943760 140495530121024 eval_util.py:381] # success: 13
INFO:tensorflow:# skipped: 11
I0621 12:35:03.943877 140495530121024 eval_util.py:382] # skipped: 11
W0621 12:35:03.944083 140495530121024 object_detection_evaluation.py:1306] The following classes have no ground truth examples: [ 1 2 4 6 7 10 14 16 17 18 19 21 22 23 24 25 26 27]
I0621 12:35:03.944644 140495530121024 object_detection_evaluation.py:1339] class 2 average_precision: 0.000000
I0621 12:35:03.944907 140495530121024 object_detection_evaluation.py:1339] class 4 average_precision: 0.000000
I0621 12:35:03.944989 140495530121024 object_detection_evaluation.py:1339] class 7 average_precision: 0.000000
I0621 12:35:03.945343 140495530121024 object_detection_evaluation.py:1339] class 8 average_precision: 0.000000
I0621 12:35:03.945549 140495530121024 object_detection_evaluation.py:1339] class 10 average_precision: 0.000000
I0621 12:35:03.945677 140495530121024 object_detection_evaluation.py:1339] class 11 average_precision: 0.000000
I0621 12:35:03.945795 140495530121024 object_detection_evaluation.py:1339] class 12 average_precision: 0.000000
I0621 12:35:03.947948 140495530121024 object_detection_evaluation.py:1339] class 14 average_precision: 0.058070
I0621 12:35:03.948159 140495530121024 object_detection_evaluation.py:1339] class 19 average_precision: 0.000000
/home/anish/.conda/envs/obj_detection_ssd_mbv2/lib/python3.7/site-packages/object_detection/utils/metrics.py:145: RuntimeWarning: invalid value encountered in true_divide
num_images_correctly_detected_per_class / num_gt_imgs_per_class)
Traceback (most recent call last):
File "research/object_detection/legacy/eval.py", line 142, in