wawawaaw
안녕하세요
wawawaaw
전체 방문자
오늘
어제
  • 분류 전체보기 (33)
    • Programming (13)
      • Debugging (0)
      • Linux (5)
      • CUDA (5)
      • Git (1)
    • AI Research (14)
      • Tracking (2)
      • Object Detection (9)
      • Dataset (1)
      • GPU (2)
    • Paper Review (1)
    • 보안 (2)
    • Book Review (0)
    • Etc. (2)
      • 자격증 (1)

인기 글

최근 글

티스토리

반응형
hELLO · Designed By 정상우.
wawawaaw

안녕하세요

[Object Detection] 윈도우 환경에서 Detectron2 실행하기
AI Research/Object Detection

[Object Detection] 윈도우 환경에서 Detectron2 실행하기

2022. 7. 27. 10:20
반응형

⭐ 윈도우에서 anaconda를 이용하여 Detectron2를 실행해보자!

Detectron2는 Facebook AI Research에서 개발한 object detection 알고리즘이다. 

 

활용할 깃허브 코드는 다음과 같다. 

https://github.com/DGMaxime/detectron2-windows

 

GitHub - DGMaxime/detectron2-windows: Detectron2 is FAIR's next-generation platform for object detection and segmentation.

Detectron2 is FAIR's next-generation platform for object detection and segmentation. - GitHub - DGMaxime/detectron2-windows: Detectron2 is FAIR's next-generation platform for object detecti...

github.com

 

⭐ 설치 순서⭐ 

1. anaconda 설치 (생략)

 

2. cuda 설치 10.2 (생략)

 

3. conda env 생성

conda create -n detectron2 python=3.7

 

4. conda 가상환경 activate

conda activate detectron2

 

5. pytorch 다운

conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch
  • 이 과정에서 error : AssertionError: Requires PyTorch >= 1.8 에러가 뜬다면 아래 코드로 실행nvcc —version을 이용하여 자신의 cuda version과 맞는 pytorch를 받아야한다. 그게 아닌 경우이 에러가 발생하는 것이다. 
conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=10.2 -c pytorch

 

6. 🔥매우 중요한 단계!!!🔥 Microsoft Visual Studio 재설치 하기 

  • build tool 다운로드
    • 아래 링크에서 visual studio 빌드툴을 다운로드 받는다. 
    • 위에서 Visual Studio 2017용 Microsoft Visual C++ 재배포 가능 패키지 x86 버전 다운로드
    • https://visualstudio.microsoft.com/ko/vs/older-downloads/
 

Visual Studio 이전 다운로드 - 2019, 2017, 2015 및 이전 버전

이전 버전의 Visual Studio Community, Professional 및 Enterprise 소프트웨어를 다운로드합니다. 여기에서 MSDN(Visual Studio) 구독에 로그인합니다.

visualstudio.microsoft.com

 

    • 위 에러 발생할 경우 distributed version 말고 build tools로 다운 받아야함. 15.9 버전의 build tools로 설치
    •  visual studio community 2017 에서 아래와 그림과 같이 체크해주고 다운로드 진행하자. 
      •  python 빌드툴에서 development tools for python with visual studio installer 설치중, 그거랑 아나콘다 가장 위에 것 설치함 .  

  • UserWarning: Error checking compiler version for cl: [WinError 2] 지정된 파일을 찾을 수 없습니다
    • distributed version 말고 build tools로 다운 받아야함. 15.9 버전의 build tools로 설치해야함. 
    • 꼭 위 사진과 같이 체크하고 설치 해줘야한다. 
    • [에러시 참고] https://stackoverflow.com/questions/54915458/microsoft-visual-c-14-0-is-required-get-it-with-microsoft-visual-c-build

7. 필요 라이브러리 설치

pip install cython
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

 

8. git clone

원하는 dir에 gitbash 열어서 clone

다운 받을 코드는 detectron 윈도우 버전이다. 

git clone https://github.com/DGMaxime/detectron2-windows.git
  • 기존의 detectron2와 다른 점은 일부 라이브러리가 윈도우에 맞게 수정되었다는 점이다.
    • setup.py
    • detectron2/engine/defaults.py
    • detectron2/layers/csrc/cocoeval/cocoeval.cpp

9. 기본 셋팅

다운 받은 폴더로 이동

cd detectron2-windows
pip install -e .
pip install opencv-python

 

10 . Test 해보기 1

  • 아래 python 파일을 detectron2/tests 폴더 아래에 두고 테스트 해보자.
  • https://github.com/yogeshkumarpilli/detectron2/blob/master/tests/test_window.py
 

GitHub - yogeshkumarpilli/detectron2: Detectron2 is FAIR's next-generation platform for object detection, segmentation and other

Detectron2 is FAIR's next-generation platform for object detection, segmentation and other visual recognition tasks. - GitHub - yogeshkumarpilli/detectron2: Detectron2 is FAIR's next-genera...

github.com

python test_window.py

이 아저씨 뜨면 성공!

  • 이미지 읽어오는 부분 주석처리하고 cv2.imread(’이미지 경로/이름’)로 변경해서 원하는 이미지에 대한 탐색을 진행하면 된다.
  • 참고) default로 config file이 coco-detection/faster__rcnn_R_101_FPN_3x.yaml 로 설정되어있다. 즉 faster rcnn 모델로 돌려본 것!

 

+) 오류나고 conda 가상환경 삭제하고 다시 하는 경우 아래 명령어

conda remove --name detectron2 --all

 

 

⭐ 설치할 때 참고한 자료들⭐

  • https://medium.com/@yogeshkumarpilli/how-to-install-detectron2-on-windows-10-or-11-2021-aug-with-the-latest-build-v0-5-c7333909676f
 

How to Install Detectron2 on Windows 10 or 11 –2021(AUG) with the latest build(v0.5).

Installing Detectron2 on windows is not so easy but an achievement indeed! I am writing this story after so many hurdles which I faced…

medium.com

  • https://dgmaxime.medium.com/how-to-easily-install-detectron2-on-windows-10-39186139101c
 

How to easily install Detectron2 on Windows 10 ?

Installing Detectron2 on Windows is no easy task because the official version of Detectron2 is officially not supported on this platform…

dgmaxime.medium.com

 

반응형

'AI Research > Object Detection' 카테고리의 다른 글

[Object Detection] 오픈소스로 detection 결과 mAP 측정하기  (0) 2023.01.13
[Object Detection] mmdetection의 input image size 변경하는 방법 (Faster r-cnn)  (0) 2022.12.28
[Object Detection] YOLOv5로 multi stream, multi camera object detection하는 법/ 동시에 여러 video detection 진행하기  (3) 2022.08.08
[Object Detection] YOLOv5 이미지 사이즈 변경하는 법 (How to change YOLOv5 image resolution)  (0) 2022.08.08
[Object Detection] Ubuntu에서 YOLOv5 실행하기  (0) 2022.07.26
    'AI Research/Object Detection' 카테고리의 다른 글
    • [Object Detection] mmdetection의 input image size 변경하는 방법 (Faster r-cnn)
    • [Object Detection] YOLOv5로 multi stream, multi camera object detection하는 법/ 동시에 여러 video detection 진행하기
    • [Object Detection] YOLOv5 이미지 사이즈 변경하는 법 (How to change YOLOv5 image resolution)
    • [Object Detection] Ubuntu에서 YOLOv5 실행하기
    wawawaaw
    wawawaaw
    안녕하세요.

    티스토리툴바