我正在尝试使用model_main.py文件训练对象检测模型。我可以毫无问题地在ubuntu环境中进行训练,但是现在赢得了10的冠军(因为我的PC上装有GeForece 1080Ti),现在遇到了麻烦。训练可以开始,并且效果很好,直到出现这些错误的第一个检查点为止(我也可以重新启动,并且它从上一个检查点开始连续训练,但是在保存下一个检查点之后再次失败...):
因此从... \ models-master \ research \ object_detection文件夹运行此命令
python model_main.py --model_dir=training --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config -–num_train_steps=20000 --sample_1_of_n_eval_examples=2 --alsologtostderr
产生此:
INFO:tensorflow:将46040的检查点保存到training \ model.ckpt中。I0307 10:01:21.055022 8112 basic_session_run_hooks.py:606]将46040的检查点保存到training \ model.ckpt中。警告:tensorflow:来自C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ training \ saver.py:960:remove_checkpoint(来自tensorflow.python.training.checkpoint_management)已被弃用将在以后的版本中删除。更新说明:使用标准文件API删除具有此前缀的文件。W0307 10:01:22.363223 8112 deprecation.py:323]来自C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ training \ saver.py:960:remove_checkpoint(来自tensorflow。 python.training.checkpoint_management)已过时,并将在以后的版本中删除。更新说明:使用标准文件API删除具有此前缀的文件。Windows致命异常:访问冲突
线程0x000023b4(最近调用优先):文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ threading.py”,在等待的第296行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ queue.py”,第170行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ summary \ writer \ event_file_writer.py”,运行中的第159行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ threading.py”,_ bootstrap_inner中的第926行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ threading.py”,_ bootstrap中的第890行
当前线程0x00001fb0(最近调用优先):文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ lib \ io \ file_io.py”,_ preread_check中的第84行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ lib \ io \ file_io.py”,读入第122行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ object_detection-0.1-py3.7.egg \ object_detection \ utils \ label_map_util.py”,load_labelmap中的第139行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ object_detection-0.1-py3.7.egg \ object_detection \ utils \ label_map_util.py”,get_label_map_dict中的第172行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ object_detection-0.1-py3.7.egg \ object_detection \ data_decoders \ tf_example_decoder.py”,init中的第64行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ object_detection-0.1-py3.7.egg \ object_detection \ data_decoders \ tf_example_decoder.py”,init中的第319行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ object_detection-0.1-py3.7.egg \ object_detection \ builders \ dataset_builder.py”,版本130文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ object_detection-0.1-py3.7.egg \ object_detection \ inputs.py”,eval_input中的第725行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ object_detection-0.1-py3.7.egg \ object_detection \ inputs.py”,_ eval_input_fn中的第625行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,_ call_input_fn中的1113行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,_ get_features_and_labels_from_input_fn中的第1022行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,_ call_model_fn_eval中的第1534行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,_ evaluate_build_graph中的第1501行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,_ evaluate中的第501行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,_ actual_eval中的第519行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,求值行477文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ training.py”,evaluate_and_export中的920行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ training.py”,_ evaluate中的第539行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ training.py”,after_save中的第519行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ training \ basic_session_run_hooks.py”,_ save中的第619行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ training \ basic_session_run_hooks.py”,after_run中的第594行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py”,运行中的第1419行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py”,运行中的第1338行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py”,运行中的第1252行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py”,运行中的第754行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,_ train_with_estimator_spec中的第1484行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”,_ train_model_default中的第1192行_train_model中的第1158行的文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”火车上的第367行“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ estimator.py”文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ training.py”,在run_local的第714行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ training.py”,运行第613行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow_estimator \ python \ estimator \ training.py”,train_and_evaluate中的第473行文件“ model_main.py”,主行中的第109行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ absl \ app.py”,_ run_main中的第250行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ absl \ app.py”,运行中的第299行文件“ C:\ Users \ Zsetszko21 \ Anaconda3 \ envs \ tf_env_Ti \ lib \ site-packages \ tensorflow \ python \ platform \ app.py”,运行第40行文件“ model_main.py”,位于第113行(tf_env_Ti)PS A:\ PPEVision \ trainer \ models-master \ research \ object_detection>
我的配置文件:
# 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: true
dropout_keep_probability: 0.95
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: 1
optimizer {
momentum_optimizer: {
learning_rate: {
exponential_decay_learning_rate {
initial_learning_rate: 0.00200000018999
decay_steps: 1000
decay_factor: 0.989999988079
}
#manual_step_learning_rate {
# initial_learning_rate: 0.0002
# schedule {
# step: 100000
# learning_rate: .002
# }
#}
}
momentum_optimizer_value: 0.9
}
use_moving_average: false
}
gradient_clipping_by_norm: 10.0
fine_tune_checkpoint: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\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: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\train.record"
}
label_map_path: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\training\\labelmap.pbtxt"
}
eval_config: {
metrics_set: "coco_detection_metrics"
num_examples: 1000
num_visualizations: 1000
visualization_export_dir: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\eval"
eval_interval_secs: 120
}
eval_input_reader: {
tf_record_input_reader {
input_path: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\test.record"
}
label_map_path: "A:\\PPEVision\\trainer\\models-master\\research\\object_detection\\labelmap.pbtxt"
shuffle: true
num_readers: 1
}
我还添加了以下几行以防止对model_main.py进行任何OOM:
session_config = tf.ConfigProto()
session_config.gpu_options.per_process_gpu_memory_fraction = 0.7 # replace this field with whichever real number you prefer
# also gives a workaround to specify RAM usage
config = tf.estimator.RunConfig(model_dir=FLAGS.model_dir, session_config=session_config)
我的规格:
Win10Geforce GTX 1080Ti 11Gb32Gb RAMi5-7500 3Ghz CPU使用conda env创建的Tensorflow 1.14-gpu+ ------------------------------------------------- ---------------------------- +| NVIDIA-SMI 442.50驱动程序版本:442.50 CUDA版本:10.2 || ------------------------------- + ----------------- ----- + ---------------------- +| GPU名称TCC / WDDM |巴士编号显示A |挥发性不佳。 ECC ||风扇温度性能:用法/上限|内存使用| GPU实用计算M。| =============================== + ================= ===== + ==================== || 0 GeForce GTX 108 ... WDDM | 00000000:01:00.0开| N / A || 23%36C P8 13W / 250W | 449MiB / 11264MiB | 0%默认|+ ------------------------------- + ----------------- ----- + ---------------------- +
我有类似的问题,看来我不得不用label_map.pbtxt.txt代替label_map.pbtxt。另外,也许用\代替\。