models icon indicating copy to clipboard operation
models copied to clipboard

Evaluation in Object Detection hanging

Open RobinBaumann opened this issue 9 years ago • 46 comments

System information

  • What is the top-level directory of the model you are using: tensorflow/models/object_detection
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes (well, i actually just adjusted the pipeline config to fit my dataset)
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 64bit
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 1.2.1
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version: 8.0 /5.1
  • GPU model and memory: GeForce GTX1060 6GB
  • Exact command to reproduce: python object_detection\eval.py --logtostderr --pipeline_config_path=C:\Users\robin\PycharmProjects\test\my_net\models\faster_r-cnn_resnet101\ pipeline.config --checkpoint_dir=C:\Users\robin\PycharmProjects\test\my_net\models\faster_r-cnn_resnet101\train\ --eval_dir=C:\Users\robin\PycharmProjects\test\my_net\models\faster_r-cnn_resnet101\eval\

Describe the problem

I am able to train with the object detecion API on my own dataset, which I created using the create_pascal_tf_record.py script (I adjusted it a bit, but mainly the paths). I also checked the generated TFRecord files with the Tensorflow Testing module and verified, that the reconstructed images are similar to the original ones.

I use the existing faster_r-cnn_resnet101_voc07.config file and only adjusted the paths and num_classes. The training runs like a charm, but when I start the eval.py script, it hangs with the message "INFO:tensorflow:Restoring parameters from C:\Users\robin\PycharmProjects\test\my-net\models\faster_r-cnn_resnet101\train\model.ckpt-123805" (see full log below).

After this I have to CTRL+C

However, I can see some output in Tensorboard, but only one value after each CTRL+C for mAP but nothing else in the other diagrams etc.

As mentioned by others having the same issue, running the evaluation and training parallel doesn't work for me, and I can't even imagine that it should be done this way. When I try it, my cuda crashed because the GPU runs out of memory.

Btw I also tried the whole evaluation process on the Oxford-IIIT Pet Dataset and am facing the same issue.

Source code / logs

The whole log after I hit CTRL+C (the part where it hangs is bold):

C:\Users\robin\models>python object_detection\eval.py --logtostderr --pipeline_config_path=C:\Users\robin\PycharmProjects\test\my_net\models\faster_r-cnn_resnet101\pipeline.config --checkpoint_dir=C:\Users\robin\PycharmProjects\test\my_net\models\faster_r-cnn_resnet101\train\ --eval_dir=C:\Users\robin\PycharmProjects\test\my_net\models\faster_r-cnn_resnet101\eval
INFO:tensorflow:Scale of 0 disables regularizer. INFO:tensorflow:Scale of 0 disables regularizer. INFO:tensorflow:Scale of 0 disables regularizer. INFO:tensorflow:Scale of 0 disables regularizer. 2017-08-16 07:40:03.000943: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations. 2017-08-16 07:40:03.001072: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-16 07:40:03.001933: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-16 07:40:03.002044: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-16 07:40:03.002153: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-16 07:40:03.002263: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-08-16 07:40:03.002357: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-16 07:40:03.002451: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. 2017-08-16 07:40:03.313527: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:940] Found device 0 with properties: name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate (GHz) 1.7085 pciBusID 0000:01:00.0 Total memory: 6.00GiB Free memory: 5.01GiB 2017-08-16 07:40:03.313690: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:961] DMA: 0 2017-08-16 07:40:03.314894: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0: Y 2017-08-16 07:40:03.314995: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0) INFO:tensorflow:Restoring parameters from C:\Users\robin\PycharmProjects\test\my_net\models\faster_r-cnn_resnet101\train\model.ckpt-123805 INFO:tensorflow:Restoring parameters from C:\Users\robin\PycharmProjects\test\my_net\models\faster_r-cnn_resnet101\train\model.ckpt-123805 Traceback (most recent call last): File "object_detection\eval.py", line 161, in tf.app.run() File "C:\Users\robin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "object_detection\eval.py", line 157, in main FLAGS.checkpoint_dir, FLAGS.eval_dir) File "C:\Users\robin\models\object_detection\evaluator.py", line 211, in evaluate save_graph_dir=(eval_dir if eval_config.save_graph else '')) File "C:\Users\robin\models\object_detection\eval_util.py", line 524, in repeated_checkpoint_run time.sleep(time_to_next_eval) KeyboardInterrupt

RobinBaumann avatar Aug 16 '17 06:08 RobinBaumann

@jch1 @tombstone @derekjchow @jesu9 @dreamdragon

skye avatar Aug 16 '17 21:08 skye

I had the same issue. How many images do you have in your validation set? I can assume it is just too many. Try to reduce it to 10 or some other reasonable amount (in the config file) and check if it works. Do you actually see images in Tensorboard?

failedmath avatar Aug 18 '17 11:08 failedmath

I have like 63 Images in the validation set and can see the Images in Tensorboard. But it still hangs.

RobinBaumann avatar Aug 18 '17 15:08 RobinBaumann

I would say try with just a couple and see if it works. Or try to run on GPU only eval (this is involves some magic to point not to the last checkpoint)

failedmath avatar Aug 18 '17 20:08 failedmath

By default, the eval script runs forever. You'll need to define max_evals in your eval proto in your train config proto.

Thus, it isn't hanging. It is just continually evaluating images, with sleeps in between. The sleep, by default, is 300 seconds.

You can set shuffle to true in your eval_input_reader if you'd like to see different images on your images tab in tensorboard.

ncaadam avatar Aug 23 '17 19:08 ncaadam

@ncaadam so there is no output during the evaluation? The script ran during my lunch break (which was like 45 mins) and there still was no output. And when I look at some code in the eval_util.py I can see logging information that do not get displayed in my Terminal.

RobinBaumann avatar Aug 29 '17 07:08 RobinBaumann

Have you tried with like 5 images? You have to change eval_config, and see them in Tensorboard. Then wait till the new checkpoint appears. The eval.py takes apriori the last checkpoint in training and then as described before checks every 300 seconds if there is a new model saved. If you run evaluation after the training, it will hang because it will wait for the next checkpoint.

failedmath avatar Aug 29 '17 07:08 failedmath

Oh I understand it now. So I have to run the eval and train parallel to get a continuous evaluation. The problem I have with this, is that my CUDA crashes because it runs out of GPU memory. I have decreased the size of the test from 20% to 5%, but it still crashes.

@failedmath what exactly does the num_examples parameter? Does it randomly pick the specified amount of images from the test.tfrecord? So can I set this parameter to 5 and leave my test set with a value of 20% of the total data set size or do I have to reduce the overall size of my test set?

RobinBaumann avatar Aug 29 '17 08:08 RobinBaumann

@RobinBaumann I run eval on my CPU, so it does not crash. For 10 images the config is:

eval_config: { num_examples: 10 num_visualizations: 10 eval_interval_secs: 120 }

And the tfrecord file should be then created just from 10 images.

failedmath avatar Aug 29 '17 08:08 failedmath

Okay thank you! This approach works for me.

I think it would be useful to add one or two sentences to the documentation or some additional logging information to the evaluation script, just in case someone else struggles on the same problem. I have seen some prior issues that mentioned similar problems.

RobinBaumann avatar Aug 29 '17 09:08 RobinBaumann

@RobinBaumann, Hi, i meet the same problem with you. I download five pictures and save them in directory /models/valimg. And I use the existing faster_r-cnn_resnet101_voc07.config file and only adjusted the paths. Finally, i run python object_detection/eval.py
--logtostderr
--pipeline_config_path=./configfile/faster_rcnn_resnet101_voc07.config
--checkpoint_dir=./faster_rcnn_resnet101_coco_11_06_2017
--eval_dir=./valimg However, I can see some output in directory valimg "-rw-r--r-- 1 joseph joseph 211856 9月 6 10:50 events.out.tfevents.1504666240.ubuntu -rw-r--r-- 1 joseph joseph 297676 9月 6 10:51 events.out.tfevents.1504666266.ubuntu -rw-r--r-- 1 joseph joseph 185722 9月 6 10:51 events.out.tfevents.1504666290.ubuntu -rw-r--r-- 1 joseph joseph 374962 9月 6 10:51 events.out.tfevents.1504666318.ubuntu -rw-r--r-- 1 joseph joseph 233590 9月 6 10:52 events.out.tfevents.1504666342.ubuntu -rw-r--r-- 1 joseph joseph 234716 9月 6 10:52 events.out.tfevents.1504666368.ubuntu -rw-r--r-- 1 joseph joseph 312911 9月 6 10:53 events.out.tfevents.1504666393.ubuntu -rw-r--r-- 1 joseph joseph 399273 9月 6 10:53 events.out.tfevents.1504666421.ubuntu -rw-r--r-- 1 joseph joseph 373139 9月 6 10:54 events.out.tfevents.1504666447.ubuntu -rw-r--r-- 1 joseph joseph 1633 9月 6 10:54 events.out.tfevents.1504666472.ubuntu" but only events.out.tfevents files, so i have to CTRL+C for mAP but nothing else in the other diagramsetc. I try to run tensorboard --logdir =./valimg, it displays nothing. So can you tell me what is wrong with my operation? thank you in advance.

liuqi05 avatar Sep 06 '17 03:09 liuqi05

Why the evaluation scripts doesn't output any information. I find lots of logging statements in the run_checkpoint_once function. Is there any examples about how to caculate roc or map?

auroua avatar Sep 06 '17 08:09 auroua

@liuqi05 I don't know what is wrong with your configuration. Maybe try launching Tensorboard with a full path to your eval_dir?

Also my directory structure looks like this:

+project/

  +data/ (dataset location)

  +models/

    +faster_r-cnn_resnet101/

      +eval/

      +inference/

      +train/

      +pipeline.config

And I launch tensorboard with the following command ( from project directory):

tensorboard --logdir=./models/faster_r-cnn_resnet101/

Maybe you have to set the parent directory of your valimg/ as logdir for Tensorboard?

RobinBaumann avatar Sep 07 '17 06:09 RobinBaumann

@liuqi05 same problem with you for train tensorboard displays output but for eval it displays nothing

liu6381810 avatar Sep 07 '17 09:09 liu6381810

@failedmath

I run eval on my CPU, so it does not crash

How do you restrict it to do that ? 😃

cipri-tom avatar Oct 10 '17 08:10 cipri-tom

@cipri-tom At the beginning of the eval.py script you can set the CUDA_VISIBLE_DEVICES to empty in the following way:

import os
os.environ["CUDA_VISIBLE_DEVICES"]="" 

Then the evaluation will fall back to cpu execution.

josifovski avatar Oct 13 '17 11:10 josifovski

@josifovski obviously! Why did I not think of that? >.< I am using CUDA_VISIBLE_DEVICES to set which GPU to use but I didn't think I could set it to null.

Thank you!

cipri-tom avatar Oct 13 '17 19:10 cipri-tom

Same problem here. Although this could be easily fixed by one line code: logging.basicConfig(level=logging.DEBUG), I suppose Tensorflow people should fix this bug.

ybsave avatar Nov 01 '17 22:11 ybsave

Can someone please explain how to run the evalutation from scratch? I want to find the mAP and IOU for a dataset which I have. The detection are happening fine, but I have no clue for evaluating the model. For now, all I am trying to do is python eval.py --logtostderr --checkpoint_dir=data/model.ckpt-5575 --eval_dir=eval_model/ --pipeline_config_path=data/object-detect.pbtxt

and the object-detect.pbtxt contains

item { id: 1 name: 'ball' }

Can someone please let me know how to do this.?

shreyas0906 avatar Jan 21 '18 07:01 shreyas0906

@shreyas0906 the pipeline_config_path argument you provide is not correct, you shouldn't provide the pbtxt mapping file but the configuration file that you have used for training, e.g. faster_rcnn_inception_resnet_v2_atrous_coco.config from the provided tensorflow/models/research/object_detection/samples/configs which you have adapted for your purposes. Inside in the config file you should adapt the eval_input_reader element such that it shows to the tf record created from the images you want to evaluate.

josifovski avatar Jan 21 '18 09:01 josifovski