공식적으로 정리된 용어집이 없냐!!!!

 

모델은 텐서가 먼가를 연산하는 함수 기능?

A model is, abstractly:

A function that computes something on tensors (a forward pass) Some variables that can be updated in response to training

[링크 : http://www.tensorflow.org/guide/intro_to_graphs]

 

그래프는 tf.Operation 객체의 집합을 포함하는 데이터 구조

Graphs are data structures that contain a set of tf.Operation objects, which represent units of computation; and tf.Tensor objects, which represent the units of data that flow between operations

[링크 : http://www.tensorflow.org/guide/intro_to_modules]

 

체크포인트는 모델에 의해서 사용되는 모든 패러미터의 정확한 값을 캡쳐한다.

Checkpoints capture the exact value of all parameters (tf.Variable objects) used by a model. Checkpoints do not contain any description of the computation defined by the model and thus are typically only useful when source code that will use the saved parameter values is available.

[링크 : http://www.tensorflow.org/guide/checkpoint]

[링크 : http://www.tensorflow.org/guide/saved_model]

 

 

Posted by 구차니

계속 tflite_convert 만 사용했는데 export_Tflite_graph_tf2.py 라는 다른 녀석을 발견했다.

ssd mobilenetv2를 주로 사용했었으니 이걸로 tflite 변환이 잘되면 좋겠네 ㅠㅠ

 

NOTE: This only supports SSD meta-architectures for now.

[링크 : http://github.com/tensorflow/models/blob/master/research/object_detection/export_tflite_graph_tf2.py]

[링크 : http://github.com/tensorflow/models/issues/9371]

 

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

ssd model convert for tflite  (0) 2021.02.26
tensorflow 용어 정의  (0) 2021.02.25
tensorflow flex ops  (0) 2021.02.23
tensorflow 1.15 설치가 힘들군  (0) 2021.02.22
tensorflow2 학습 해보기 어렵네..  (0) 2021.02.20
Posted by 구차니

flex ops라는 말이 많이 나와서 도대체 멀까 정의를 찾아보는데 공식적인 문서는 발견하지 못했지만..

select 텐서플로우 ops를 텐서플로우 라이트에서 사용하는 내부 코드의 명칭

이라고 하니 더 이해가 안되네?

 

"Flex" is the internal code name for the "Using TensorFlow Lite with select TensorFlow ops" feature.

[링크 : http://stackoverflow.com/questions/53824223/what-does-flex-op-mean-in-tensorflow]

[링크 : https://www.tensorflow.org/lite/guide/ops_select]

 

+

[링크 : https://github.com/tensorflow/tensorflow/issues/45875]

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

tensorflow 용어 정의  (0) 2021.02.25
tflite convert  (0) 2021.02.24
tensorflow 1.15 설치가 힘들군  (0) 2021.02.22
tensorflow2 학습 해보기 어렵네..  (0) 2021.02.20
tensorflow 객체 탐지 디렉토리 구조  (0) 2021.02.19
Posted by 구차니

 

$ python3
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

 

$ pip3 install tensorflow==1.15.5
ERROR: Could not find a version that satisfies the requirement tensorflow==1.15.5 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.2.2, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1, 2.3.2, 2.4.0rc0, 2.4.0rc1, 2.4.0rc2, 2.4.0rc3, 2.4.0rc4, 2.4.0, 2.4.1)
ERROR: No matching distribution found for tensorflow==1.15.5

[링크 : https://pypi.org/project/tensorflow/1.15.5/]

 

[링크 : https://stackoverflow.com/questions/61491893/i-cannot-install-tensorflow-version-1-15-through-pip]

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

tflite convert  (0) 2021.02.24
tensorflow flex ops  (0) 2021.02.23
tensorflow2 학습 해보기 어렵네..  (0) 2021.02.20
tensorflow 객체 탐지 디렉토리 구조  (0) 2021.02.19
tensorflow model 학습 시작지점  (0) 2021.02.18
Posted by 구차니

아주 에러가 에러에 에러를 무는구만...

 

ModuleNotFoundError: No module named 'official'

pip3 install tf-models-official

[링크 : https://github.com/tensorflow/models/issues/8291]

 

from object_detection.protos import string_int_label_map_pb2 ImportError: cannot import name 'string_int_label_map_pb2' 

sudo apt-get install protobuf-compiler

protoc object_detection/protos/*.proto --python_out=.

[링크 : https://github.com/tensorflow/models/issues/7877]

 

tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for checkpoint/mobilenet_v2.ckpt-1

[링크 : https://github.com/bourdakos1/Custom-Object-Detection/issues/11]

[링크 : https://github.com/tensorflow/models/issues/2676]

 

일단은 기존의 체크포인트가 있는건가 싶어서 아래의 경로에서 학습된걸 받고

config에서 300 300인걸 320 320으로 수정하고 아래와 같이 ckpt-0.data 식으로 되어 있어서 ckpt-0만 입력해주니 일단 넘어간다.

train_config: {
  fine_tune_checkpoint_version: V2
  fine_tune_checkpoint: "checkpoint/ckpt-0"
  fine_tune_checkpoint_type: "classification"

[링크 : http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_mobilenet_v2_320x320_coco17_tpu-8.tar.gz]

 

tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 629145600 exceeds 10% of free system memory.

config 파일에서 찾아보니 train_config에 batch_size가 좀 큰 듯?

train_config: {
  fine_tune_checkpoint_version: V2
  fine_tune_checkpoint: "aimd/checkpoint/ckpt-0"
  fine_tune_checkpoint_type: "classification"
  batch_size: 512

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

 

AssertionError: Some Python objects were not bound to checkpointed values, likely due to changes in the Python program: [SyncOnReadVariable:{
  0: <tf.Variable 'block_6_expand_BN/moving_variance:0' shape=(192,) dtype=float32, numpy=

아니. 제공된 건데 왜 detection이 아니고 classification으로 되어 있는거야?

# fine_tune_checkpoint_type: "classification"

fine_tune_checkpoint_type: "detection"

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

 

 

ValueError: Cannot assign to variable BoxPredictor/ConvolutionalClassHead_0/ClassPredictor/bias:0 due to variable shape (6,) and value shape (273,) are incompatible

원래 학습된게 90개를 구분하도록 된 녀석인데 강제로 숫자를 바꾸어 주었더니(90->1) 저렇게 에러가 난듯.

대충 (1+1)*3 과 (90+1)*3 을 해보면 맞는 수치인 것 같은데..

[링크 : https://eehoeskrap.tistory.com/368]

 

i5-2520m 에서 1번의 train/ 1번의 eval을 하도록 설정하였는데

train 880 여개 eval 220  여개 인데 나름 1분 30초면 빠른건가? (쌩 cpu 만으로 하는데)

2021. 02. 20. (토) 23:47:07 KST
real 1m29.988s
user 2m4.538s
sys 0m6.553s
2021. 02. 20. (토) 23:48:37 KST
Posted by 구차니

data - *.record (바이너리 타입의 이미지에 대한 ROI 좌표)

training - *.pbxt (json 타입의 이미지 라벨)

images - test (eval용 이미지)

images - train (학습용 이미지)

object_detection - *.py (library)

 

generate_tfrecord.py

model_main_tf2.py (학습)

exporter_main_v2.py (pb로 결과물 내보내기)

Posted by 구차니

텐서플로우 object detection 관련 시작 지점으로 보면 되려나?

 

[링크 : http://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md]

Posted by 구차니

텐서플로우 모델에서 메타데이터를 보다보니 에러가 발생하는 녀석도 있어서

찾아는 보는데 도대체 먼지 알 수가 없네..

 

[링크 : http://https://www.tensorflow.org/tfx/serving/serving_basic]

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

Posted by 구차니

+ 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 구차니

모델 생성해서 보니 피라미드라고 불릴 만큼 크고 아름답다(?)

 

원본은 변환하다 문제가 생긴건지 잘 올려져서 그냥 크롬에서 줄여서 올리는데 티가 안나네

이걸 모바일 디바이스에서 돌릴순 있는게 맞나... ㄷㄷ

 

It stands for Feature Pyramid Network. Its a subnetwork which outputs feature maps of different resolutions. An explanation of FPN using detectron2 as an example is here: https://medium.com/@hirotoschwert/digging-into-detectron-2-part-2-dd6e8b0526e

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

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

tensorflow tag set 'serve'  (0) 2021.02.18
ssd_mobilenet_v2 on tf1, tf2  (0) 2021.02.12
tensorflow pipeline.config  (0) 2021.02.10
tensorflow pipeline.conf  (0) 2021.02.08
tf object detection COCO  (0) 2021.02.05
Posted by 구차니