JSP's Deep learning

[Deep learning - Obeject Detection] TensorFlow Object Detection API(3) - 모델 빌드 본문

Deap learning/Object Detection

[Deep learning - Obeject Detection] TensorFlow Object Detection API(3) - 모델 빌드

_JSP_ 2023. 3. 6. 21:59

1. Pre-Trained Model 다운로드

  • 다운로드 링크 : Download
  • TensorFlow/workspace/training_demo/pre-trained-models에 압축해제
  • 압축해제시 폴더 구조

2. Training pipeline 파일 생성

  • Tensorflow/workspace/training_demo/models에 폴더 이름을 지정(사용자정의)하여 생성
  • 생성한 폴더에 pre-trained modelpipeline.config 파일 저장
  • 폴더 구조 예시

3. pipeline.config 파일 조정

  • Model이 가지는 classes 수 설정(즉, 모델이 분류할 수 있는 클래스 수)

  • Train batch_size 조정(그래픽 카드 성능에 맞게 조정)

  • Pre-trained model checkpoint 경로 지정

  • 학습 목적 및 TPU 설정

  • 학습 데이터의 label map, record 파일 경로 지정

  • 모델 평가 metrics 지정

  • 모델 평가 데이터 label map, record 경로 지정

4. 학습

  • Model training script 가져오기
# 1. 파일 복사
TensorFlow/models/research/object_detection/model_main_tf2.py
=>
TensorFlow/workspace/training_demo 폴더에 copy

# 2. 경로 이동
TensorFlow/workspace/training_demo 경로로 이동

# 3. 학습 파일 실행
python model_main_tf2.py --model_dir=[MODEL_FOLDER] --pipeline_config_path=[CONFIG_FILE_PATH] 실행

 

5. 평가

  • 평가에 이용할 checkpoint 생성
# 1. 경로 이동
TensorFlow/workspace/training_demo 경로로 이동

# 2. 파일 실행
python model_main_tf2.py --model_dir=[MODEL_FOLDER] --pipeline_config_path=[MODEL_CONFIG_PATH] --checkpoint_dir=[SAVE_CKPT_PATH]

 

6. 모델 학습 결과 모니터링

# 1. 경로 이동
TensorFlow/workspace/training_demo 경로로 이동

# 2. 텐서보드 실행
tensorboard --logdir=[EVAL_CKPT_PATH]

 


참고

[1] https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html

 

Training Custom Object Detector — TensorFlow 2 Object Detection API tutorial documentation

Whether you are using the TensorFlow CPU or GPU variant: In general, even when compared to the best CPUs, almost any GPU graphics card will yield much faster training and detection speeds. As a matter of fact, when I first started I was running TensorFlow

tensorflow-object-detection-api-tutorial.readthedocs.io

 

Comments