SlideShare a Scribd company logo
1 of 40
Download to read offline
대장 용종 Detection
with Tensorflow Object Detection API
디플러스 김영하 연구원
강동경희대병원 소화기내과 곽민섭 교수
발표 및 연구자 소재
곽민섭
학력사항)
연세대학교 의과대학 의학석,박사
경력사항)
서울아산병원 소화기내과 임상강사
Stanford university hospital (CA, USA) 연수
경희대학교 의과대학 강동경희대학교병원 소화기내과
임상조교수
경희대학교 의과대학 강동경희대학교병원 소화기내과 조교수
대한장연구학회 장종양연구회 운영위원
대한장연구학회 전산정보 위원
대한소화기내시경학회 전산정보위원
한국데이터진흥원 의료빅데이터 과정 수료 및 프로젝트 우수상
한국연구재단 빅데이터 단독 과제 연구비 수주
김영하
학력사항)
아주대학교 정보통신/C4I 공학석사
경력사항)
지티원 : 소스코드 변경관리 및 연관분석
타임게이트 : Splunk 엔지니어
디플러스 : 데이터 분석 / 파이썬, 머신러닝 강의
번역)
Splunk 앱 제작과 대시보드 개발 / 에이콘출판사
파이썬 웹 스크래핑 / 에이콘출판사
뷰티플 자바스크립트 / 비제이퍼블릭
누구나 쉽게 배우는 스몰베이직 / 비제이퍼블릭
집필 중)
머신러닝으로 하는 이미지분석 / tensorflow.js
youngha@dplus.companykwac63@hanmail.net
연구의 필요성
• 대장 내시경을 통한 용종 제거의 중요성
– 대장암의 발생 확률을 낮춤
– 대장암으로 인한 사망률을 낮춤
• 머신러닝을 통한 대장 내시경에서의 용종 Detection이 요구됨
– 주름이 많고 구분하기 어려운 대장의 구조
– 대장 내시경을 판단하는 시간이 보통 2시간이 요소됨
– 내시경 해상도 및 판단 숙련도에 따라 진단결과가 달라질 수 있음
• 20%정도의 미탐지률을 5%까지 낮추고자 함
▪ 목차
1. What is Object Detection?
2. Tensorflow Object Detection API
3. 사전준비
4. Object Detection 과정
5. 학습모델 선택
6. 학습 / 평가
7. 파이썬 luminoth 라이브러리
1. What is Object Detection?
Definition
Object detection is a computer technology related to computer vision and
image processing that deals with detecting instances of semantic objects of a
certain class (such as humans, buildings, or cars) in digital images and
videos. Well-researched domains of object detection include face detection
and pedestrian detection. Object detection has applications in many areas of
computer vision, including image retrieval and video surveillance.
Every object class has its own
special features that helps in
classifying the class!
Image Classification vs Object Detection
Single Object vs Multiple Objects
Instance Segmentation
http://www.sseem.com/index
2. Tensorflow Object Detection API
Tensorflow APIs 1
https://github.com/tensorflow
Tensorflow APIs 2
https://github.com/tensorflow/models
Tensorflow Object Detection API
https://github.com/tensorflow/models/tree/master/research/object_detection
3. 사전준비
사전준비 – 디렉토리 구성
|
|-- annotations (LabelImg로 이미지에서 object에 대한 라벨 처리한 xml가 저장되는 디렉토리)
|
|-- config (Object Detection API에서 제공하는 model들에 대한 기본 설정 파일들)
| https://github.com/tensorflow/models/tree/master/research/object_detection/samples/configs
|
|-- csv (라벨 정보가 담긴 xml들을 test_polyp_labels.csv와 train_polyp_labels.csv로 정리)
|
|-- data (train와 eval에 사용한 TFRecord 파일이 있는 곳, 라벨맵 polyp_label_map.pbtxt가 있는 곳)
|
|-- fine_tuned_model (직접 만든 데이터셋으로 학습을 시킨 모델이 위치하는 곳 / 새로 학습을 할 때 삭제가 필요함)
|
|-- images (이미지들이 위치하는 곳)
|
|-- LabelImg_v1.6.1 (이미지에 object를 라벨링하는 프로그램)
|
|-- models (Object Detection API에서 기본으로 제공하는 모델들 / 이 모델들을 기반으로 자신만의 데이터셋으로 학습)
|
|-- object_detection (Object Detection API)
|
|-- resource_img (쥬피터 노트북 참고용 이미지)
|
|-- slim (slim Library)
|
|-- test_images (학습이 끝난 모델에 대한 테스트 이미지가 위치)
|
|-- training (자신만의 데이터셋으로 학습할 때 model checkpoint 파일이 생성되는 곳, 그래프도 존재함)
4. Object Detection 과정
Object Detection 과정
자신만의 학습 데이터셋
준비
학습시킬 모델 선정
선정한 모델에 자신이
만든 데이터셋 학습
학습된 결과로 검증
5. 자신만의 데이터셋 만들기
Why custom dataset?
1. 가지고 있는 데이터셋이 기존 Object Detection 모델에 학습한 결과와 다름
2. 좀더 가능한 좋은 인식률을 가졌으면 한다.
3. 목적에 맞는 좋은 데이터셋이 없다
LabelImg
LabelImg 프로그램은 이지미에 라벨을 하기 위해 사용합니다
파이썬으로 만들어졌으며, Qt 라는 GUI 라이브러리를 사용했습니다.
ImageNet이 사용하는 PASCAL VOC 형식을 가진 XML 파일로 저장합니다.
윈도우즈, 리눅스, 맥에서 사용 가능합니다.
TFRecord
TensorFlow’s binary file format
a serialized tf.train.Example protobuf object
Why?
디스크 캐시를 더 잘 사용
처리가 빠르다
관리가 용이하다 – 이미지와 라벨을 같이 1개의 파일로 관리
쉽다
5. 학습 모델 선택
Pre-trained models in Tensorflow Object
Detection API (Version 1.8)
Pre-trained models in Tensorflow Object
Detection API 설정 (Version 1.8)
5. 학습 / 평가
학습 실행 명령 (200개 이미지 / 20 배치)
python .object_detectiontrain.py --logtostderr --train_dir=./training_ssd_mobilenet_v1_KHU --
pipeline_config_path=./config/ssd_mobilenet_v1_KHU.config
python .object_detectiontrain.py --logtostderr --train_dir=./training_ssd_mobilenet_v2_KHU --
pipeline_config_path=./config/ssd_mobilenet_v2_KHU.config
python .object_detectiontrain.py --logtostderr --train_dir=./training_faster_rcnn_resnet101_KHU --
pipeline_config_path=./config/faster_rcnn_resnet101_KHU.config
python .object_detectiontrain.py --logtostderr --train_dir=./training_faster_rcnn_nas_KHU --
pipeline_config_path=./config/faster_rcnn_nas_KHU.config
python .object_detectiontrain.py --logtostderr --train_dir=./training_rfcn_resnet101_KHU --
pipeline_config_path=./config/rfcn_resnet101_KHU.config
학습 실행
학습 결과 확인
그러나… 영상은?
OpenCV?
Jupyter notebook 에서 가능?
관리는?
6. luminoth
luminoth library 소개
https://tryolabs.com/
+
luminoth library 설치 및 활용
luminoth library 설치 및 활용
luminoth library 설치 및 활용
쉬운 checkpoint repository 관리
$ lumi checkpoint refresh
Retrieving remote index... done.
2 new remote checkpoints added.
$ lumi checkpoint list
================================================================================
| id | name | alias | source | status |
================================================================================
| 48ed2350f5b2 | Faster R-CNN w/COCO | accurate | remote | NOT_DOWNLOADED |
| e3256ffb7e29 | SSD w/Pascal VOC | fast | local | NOT_DOWNLOADED |
================================================================================
$ lumi checkpoint download accurate
Downloading checkpoint... [####################################] 100%
Importing checkpoint... done.
Checkpoint imported successfully.
쉬운 Dataset 관리
$ lumi dataset transform 
--type coco 
--data-dir datasets/coco/ 
--output-dir datasets/coco/tf/ 
--split train --split val 
--only-classes=car
$ lumi dataset merge 
datasets/pascal/tf/2007/classes-car/train.tfrecords 
datasets/pascal/tf/2012/classes-car/train.tfrecords 
datasets/coco/tf/classes-car/train.tfrecords 
datasets/tf/train.tfrecords
쉬운 학습
$ lumi train -c config.yml
INFO:tensorflow:Starting training for SSD
INFO:tensorflow:Constructing op to load 32 variables from pretrained checkpoint
INFO:tensorflow:ImageVisHook was created with mode = "debug"
INFO:tensorflow:Create CheckpointSaverHook.
INFO:tensorflow:Graph was finalized.
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Saving checkpoints for 1 into jobs/ssd-cars/model.ckpt.
INFO:tensorflow:step: 1, file: b'000004.jpg', train_loss: 20.626895904541016, in 0.07s
INFO:tensorflow:step: 2, file: b'000082.jpg', train_loss: 12.471542358398438, in 0.07s
INFO:tensorflow:step: 3, file: b'000074.jpg', train_loss: 7.3356428146362305, in 0.06s
INFO:tensorflow:step: 4, file: b'000137.jpg', train_loss: 8.618950843811035, in 0.07s
(ad infinitum)
쉬운 결과 확인
$ lumi predict video.mp4 --checkpoint=fast --save-media-to=.
Found 1 files to predict.
Predicting video.mp4 [####################################] 100% fps: 45.9
$ lumi predict image.png
Found 1 files to predict.
Neither checkpoint not config specified, assuming `accurate`.
Predicting image.jpg... done.
{
"file": "image.jpg",
"objects": [
{"bbox": [294, 231, 468, 536], "label": "person", "prob": 0.9997},
{"bbox": [494, 289, 578, 439], "label": "person", "prob": 0.9971},
{"bbox": [534, 298, 633, 473], "label": "person", "prob": 0.4089}
]
}
용종 영상 Detection 결과
SSD Model Faster RCNN

More Related Content

Similar to Polyp detection with_tensorflow_object_detection_api

weather-data-processing-using-python
weather-data-processing-using-pythonweather-data-processing-using-python
weather-data-processing-using-pythonmarc_kth
 
Java와 Python의 만남: Jython과 Sikuli
Java와 Python의 만남: Jython과 SikuliJava와 Python의 만남: Jython과 Sikuli
Java와 Python의 만남: Jython과 Sikuli용 최
 
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링OpenStack Korea Community
 
The log based event script (로그기반 이벤트스크립트)
The log based event script (로그기반 이벤트스크립트)The log based event script (로그기반 이벤트스크립트)
The log based event script (로그기반 이벤트스크립트)Jun Hong Kim
 
[Tf2017] day1 jwkang_pub
[Tf2017] day1 jwkang_pub[Tf2017] day1 jwkang_pub
[Tf2017] day1 jwkang_pubJaewook. Kang
 
머신러닝의 개념과 실습
머신러닝의 개념과 실습머신러닝의 개념과 실습
머신러닝의 개념과 실습Byoung-Hee Kim
 
[232] 성능어디까지쥐어짜봤니 송태웅
[232] 성능어디까지쥐어짜봤니 송태웅[232] 성능어디까지쥐어짜봤니 송태웅
[232] 성능어디까지쥐어짜봤니 송태웅NAVER D2
 
Elastic Search Performance Optimization - Deview 2014
Elastic Search Performance Optimization - Deview 2014Elastic Search Performance Optimization - Deview 2014
Elastic Search Performance Optimization - Deview 2014Gruter
 
Python machine learning_chap04_2
Python machine learning_chap04_2 Python machine learning_chap04_2
Python machine learning_chap04_2 PartPrime
 
Python machine learning Chapter 04 - PART2
Python machine learning Chapter 04 - PART2Python machine learning Chapter 04 - PART2
Python machine learning Chapter 04 - PART2Young Oh Jeong
 
Lecture 1: Introduction to Python and TensorFlow
Lecture 1: Introduction to Python and TensorFlowLecture 1: Introduction to Python and TensorFlow
Lecture 1: Introduction to Python and TensorFlowSang Jun Lee
 
Workshop 210417 dhlee
Workshop 210417 dhleeWorkshop 210417 dhlee
Workshop 210417 dhleeDongheon Lee
 
Python study 1강 (오픈소스컨설팅 내부 강의)
Python study 1강 (오픈소스컨설팅 내부 강의)Python study 1강 (오픈소스컨설팅 내부 강의)
Python study 1강 (오픈소스컨설팅 내부 강의)정명훈 Jerry Jeong
 
Io t에서의 소프트웨어단위테스트_접근사례
Io t에서의 소프트웨어단위테스트_접근사례Io t에서의 소프트웨어단위테스트_접근사례
Io t에서의 소프트웨어단위테스트_접근사례SangIn Choung
 
Elastic Stack & Data pipeline
Elastic Stack & Data pipelineElastic Stack & Data pipeline
Elastic Stack & Data pipelineJongho Woo
 
Python을 활용한 챗봇 서비스 개발 2일차
Python을 활용한 챗봇 서비스 개발 2일차Python을 활용한 챗봇 서비스 개발 2일차
Python을 활용한 챗봇 서비스 개발 2일차Taekyung Han
 
VLFeat SIFT MATLAB application 테크니컬 리포트
VLFeat SIFT MATLAB application 테크니컬 리포트VLFeat SIFT MATLAB application 테크니컬 리포트
VLFeat SIFT MATLAB application 테크니컬 리포트Hyunwoong_Jang
 

Similar to Polyp detection with_tensorflow_object_detection_api (20)

weather-data-processing-using-python
weather-data-processing-using-pythonweather-data-processing-using-python
weather-data-processing-using-python
 
Java와 Python의 만남: Jython과 Sikuli
Java와 Python의 만남: Jython과 SikuliJava와 Python의 만남: Jython과 Sikuli
Java와 Python의 만남: Jython과 Sikuli
 
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
 
The log based event script (로그기반 이벤트스크립트)
The log based event script (로그기반 이벤트스크립트)The log based event script (로그기반 이벤트스크립트)
The log based event script (로그기반 이벤트스크립트)
 
[Tf2017] day1 jwkang_pub
[Tf2017] day1 jwkang_pub[Tf2017] day1 jwkang_pub
[Tf2017] day1 jwkang_pub
 
파이썬으로 익히는 딥러닝
파이썬으로 익히는 딥러닝파이썬으로 익히는 딥러닝
파이썬으로 익히는 딥러닝
 
머신러닝의 개념과 실습
머신러닝의 개념과 실습머신러닝의 개념과 실습
머신러닝의 개념과 실습
 
[232] 성능어디까지쥐어짜봤니 송태웅
[232] 성능어디까지쥐어짜봤니 송태웅[232] 성능어디까지쥐어짜봤니 송태웅
[232] 성능어디까지쥐어짜봤니 송태웅
 
Elastic Search Performance Optimization - Deview 2014
Elastic Search Performance Optimization - Deview 2014Elastic Search Performance Optimization - Deview 2014
Elastic Search Performance Optimization - Deview 2014
 
Python machine learning_chap04_2
Python machine learning_chap04_2 Python machine learning_chap04_2
Python machine learning_chap04_2
 
Python machine learning Chapter 04 - PART2
Python machine learning Chapter 04 - PART2Python machine learning Chapter 04 - PART2
Python machine learning Chapter 04 - PART2
 
Lecture 1: Introduction to Python and TensorFlow
Lecture 1: Introduction to Python and TensorFlowLecture 1: Introduction to Python and TensorFlow
Lecture 1: Introduction to Python and TensorFlow
 
Eclipse RCP 1/2
Eclipse RCP 1/2Eclipse RCP 1/2
Eclipse RCP 1/2
 
Workshop 210417 dhlee
Workshop 210417 dhleeWorkshop 210417 dhlee
Workshop 210417 dhlee
 
Python study 1강 (오픈소스컨설팅 내부 강의)
Python study 1강 (오픈소스컨설팅 내부 강의)Python study 1강 (오픈소스컨설팅 내부 강의)
Python study 1강 (오픈소스컨설팅 내부 강의)
 
14 2 iterator
14 2 iterator14 2 iterator
14 2 iterator
 
Io t에서의 소프트웨어단위테스트_접근사례
Io t에서의 소프트웨어단위테스트_접근사례Io t에서의 소프트웨어단위테스트_접근사례
Io t에서의 소프트웨어단위테스트_접근사례
 
Elastic Stack & Data pipeline
Elastic Stack & Data pipelineElastic Stack & Data pipeline
Elastic Stack & Data pipeline
 
Python을 활용한 챗봇 서비스 개발 2일차
Python을 활용한 챗봇 서비스 개발 2일차Python을 활용한 챗봇 서비스 개발 2일차
Python을 활용한 챗봇 서비스 개발 2일차
 
VLFeat SIFT MATLAB application 테크니컬 리포트
VLFeat SIFT MATLAB application 테크니컬 리포트VLFeat SIFT MATLAB application 테크니컬 리포트
VLFeat SIFT MATLAB application 테크니컬 리포트
 

Recently uploaded

Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Kim Daeun
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Wonjun Hwang
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionKim Daeun
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)Tae Young Lee
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Wonjun Hwang
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스
 

Recently uploaded (6)

Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차
 

Polyp detection with_tensorflow_object_detection_api

  • 1. 대장 용종 Detection with Tensorflow Object Detection API 디플러스 김영하 연구원 강동경희대병원 소화기내과 곽민섭 교수
  • 2. 발표 및 연구자 소재 곽민섭 학력사항) 연세대학교 의과대학 의학석,박사 경력사항) 서울아산병원 소화기내과 임상강사 Stanford university hospital (CA, USA) 연수 경희대학교 의과대학 강동경희대학교병원 소화기내과 임상조교수 경희대학교 의과대학 강동경희대학교병원 소화기내과 조교수 대한장연구학회 장종양연구회 운영위원 대한장연구학회 전산정보 위원 대한소화기내시경학회 전산정보위원 한국데이터진흥원 의료빅데이터 과정 수료 및 프로젝트 우수상 한국연구재단 빅데이터 단독 과제 연구비 수주 김영하 학력사항) 아주대학교 정보통신/C4I 공학석사 경력사항) 지티원 : 소스코드 변경관리 및 연관분석 타임게이트 : Splunk 엔지니어 디플러스 : 데이터 분석 / 파이썬, 머신러닝 강의 번역) Splunk 앱 제작과 대시보드 개발 / 에이콘출판사 파이썬 웹 스크래핑 / 에이콘출판사 뷰티플 자바스크립트 / 비제이퍼블릭 누구나 쉽게 배우는 스몰베이직 / 비제이퍼블릭 집필 중) 머신러닝으로 하는 이미지분석 / tensorflow.js youngha@dplus.companykwac63@hanmail.net
  • 3. 연구의 필요성 • 대장 내시경을 통한 용종 제거의 중요성 – 대장암의 발생 확률을 낮춤 – 대장암으로 인한 사망률을 낮춤 • 머신러닝을 통한 대장 내시경에서의 용종 Detection이 요구됨 – 주름이 많고 구분하기 어려운 대장의 구조 – 대장 내시경을 판단하는 시간이 보통 2시간이 요소됨 – 내시경 해상도 및 판단 숙련도에 따라 진단결과가 달라질 수 있음 • 20%정도의 미탐지률을 5%까지 낮추고자 함
  • 4. ▪ 목차 1. What is Object Detection? 2. Tensorflow Object Detection API 3. 사전준비 4. Object Detection 과정 5. 학습모델 선택 6. 학습 / 평가 7. 파이썬 luminoth 라이브러리
  • 5. 1. What is Object Detection?
  • 6. Definition Object detection is a computer technology related to computer vision and image processing that deals with detecting instances of semantic objects of a certain class (such as humans, buildings, or cars) in digital images and videos. Well-researched domains of object detection include face detection and pedestrian detection. Object detection has applications in many areas of computer vision, including image retrieval and video surveillance. Every object class has its own special features that helps in classifying the class!
  • 7.
  • 8. Image Classification vs Object Detection
  • 9. Single Object vs Multiple Objects
  • 11. 2. Tensorflow Object Detection API
  • 14. Tensorflow Object Detection API https://github.com/tensorflow/models/tree/master/research/object_detection
  • 16. 사전준비 – 디렉토리 구성 | |-- annotations (LabelImg로 이미지에서 object에 대한 라벨 처리한 xml가 저장되는 디렉토리) | |-- config (Object Detection API에서 제공하는 model들에 대한 기본 설정 파일들) | https://github.com/tensorflow/models/tree/master/research/object_detection/samples/configs | |-- csv (라벨 정보가 담긴 xml들을 test_polyp_labels.csv와 train_polyp_labels.csv로 정리) | |-- data (train와 eval에 사용한 TFRecord 파일이 있는 곳, 라벨맵 polyp_label_map.pbtxt가 있는 곳) | |-- fine_tuned_model (직접 만든 데이터셋으로 학습을 시킨 모델이 위치하는 곳 / 새로 학습을 할 때 삭제가 필요함) | |-- images (이미지들이 위치하는 곳) | |-- LabelImg_v1.6.1 (이미지에 object를 라벨링하는 프로그램) | |-- models (Object Detection API에서 기본으로 제공하는 모델들 / 이 모델들을 기반으로 자신만의 데이터셋으로 학습) | |-- object_detection (Object Detection API) | |-- resource_img (쥬피터 노트북 참고용 이미지) | |-- slim (slim Library) | |-- test_images (학습이 끝난 모델에 대한 테스트 이미지가 위치) | |-- training (자신만의 데이터셋으로 학습할 때 model checkpoint 파일이 생성되는 곳, 그래프도 존재함)
  • 18. Object Detection 과정 자신만의 학습 데이터셋 준비 학습시킬 모델 선정 선정한 모델에 자신이 만든 데이터셋 학습 학습된 결과로 검증
  • 20. Why custom dataset? 1. 가지고 있는 데이터셋이 기존 Object Detection 모델에 학습한 결과와 다름 2. 좀더 가능한 좋은 인식률을 가졌으면 한다. 3. 목적에 맞는 좋은 데이터셋이 없다
  • 21. LabelImg LabelImg 프로그램은 이지미에 라벨을 하기 위해 사용합니다 파이썬으로 만들어졌으며, Qt 라는 GUI 라이브러리를 사용했습니다. ImageNet이 사용하는 PASCAL VOC 형식을 가진 XML 파일로 저장합니다. 윈도우즈, 리눅스, 맥에서 사용 가능합니다.
  • 22. TFRecord TensorFlow’s binary file format a serialized tf.train.Example protobuf object Why? 디스크 캐시를 더 잘 사용 처리가 빠르다 관리가 용이하다 – 이미지와 라벨을 같이 1개의 파일로 관리 쉽다
  • 24. Pre-trained models in Tensorflow Object Detection API (Version 1.8)
  • 25. Pre-trained models in Tensorflow Object Detection API 설정 (Version 1.8)
  • 26. 5. 학습 / 평가
  • 27. 학습 실행 명령 (200개 이미지 / 20 배치) python .object_detectiontrain.py --logtostderr --train_dir=./training_ssd_mobilenet_v1_KHU -- pipeline_config_path=./config/ssd_mobilenet_v1_KHU.config python .object_detectiontrain.py --logtostderr --train_dir=./training_ssd_mobilenet_v2_KHU -- pipeline_config_path=./config/ssd_mobilenet_v2_KHU.config python .object_detectiontrain.py --logtostderr --train_dir=./training_faster_rcnn_resnet101_KHU -- pipeline_config_path=./config/faster_rcnn_resnet101_KHU.config python .object_detectiontrain.py --logtostderr --train_dir=./training_faster_rcnn_nas_KHU -- pipeline_config_path=./config/faster_rcnn_nas_KHU.config python .object_detectiontrain.py --logtostderr --train_dir=./training_rfcn_resnet101_KHU -- pipeline_config_path=./config/rfcn_resnet101_KHU.config
  • 36. 쉬운 checkpoint repository 관리 $ lumi checkpoint refresh Retrieving remote index... done. 2 new remote checkpoints added. $ lumi checkpoint list ================================================================================ | id | name | alias | source | status | ================================================================================ | 48ed2350f5b2 | Faster R-CNN w/COCO | accurate | remote | NOT_DOWNLOADED | | e3256ffb7e29 | SSD w/Pascal VOC | fast | local | NOT_DOWNLOADED | ================================================================================ $ lumi checkpoint download accurate Downloading checkpoint... [####################################] 100% Importing checkpoint... done. Checkpoint imported successfully.
  • 37. 쉬운 Dataset 관리 $ lumi dataset transform --type coco --data-dir datasets/coco/ --output-dir datasets/coco/tf/ --split train --split val --only-classes=car $ lumi dataset merge datasets/pascal/tf/2007/classes-car/train.tfrecords datasets/pascal/tf/2012/classes-car/train.tfrecords datasets/coco/tf/classes-car/train.tfrecords datasets/tf/train.tfrecords
  • 38. 쉬운 학습 $ lumi train -c config.yml INFO:tensorflow:Starting training for SSD INFO:tensorflow:Constructing op to load 32 variables from pretrained checkpoint INFO:tensorflow:ImageVisHook was created with mode = "debug" INFO:tensorflow:Create CheckpointSaverHook. INFO:tensorflow:Graph was finalized. INFO:tensorflow:Running local_init_op. INFO:tensorflow:Done running local_init_op. INFO:tensorflow:Saving checkpoints for 1 into jobs/ssd-cars/model.ckpt. INFO:tensorflow:step: 1, file: b'000004.jpg', train_loss: 20.626895904541016, in 0.07s INFO:tensorflow:step: 2, file: b'000082.jpg', train_loss: 12.471542358398438, in 0.07s INFO:tensorflow:step: 3, file: b'000074.jpg', train_loss: 7.3356428146362305, in 0.06s INFO:tensorflow:step: 4, file: b'000137.jpg', train_loss: 8.618950843811035, in 0.07s (ad infinitum)
  • 39. 쉬운 결과 확인 $ lumi predict video.mp4 --checkpoint=fast --save-media-to=. Found 1 files to predict. Predicting video.mp4 [####################################] 100% fps: 45.9 $ lumi predict image.png Found 1 files to predict. Neither checkpoint not config specified, assuming `accurate`. Predicting image.jpg... done. { "file": "image.jpg", "objects": [ {"bbox": [294, 231, 468, 536], "label": "person", "prob": 0.9997}, {"bbox": [494, 289, 578, 439], "label": "person", "prob": 0.9971}, {"bbox": [534, 298, 633, 473], "label": "person", "prob": 0.4089} ] }
  • 40. 용종 영상 Detection 결과 SSD Model Faster RCNN