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 라이브러리
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!
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 파일이 생성되는 곳, 그래프도 존재함)
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개의 파일로 관리
쉽다
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}
]
}