models icon indicating copy to clipboard operation
models copied to clipboard

tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: data/Obj_det.pbtxt : The system cannot find the file specified.

Open Pices-26 opened this issue 7 years ago • 35 comments

Few things before the start Yes, protobuf was compiled. I ran the basic object_detection model test no problem. That input_reader_pb2 is there along with every other file I made a live camera feed with this object_detection When I try to run model_test_builder in object_detection\builders I get this issue

D:\python_ver\python364\Lib\site-packages\object_detection\builders>python model_builder_test.py Traceback (most recent call last): File "model_builder_test.py", line 23, in from object_detection.builders import model_builder File "D:\python_ver\python364\lib\site-packages\object_detection\builders\model_builder.py", line 20, in from object_detection.builders import anchor_generator_builder File "D:\python_ver\python364\lib\site-packages\object_detection\builders\anchor_generator_builder.py", line 21, in from object_detection.protos import anchor_generator_pb2 ImportError: cannot import name 'anchor_generator_pb2'

This means that protobuf wasn't installed fully correctly which might lead to my main issue down below. But everything was done including exports of path and compilation. I've been on this 2 whole days now. Maybe someone knows the answer. Thank you

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Win10
  • TensorFlow installed from (source or binary): Binary
  • TensorFlow version (use command below): 1.13.1
  • GPU model and memory: no gpu
  • Exact command to reproduce: python legacy/train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config

TF version: 1.13.1 Python Version: 3.6.4 protoc version: 3.4

Source code / logs

D:\python_ver\python364\Lib\site-packages\tensorflow\models-master\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config Traceback (most recent call last): File "train.py", line 49, in from object_detection.builders import dataset_builder File "D:\python_ver\python364\lib\site-packages\object_detection\builders\dataset_builder.py", line 27, in from object_detection.data_decoders import tf_example_decoder File "D:\python_ver\python364\lib\site-packages\object_detection\data_decoders\tf_example_decoder.py", line 24, in from object_detection.protos import input_reader_pb2 ImportError: cannot import name 'input_reader_pb2'

Pices-26 avatar Apr 17 '19 13:04 Pices-26

I've used this command and got no errors. It was ran from research folder C:\Users\User\Downloads\protoc\bin\protoc object_detection/protos/*.proto --python_out=.

Pices-26 avatar Apr 17 '19 13:04 Pices-26

cd research folder and run this

protoc --python_out=. .\object_detection\protos\input_reader.proto python setup.py build python setup.py install

merts1 avatar Apr 17 '19 17:04 merts1

cd research folder and run this

protoc --python_out=. .\object_detection\protos\input_reader.proto python setup.py build python setup.py install

this is what I'm getting now

Traceback (most recent call last): File "model_builder.py", line 35, in from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "D:\python_ver\python364\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'

Pices-26 avatar Apr 17 '19 17:04 Pices-26

cd research folder and run this protoc --python_out=. .\object_detection\protos\input_reader.proto python setup.py build python setup.py install

this is what I'm getting now

Traceback (most recent call last): File "model_builder.py", line 35, in from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "D:\python_ver\python364\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'

you didn't set the paths correctly do the following

set PYTHONPATH=%PYTHONPATH%;[PATH TO RESEARCH FOLDER] set PYTHONPATH=%PYTHONPATH%;[PATH TO SLIM FOLDER INSIDE THE RESEARCH FOLDER]

merts1 avatar Apr 17 '19 17:04 merts1

did it work?

merts1 avatar Apr 17 '19 18:04 merts1

My model test has worked, my live object detection works too. But that's a preset model. Tomorrow I will train my own model and see how it will work. I'll update you. Other than that, thank you so much. Do I have to set this path every time I do something in a different directory location? Also I'm using pycharm combined with just console. Do you think it's a good idea or should I move over to conda? or just linux all together?

Pices-26 avatar Apr 17 '19 21:04 Pices-26

yes you have to set it every time, or you can simply move nets folder to current directory but setting pythonpath is much more useful in many ways. i have never used pycharm for object detection, i’m using conda and it’s very useful imo but just stay with the one you’re comfortable

merts1 avatar Apr 17 '19 21:04 merts1

I've used this line python legacy/train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config

and got this

Traceback (most recent call last): File "legacy/train.py", line 184, in tf.app.run() File "D:\python_ver\python364\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv)) File "D:\python_ver\python364\lib\site-packages\tensorflow\python\util\deprecation.py", line 324, in new_func return func(*args, **kwargs) File "legacy/train.py", line 180, in main graph_hook_fn=graph_rewriter_fn) File "D:\python_ver\python364\Lib\site-packages\tensorflow\models\research\object_detection\legacy\trainer.py", line 280, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "D:\python_ver\python364\Lib\site-packages\tensorflow\models\research\object_detection\legacy\trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "legacy/train.py", line 121, in get_next dataset_builder.build(config)).get_next() File "D:\python_ver\python364\Lib\site-packages\tensorflow\models\research\object_detection\builders\dataset_builder.py", line 124, in build num_additional_channels=input_reader_config.num_additional_channels) File "D:\python_ver\python364\Lib\site-packages\tensorflow\models\research\object_detection\data_decoders\tf_example_decoder.py", line 307, in init default_value=''), File "D:\python_ver\python364\Lib\site-packages\tensorflow\models\research\object_detection\data_decoders\tf_example_decoder.py", line 59, in init label_map_proto_file, use_display_name=False) File "D:\python_ver\python364\Lib\site-packages\tensorflow\models\research\object_detection\utils\label_map_util.py", line 164, in get_label_map_dict label_map = load_labelmap(label_map_path) File "D:\python_ver\python364\Lib\site-packages\tensorflow\models\research\object_detection\utils\label_map_util.py", line 133, in load_labelmap label_map_string = fid.read() File "D:\python_ver\python364\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 125, in read self._preread_check() File "D:\python_ver\python364\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 85, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "D:\python_ver\python364\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 528, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: data/Obj_det.pbtxt : The system cannot find the file specified. ; No such file or directory

I know for a fact that this file is inside of data. data folder is in the directory that I'm running the command from. It looks like my path is set incorrectly. Is it something to do with pointing it not at set PYTHONPATH=%PYTHONPATH%;[PATH TO RESEARCH FOLDER] set PYTHONPATH=%PYTHONPATH%;[PATH TO SLIM FOLDER INSIDE THE RESEARCH FOLDER] ?

Pices-26 avatar Apr 19 '19 17:04 Pices-26

label_map_path: "data/Obj_det.pbtxt" this is my path in the config file

Pices-26 avatar Apr 19 '19 17:04 Pices-26

How much disk memory would I need for like 150 photos?

I've got 140gb on D and 40gb on C. Some people say it might be linked to memory

Pices-26 avatar Apr 19 '19 18:04 Pices-26

Hi! Please i cant write good code for model_main.py will run sucsessfully in colab google. I cheked with !ls => model_main.py

!export PYTHONPATH=$PYTHONPATH:/content/gdrive/My Drive/colab_data/models/research/object_detection:/content/gdrive/My Drive/colab_data/models/research/object_detection/slim python content/gdrive/My Drive/colab_data/models/research/object_detection/model_main.py \ --pipeline_config_path=object_detection/my_data/pipeline.config \ --model_dir=object_detection/my_data/output \ --num_train_steps=1000 \ --alsologtostderr

/bin/bash: /content/gdrive/My: No such file or directory /bin/bash: /content/gdrive/My: No such file or directory /bin/bash: line 0: export: content/gdrive/My': not a valid identifier /bin/bash: line 0: export: Drive/colab_data/models/research/object_detection/model_main.py': not a valid identifier /bin/bash: line 0: export: --pipeline_config_path=object_detection/my_data/pipeline.config': not a valid identifier /bin/bash: line 0: export: --model_dir=object_detection/my_data/output': not a valid identifier /bin/bash: line 0: export: --num_train_steps=1000': not a valid identifier /bin/bash: line 0: export: --alsologtostderr': not a valid identifier

mihuzz avatar Apr 20 '19 10:04 mihuzz

setting a pythonpath does not change your current working directory, it just enables libraries in that direction for you to use them without moving them to working directory. the reason why you’re getting such error is probably because you haven’t edit the paths correctly in the contig file according to current directory. i can’t know how did you configure the folders but i can say that it has nothing to do with memory issue

merts1 avatar Apr 20 '19 10:04 merts1

setting a pythonpath does not change your current working directory, it just enables libraries in that direction for you to use them without moving them to working directory. the reason why you’re getting such error is probably because you haven’t edit the paths correctly in the contig file according to current directory. i can’t know how did you configure the folders but i can say that it has nothing to do with memory issue fine_tune_checkpoint: "/content/gdrive/My Drive/colab_data/models/research/object_detection/ssd_mobilenet_v1_coco_2018_01_28/model.ckpt" from_detection_checkpoint: true num_steps: 20000 } train_input_reader { label_map_path: "/content/gdrive/My Drive/colab_data/models/research/object_detection/my_data/32classes_label_map.pbtxt" tf_record_input_reader { input_path: "/content/gdrive/My Drive/colab_data/models/research/object_detection/my_data/train_data.record" } } eval_config { num_examples: 4280 max_evals: 10 use_moving_averages: false } eval_input_reader { label_map_path: "/content/gdrive/My Drive/colab_data/models/research/object_detection/my_data/32classes_label_map.pbtxt" shuffle: false num_readers: 1 tf_record_input_reader { input_path: "/content/gdrive/My Drive/colab_data/models/research/object_detection/my_data/test_data.record" } }

mihuzz avatar Apr 20 '19 11:04 mihuzz

my paths are set correctly. The file is there and it's contents are what they are meant to be.

train_config: { batch_size: 1 optimizer { rms_prop_optimizer: { learning_rate: { exponential_decay_learning_rate { initial_learning_rate: 0.004 decay_steps: 800720 decay_factor: 0.95 } } momentum_optimizer_value: 0.9 decay: 0.9 epsilon: 1.0 } } fine_tune_checkpoint: "ssd_mobilenet_v1_coco_2017_11_17/model.ckpt" from_detection_checkpoint: true load_all_detection_checkpoint_vars: true

Note: The below line limits the training process to 200K steps, which we

empirically found to be sufficient enough to train the pets dataset. This

effectively bypasses the learning rate schedule (the learning rate will

never decay). Remove the below line to train indefinitely.

num_steps: 200000 data_augmentation_options { random_horizontal_flip { } } data_augmentation_options { ssd_random_crop { } } }

train_input_reader: { tf_record_input_reader { input_path: "data/train.record" } label_map_path: "data/Obj_det.pbtxt" }

eval_config: { metrics_set: "coco_detection_metrics" num_examples: 1100 }

eval_input_reader: { tf_record_input_reader { input_path: "data/test.record" } label_map_path: "data/Obj_det.pbtxt" shuffle: false num_readers: 1 }

Pices-26 avatar Apr 20 '19 21:04 Pices-26

can you change the name of obj_det file to maplabel and the path to data/maplabel.pbtxt for both rows in the config file

merts1 avatar Apr 20 '19 21:04 merts1

same error at the end tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: data/maplabel.pbtxt : The system cannot find the file specified. ; No such file or directory

Pices-26 avatar Apr 20 '19 23:04 Pices-26

Would I have to update?

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see:

  • https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  • https://github.com/tensorflow/addons If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From D:\python_ver\python364\lib\site-packages\tensorflow\python\platform\app.py:125: main (from main) is deprecated and will be removed in a future version. Instructions for updating: Use object_detection/model_main.py. WARNING:tensorflow:From D:\python_ver\python364\Lib\site-packages\tensorflow\models\research\object_detection\legacy\trainer.py:266: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version. Instructions for updating: Please switch to tf.train.create_global_step WARNING:tensorflow:From D:\python_ver\python364\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version. Instructions for updating:

Pices-26 avatar Apr 21 '19 00:04 Pices-26

I have the exact same problem, any solutions yet?

Gerahal avatar Apr 22 '19 07:04 Gerahal

can you upload your config file

merts1 avatar Apr 22 '19 07:04 merts1

Here is my config file:

# Faster R-CNN with Inception v2, configured for Oxford-IIIT Pets Dataset.
# Users should configure the fine_tune_checkpoint field in the train config as
# well as the label_map_path and input_path fields in the train_input_reader and
# eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that
# should be configured.

model {
  faster_rcnn {
    num_classes: 2
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 600
        max_dimension: 1024
      }
    }
    feature_extractor {
      type: 'faster_rcnn_inception_v2'
      first_stage_features_stride: 16
    }
    first_stage_anchor_generator {
      grid_anchor_generator {
        scales: [0.25, 0.5, 1.0, 2.0]
        aspect_ratios: [0.5, 1.0, 2.0]
        height_stride: 16
        width_stride: 16
      }
    }
    first_stage_box_predictor_conv_hyperparams {
      op: CONV
      regularizer {
        l2_regularizer {
          weight: 0.0
        }
      }
      initializer {
        truncated_normal_initializer {
          stddev: 0.01
        }
      }
    }
    first_stage_nms_score_threshold: 0.0
    first_stage_nms_iou_threshold: 0.7
    first_stage_max_proposals: 300
    first_stage_localization_loss_weight: 2.0
    first_stage_objectness_loss_weight: 1.0
    initial_crop_size: 14
    maxpool_kernel_size: 2
    maxpool_stride: 2
    second_stage_box_predictor {
      mask_rcnn_box_predictor {
        use_dropout: false
        dropout_keep_probability: 1.0
        fc_hyperparams {
          op: FC
          regularizer {
            l2_regularizer {
              weight: 0.0
            }
          }
          initializer {
            variance_scaling_initializer {
              factor: 1.0
              uniform: true
              mode: FAN_AVG
            }
          }
        }
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.0
        iou_threshold: 0.6
        max_detections_per_class: 100
        max_total_detections: 300
      }
      score_converter: SOFTMAX
    }
    second_stage_localization_loss_weight: 2.0
    second_stage_classification_loss_weight: 1.0
  }
}

train_config: {
  batch_size: 32
  optimizer {
    momentum_optimizer: {
      learning_rate: {
        manual_step_learning_rate {
          initial_learning_rate: 0.0002
          schedule {
            step: 900000
            learning_rate: .00002
          }
          schedule {
            step: 1200000
            learning_rate: .000002
          }
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint: "faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: true
  # Note: The below line limits the training process to 200K steps, which we
  # empirically found to be sufficient enough to train the pets dataset. This
  # effectively bypasses the learning rate schedule (the learning rate will
  # never decay). Remove the below line to train indefinitely.
  num_steps: 200000
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
}


train_input_reader: {
  tf_record_input_reader {
    input_path: "data\train.record-?????-of-00010"
  }
  label_map_path: "data\objectdetection.pbtxt"
}

eval_config: {
  metrics_set: "coco_detection_metrics"
  num_examples: 1101
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "data\test.record-?????-of-00010"
  }
  label_map_path: "data\objectdetection.pbtxt"
  shuffle: false
  num_readers: 1
}

Gerahal avatar Apr 22 '19 07:04 Gerahal