티스토리 뷰

 작성자 : 한양대학원 융합로봇시스템학과 유승환 석사과정 (CAI LAB)

 

 오늘은 번외로 Pytorch와 yolov4, yolov5를 설치하겠습니다. ROS는 사용하지 않습니다.


번외 1. YOLOv4 설치

  • 아래의 링크가 친절하게 설명되어있습니다! 아래의 링크는 yolov3 기준으로 설명되어 있는데, yolov3의 인자를 v4로 변경하면 v4를 사용할 수 있습니다!
  • YOLOv4 설치 : wendys.tistory.com/143
 

[AI] 젯슨 나노(Jetson Nano) darknet YOLO v3 설치 및 샘플 돌려보기

젯슨 나노 (jetson nano) darknet 신경망 오픈소스 프로젝트 YOLO v3 설치하기 https://pjreddie.com/darknet/ Darknet: Open Source Neural Networks in C Nightmare Use Darknet's black magic to conjure ghost..

wendys.tistory.com


번외 2. Pytorch & torchvision 설치 (Jeston nano, TX1/2에서도 설치법은 동일!)

 

PyTorch for Jetson - version 1.7.0 now available

Below are pre-built PyTorch pip wheel installers for Python on Jetson Nano, Jetson TX1/TX2, and Jetson Xavier NX/AGX with JetPack 4.2 and newer. Download one of the PyTorch binaries from below for your version of JetPack, and see the installation instructi

forums.developer.nvidia.com

  • Python 2.7과 3.6 기준으로 설치법을 정리해놓겠습니다.
  • torchvision을 설치할 때, sudo python setup.py install 실행 과정이 깁니다! 저도 20분 정도 기다렸네요... 인내심 필수!
############################## python 3 #######################################
# if you not install pip (python3)
sudo apt-get install python3-pip
pip install --upgrade pip3

# install torch v1.7 (for python 3)
wget https://nvidia.box.com/shared/static/wa34qwrwtk9njtyarwt5nvo6imenfy26.whl -O torch-1.7.0-cp36-cp36m-linux_aarch64.whl
sudo apt-get install python3-pip libopenblas-base libopenmpi-dev 
pip3 install Cython
pip3 install numpy torch-1.7.0-cp36-cp36m-linux_aarch64.whl

# install torchvision v0.8.1 (for python3)
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
git clone --branch v0.8.1 https://github.com/pytorch/vision torchvision
cd torchvision
export BUILD_VERSION=0.8.1 
sudo python3 setup.py install

############################## python 2 #######################################
# if you not install pip (python2)
sudo apt-get install python-pip
pip install --upgrade pip

# install torch v1.4 (for python 2.7, jetpack 4.4)
wget https://nvidia.box.com/shared/static/1v2cc4ro6zvsbu0p8h6qcuaqco1qcsif.whl -O torch-1.4.0-cp27-cp27mu-linux_aarch64.whl
sudo apt-get install libopenblas-base libopenmpi-dev 
pip install future torch-1.4.0-cp27-cp27mu-linux_aarch64.whl

# if occur error, to do this
pip install future torch-1.4.0-cp27-cp27mu-linux_aarch64.whl --no-warn-script-location

# install torchvision v0.5.0 (for python 2.7, torch v1.4)
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
git clone --branch v0.5.0 https://github.com/pytorch/vision torchvision
cd torchvision
export BUILD_VERSION=0.5.0 
sudo python setup.py install
cd ../
pip install 'pillow<7'
  • 설치가 완료됬으면, python으로 진입해서 import torch, import torchvision이 잘 실행이 되는지 확인하면 완료!

번외 3. YOLOv5-torch 설치

  • yolov5에 필요한 라이브러리들을 설치합니다.
  • yolov5는 opencv-python 4.1 이상의 버전을 요구합니다!!! 유의!!!!
# pip3 upgrade to ver 20.2.4
sudo pip3 install pip --upgrade

# base
pip3 install matplotlib
pip3 install Pillow
pip3 install PyYAML
pip3 install scipy

# if scipy version < 1.0
# pip3 install scipy --upgrade

pip3 install tensorboard
pip3 install tqdm
pip3 install opencv-python

# If python2
# if you not install numpy
pip install numpy==1.13.3
# if you install numpy but not v1.13.3 (because skimage version)
pip install --upgrade numpy==1.13.3

pip install matplotlib

sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev
sudo apt-get install gfortran
sudo pip install scipy

pip insatll Cython
pip install scikit-image==0.13.0
sudo apt install python-opencv

# if python2 on error
sudo apt-get install libfreetype6-dev
sudo apt-get install pkg-config

 

  • yolov5 코드를 클론합니다.
# git clone yolov5
sudo git clone https://github.com/ultralytics/yolov5.git

 

  • 이제 필요한 파일들 설치가 완료되었습니다! 테스트를 위해서 아래의 weight 파일을 다운받읍시다.
  • download weight file (yolov5s.pt) : github.com/ultralytics/yolov5/releases
 

Releases · ultralytics/yolov5

YOLOv5 in PyTorch > ONNX > CoreML > TFLite. Contribute to ultralytics/yolov5 development by creating an account on GitHub.

github.com

  • 아래의 명령어를 실행하고, yolov5의 판단 결과가 나오면 끝!!
python3 detect.py --source data/images --weights yolov5s.pt --conf 0.25

 


 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30