+ 2021.02.16

오는길에 다시 보니 tensorflow model garden / research / object detection 에서 구현된

내용들이지 엄밀하게는 tensorflow 자체의 구현은 아니다.

tensorflow를 가지고 구현한 내용이라고 해야하려나?

-

 

model ssd

type ssd_mobilenet_v2_keras 를

ssd_mobilenet_v2 로 바꾸었더니 아래와 같은 에러가 발생했다.

 

INFO:tensorflow:Maybe overwriting train_steps: 1
I0212 20:50:37.009305 140651210348352 config_util.py:552] Maybe overwriting train_steps: 1
INFO:tensorflow:Maybe overwriting use_bfloat16: False
I0212 20:50:37.009468 140651210348352 config_util.py:552] Maybe overwriting use_bfloat16: False
Traceback (most recent call last):
  File "model_main_tf2.py", line 113, in <module>
    tf.compat.v1.app.run()
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/home/minimonk/.local/lib/python3.8/site-packages/absl/app.py", line 303, in run
    _run_main(main, args)
  File "/home/minimonk/.local/lib/python3.8/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "model_main_tf2.py", line 104, in main
    model_lib_v2.train_loop(
  File "/home/minimonk/src/SSD-MobileNet-TF/object_detection/model_lib_v2.py", line 507, in train_loop
    detection_model = MODEL_BUILD_UTIL_MAP['detection_model_fn_base'](
  File "/home/minimonk/src/SSD-MobileNet-TF/object_detection/builders/model_builder.py", line 1106, in build
    return build_func(getattr(model_config, meta_architecture), is_training,
  File "/home/minimonk/src/SSD-MobileNet-TF/object_detection/builders/model_builder.py", line 377, in _build_ssd_model
    _check_feature_extractor_exists(ssd_config.feature_extractor.type)
  File "/home/minimonk/src/SSD-MobileNet-TF/object_detection/builders/model_builder.py", line 249, in _check_feature_extractor_exists
    raise ValueError('{} is not supported. See `model_builder.py` for features '
ValueError: ssd_mobilenet_v2 is not supported. See `model_builder.py` for features extractors compatible with different versions of Tensorflow

 

model_builder.py를 열어보라는데 여러개 파일이 나타난다.?

$ sudo find / -name model_builder.py
/home/minimonk/src/SSD-MobileNet-TF/object_detection/builders/model_builder.py
/home/minimonk/src/SSD-MobileNet-TF/models/research/object_detection/builders/model_builder.py
/home/minimonk/src/SSD-MobileNet-TF/models/research/lstm_object_detection/model_builder.py
/home/minimonk/src/SSD-MobileNet-TF/build/lib/object_detection/builders/model_builder.py

 

lstm 어쩌구를 제외하면 용량이 동일하니 같은 파일로 간주하고 하나를 열어보니 다음과 같이 나오는데..

if tf_version.is_tf2() 에 의해서 사용가능한 녀석은.. 

ssd_mobilenet_v2_fpn_keras 와

ssd_mobilenet_v2_keras 뿐이다 -_-

기대했던 ssd_mobilenet_v2는  tf1 ㅠㅠ

$ vi /home/minimonk/src/SSD-MobileNet-TF/object_detection/builders/model_builder.py
if tf_version.is_tf2():
  from object_detection.models import center_net_hourglass_feature_extractor
  from object_detection.models import center_net_mobilenet_v2_feature_extractor
  from object_detection.models import center_net_mobilenet_v2_fpn_feature_extractor
  from object_detection.models import center_net_resnet_feature_extractor
  from object_detection.models import center_net_resnet_v1_fpn_feature_extractor
  from object_detection.models import faster_rcnn_inception_resnet_v2_keras_feature_extractor as frcnn_inc_res_keras
  from object_detection.models import faster_rcnn_resnet_keras_feature_extractor as frcnn_resnet_keras
  from object_detection.models import ssd_resnet_v1_fpn_keras_feature_extractor as ssd_resnet_v1_fpn_keras
  from object_detection.models import faster_rcnn_resnet_v1_fpn_keras_feature_extractor as frcnn_resnet_fpn_keras
  from object_detection.models.ssd_mobilenet_v1_fpn_keras_feature_extractor import SSDMobileNetV1FpnKerasFeatureExtractor
  from object_detection.models.ssd_mobilenet_v1_keras_feature_extractor import SSDMobileNetV1KerasFeatureExtractor
  from object_detection.models.ssd_mobilenet_v2_fpn_keras_feature_extractor import SSDMobileNetV2FpnKerasFeatureExtractor
  from object_detection.models.ssd_mobilenet_v2_keras_feature_extractor import SSDMobileNetV2KerasFeatureExtractor
  from object_detection.predictors import rfcn_keras_box_predictor
  if sys.version_info[0] >= 3:
    from object_detection.models import ssd_efficientnet_bifpn_feature_extractor as ssd_efficientnet_bifpn

if tf_version.is_tf1():
  from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
  from object_detection.models import faster_rcnn_inception_v2_feature_extractor as frcnn_inc_v2
  from object_detection.models import faster_rcnn_nas_feature_extractor as frcnn_nas
  from object_detection.models import faster_rcnn_pnas_feature_extractor as frcnn_pnas
  from object_detection.models import faster_rcnn_resnet_v1_feature_extractor as frcnn_resnet_v1
  from object_detection.models import ssd_resnet_v1_fpn_feature_extractor as ssd_resnet_v1_fpn
  from object_detection.models import ssd_resnet_v1_ppn_feature_extractor as ssd_resnet_v1_ppn
  from object_detection.models.embedded_ssd_mobilenet_v1_feature_extractor import EmbeddedSSDMobileNetV1FeatureExtractor
  from object_detection.models.ssd_inception_v2_feature_extractor import SSDInceptionV2FeatureExtractor
  from object_detection.models.ssd_mobilenet_v2_fpn_feature_extractor import SSDMobileNetV2FpnFeatureExtractor
  from object_detection.models.ssd_mobilenet_v2_mnasfpn_feature_extractor import SSDMobileNetV2MnasFPNFeatureExtractor
  from object_detection.models.ssd_inception_v3_feature_extractor import SSDInceptionV3FeatureExtractor
  from object_detection.models.ssd_mobilenet_edgetpu_feature_extractor import SSDMobileNetEdgeTPUFeatureExtractor
  from object_detection.models.ssd_mobilenet_v1_feature_extractor import SSDMobileNetV1FeatureExtractor
  from object_detection.models.ssd_mobilenet_v1_fpn_feature_extractor import SSDMobileNetV1FpnFeatureExtractor
  from object_detection.models.ssd_mobilenet_v1_ppn_feature_extractor import SSDMobileNetV1PpnFeatureExtractor
  from object_detection.models.ssd_mobilenet_v2_feature_extractor import SSDMobileNetV2FeatureExtractor
  from object_detection.models.ssd_mobilenet_v3_feature_extractor import SSDMobileNetV3LargeFeatureExtractor
  from object_detection.models.ssd_mobilenet_v3_feature_extractor import SSDMobileNetV3SmallFeatureExtractor
  from object_detection.models.ssd_mobiledet_feature_extractor import SSDMobileDetCPUFeatureExtractor
  from object_detection.models.ssd_mobiledet_feature_extractor import SSDMobileDetDSPFeatureExtractor
  from object_detection.models.ssd_mobiledet_feature_extractor import SSDMobileDetEdgeTPUFeatureExtractor
  from object_detection.models.ssd_mobiledet_feature_extractor import SSDMobileDetGPUFeatureExtractor
  from object_detection.models.ssd_pnasnet_feature_extractor import SSDPNASNetFeatureExtractor
  from object_detection.predictors import rfcn_box_predictor

 

[링크 : https://stackoverflow.com/questions/65938445/]

 

+

와.. ssd_mobilenet_v2_fpn_keras를 돌리는데 메모리 부족으로 죽어버리네 ㄷㄷ

눈에 보이는건.. additional_layer_depth 인가.. 이걸 줄이고 해봐야 겠네..

    feature_extractor {
      type: 'ssd_mobilenet_v2_fpn_keras'
      use_depthwise: true
      fpn {
        min_level: 3
        max_level: 7
        additional_layer_depth: 128
      }
      min_depth: 16
      depth_multiplier: 1.0
      conv_hyperparams {
        activation: RELU_6,
        regularizer {
          l2_regularizer {
            weight: 0.00004
          }
        }
        initializer {
          random_normal_initializer {
            stddev: 0.01
            mean: 0.0
          }
        }
        batch_norm {
          scale: true,
          decay: 0.997,
          epsilon: 0.001,
        }
      }
      override_base_feature_extractor_hyperparams: true
    }

 

/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/python/keras/backend.py:434: UserWarning: `tf.keras.backend.set_learning_phase` is deprecated and will be removed after 2020-10-11. To update it, simply pass a True/False value to the `training` argument of the `__call__` method of your layer or model.
  warnings.warn('`tf.keras.backend.set_learning_phase` is deprecated and '
2021-02-12 21:23:47.163320: W tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 1258291200 exceeds 10% of free system memory.
죽었음

 

+

depth를 줄이고 해보니 되는척 하다가 또 에러가 발생 ㅋㅋ

    ValueError: Number of feature maps is expected to equal the length of `num_anchors_per_location`.

 

되는 척 하더니 안되네? ㅠㅠ

AssertionError: Some Python objects were not bound to checkpointed values, likely due to changes in the Python program: [MirroredVariable:{
  0: <tf.Variable 'block_8_depthwise/depthwise_kernel:0' shape=(3, 3, 384, 1) dtype=float32, numpy=

...

WARNING:tensorflow:A checkpoint was restored (e.g. tf.train.Checkpoint.restore or tf.keras.Model.load_weights) but not all checkpointed values were used. See above for specific issues. Use expect_partial() on the load status object, e.g. tf.train.Checkpoint.restore(...).expect_partial(), to silence these warnings, or use assert_consumed() to make the check explicit. See https://www.tensorflow.org/guide/checkpoint#loading_mechanics for details.
W0212 21:37:27.939997 140162079770432 util.py:168] A checkpoint was restored (e.g. tf.train.Checkpoint.restore or tf.keras.Model.load_weights) but not all checkpointed values were used. See above for specific issues. Use expect_partial() on the load status object, e.g. tf.train.Checkpoint.restore(...).expect_partial(), to silence these warnings, or use assert_consumed() to make the check explicit. See https://www.tensorflow.org/guide/checkpoint#loading_mechanics for details.

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

tensorflow model 학습 시작지점  (0) 2021.02.18
tensorflow tag set 'serve'  (0) 2021.02.18
fpn - Feature Pyramid Network  (0) 2021.02.11
tensorflow pipeline.config  (0) 2021.02.10
tensorflow pipeline.conf  (0) 2021.02.08
Posted by 구차니