외부활동/매카톤(인공지능 동아리) - 1기

[2022 매카톤] Face Detection+Blur Tutorial

dohyeon2 2022. 6. 30. 14:29

1. 데이터셋 수집(동영상 촬영)

kaggle opensource dataset

인터넷에 공개된 오픈소스 데이터셋 대부분은 머리 전체를 face로 놓고 데이터셋을 구성하였기 때문에 우리의 목적과 다소 차이가 있다. 따라서 이번 매카톤 프로젝트에서는 한국인의 얼굴 데이터를 직접 동영상 촬영한 뒤 프레임 분할하여 face datset을 구성할 예정이다. 

 

2. video file 프레임 분할

https://n2infotech.co.kr/193

위 블로그에 나와있는대로 VLC Media Player 프로그램을 이용하여 프레임을 분할한다.

 

3. 데이터 라벨링

https://github.com/tzutalin/labelImg

 

GitHub - tzutalin/labelImg: 🖍️ LabelImg is a graphical image annotation tool and label object bounding boxes in images

🖍️ LabelImg is a graphical image annotation tool and label object bounding boxes in images - GitHub - tzutalin/labelImg: 🖍️ LabelImg is a graphical image annotation tool and label object bounding b...

github.com

anaconda에 새로운 가상환경을 만든 뒤, 가상환경을 활성화하고 

pip install labelimg
labelimg

위 명령어를 순서대로 입력하여 labelimg를 실행한다. 

그 뒤 저장형식을 yolo로 지정한 뒤 목표한 지점을 bounding box를 그려 annotation data를 저장한다. 

 

4. yolov5 custom dataset 학습 

https://dohyeon.tistory.com/38?category=1006878 

 

[Detection] Yolov5 custom dataset 학습 및 추론방법

2022년 5월 24일 기준 작성된 글입니다. 수정사항이 있으면 댓글로 말씀 부탁드립니다. 실행환경 os: window10 python: 3.8 pytorch: 1.10.0 cuda: 11.3 cudnn: 8.2.1 for cuda 11.x 1. 가상환경 생성 #가상환경..

dohyeon.tistory.com

위 블로그에 나온 글을 토대로 앞서 라벨링된 face dataset을 가지고 yolov5 네트워크를 학습시킨다.

결과적으로 weight file 하나를 얻을 수 있다.

 

5. yolov5 + strongsort model을 이용한 object detection+tracking 모델 구현

https://github.com/mikel-brostrom/Yolov5_StrongSORT_OSNet

 

GitHub - mikel-brostrom/Yolov5_StrongSORT_OSNet: Real-time multi-camera multi-object tracker using YOLOv5 and StrongSORT with OS

Real-time multi-camera multi-object tracker using YOLOv5 and StrongSORT with OSNet - GitHub - mikel-brostrom/Yolov5_StrongSORT_OSNet: Real-time multi-camera multi-object tracker using YOLOv5 and St...

github.com

앞서 4번 과정에서 얻은 weight file을 이용하여 yolov5+strongsort model inference를 하여 얼굴영역을 tracking 한다.

 

6. yolov5의 detection 코드에서 bounding box의 좌표 영역을 parsing하여 roi를 받아오고, 

roi영역만 가우시안 블러 처리한 뒤 original image에 다시 그려준다. 

 

7. 끝!

 

참고
https://pyimagesearch.com/2020/04/06/blur-and-anonymize-faces-with-opencv-and-python/