Computer Vision/Object Detection

[Detection+Tracking] YOLOv4+Deep_SORT custom model 사용법

dohyeon2 2021. 8. 9. 11:28

목차

    안녕하세요 이글은 2021년 8월 9일 기준 작성된 글입니다.

    오늘은 Object Detection 기반 Tracking 실습을 하려합니다. 학습할 모델명은 YOLOv4+Deep_SORT 입니다. 

     

     

     

     

    1. GPU 구동환경 구성

     


    https://dohyeon.tistory.com/4

     

    딥러닝 GPU 개발환경 구성방법(cuda,cudnn)-Window10

    2021년 3월기준 자료입니다. 시간이 지나면서 버전이 업데이트 되었을 것입니다. 아래의 방법과 같이 버전을 잘 확인해주세요! 윈도우 검색창에 cmd를 검색하고 명령 프롬프트 창을 킨다. 아래 명

    dohyeon.tistory.com

     

    2. YOLOv4 custom dataset Training (custom weight파일 얻기위해)


    https://dohyeon.tistory.com/9

     

    [colab] Yolov4 custom dataset 학습방법

    2021년 7월 27일 기준 작성된 글입니다. 수정사항이 있으면 댓글로 말씀 부탁드립니다. https://github.com/dohyeonYoon/yolov4-custom-training GitHub - dohyeonYoon/yolov4-custom-training: google colab을..

    dohyeon.tistory.com

     

     

    3. YOLO v4 + Deep_SORT 환경 셋팅하기


    3.1 본인의 학습환경 

    -os: Window10

    -CUDA: 10.1 

    -cuDNN: 7.6.5

    -실행: Anaconda 가상환경

     

    3.2 Anaconda 가상환경 생성 및 필요한 라이브러리 설치 

    conda create -n deepsort python=3.7 #가상환경 생성
    conda activate deepsort #가상환경 접속
    
    pip install opencv-python
    pip install pillow
    pip install matplotlib
    pip install tensorflow-gpu==2.3.0

    3.3 코드 다운로드(git clone)

    git clone https://github.com/theAIGuysCode/yolov4-deepsort.git

     

    4. 앞서 yolov4 custom training을 통해 학습시킨 yolov4-custom-last.weight file 다운로드 


     

    5. yolov4-deepsort/core/config.py에서 __C.YOLO.CLASSES을 자신의 names 파일에 맞게 수정


     

     

    6. 실행!! 


    6.1 model save 

    #save yolov4 model
    python save_model.py --weights ./data/yolov4-custom_last.weights --output ./checkpoints/yolov4-custom-416 --model yolov4

     

    -실행결과

    다음과 같이 checkpoints/yolov4-custom-416 폴더내에 다음과 같이 모델이 저장된다.

     

     

    6.2 tracking 실행 

     

    # Run yolov4 object tracker
    python object_tracker.py --weights ./checkpoints/yolov4-custom-416 --model yolov4 --video ./data/video/test2.mp4 --output ./outputs/result2.avi

     

    -실행결과

     

     

     

     

     

     

     

     

    Reference 

     

    YOLOv4+Deep_SORT 깃허브 링크


    https://github.com/theAIGuysCode/yolov4-deepsort/tree/9e745bfb3ea5e7c7505cb11a8e8654f5b1319ad9

     

    GitHub - theAIGuysCode/yolov4-deepsort: Object tracking implemented with YOLOv4, DeepSort, and TensorFlow.

    Object tracking implemented with YOLOv4, DeepSort, and TensorFlow. - GitHub - theAIGuysCode/yolov4-deepsort: Object tracking implemented with YOLOv4, DeepSort, and TensorFlow.

    github.com