์ผ๊ตด์์ landmark๋ฅผ ์ธ์ํด์ face alignment๋ฅผ ํ๋ ค๊ณ ํ๋๋ฐ ๋ฅ๋ฌ๋์ผ๋ก ํ์ต๋ ๋ชจ๋ธ์ด ์ฑ๋ฅ์ด ์ข๋ค๊ณ ์งํ๊ฐ ๋์์์๋ค.
ํ์ฌ ํ๋ก์ ํธ๋ C๋ก ๋ง๋ค์ด์ ธ ์๊ธฐ๋๋ฌธ์ ์ ๋งํ๋ฉด c๋ก ์ง์ ธ์๋ ์ฝ๋๊ฐ ํ์ํ๋ค. tensorflow์์ c++๋ก ํ์ต ์ํค๊ณ ํ ์คํธ ํ๋ ๊ฒ ๋์ด์๋ face alignment ์ฝ๋๋ฅผ ์ฐพ์๋ค.
https://github.com/bobetocalo/faces_framework
๊ทธ๊ฒ ์ ๋งํฌ์ธ๋ฐ
์ด๊ฑธ Cmake ๋น๋ํ๋ ค๋ค ๋ณด๋ ๊ณจ๋๋ฆฌ๋๊ฒ ํ๋๊ฐ์ง๊ฐ ์๋๋ค.
์ฐ์ opencv๋ ๊น๋ ค์ ธ ์์ผ๋ ํจ์ค
Boost๋ ๋น๋ ํด์ shared library๋ง cmake๋ก ์ฐ๊ฒฐํด์ฃผ๋ ์ด์ฐ์ ์ฐ ๋์๋๋ฐ
๋ฌธ์ ๋
https://github.com/bobetocalo/bobetocalo_prl19/
faces_framework submodule๋ก ์กด์ฌํ๋ ์ฌ๊ธฐ์ tensorflow๋ฅผ ์ฐ๊ฒฐํด์ฃผ์ด์ผ ํ๋ค.
ํด๋น ๊น์๋ tensorflow ๋ฒ์ ์ ๋ช์ ์ฐ๋ผ๋์ง ์ ํ์๋ ๋ด์ฉ์ด์์ด ๊ทธ๋ฅ ๋์ถฉ git ๋ ์ง ๋ณด๊ณ
2.0๋ง ์๋๋ฉด ๋๊ฒ ์ง ๋ผ๋ ์๊ฐ์ผ๋ก 1.4๋ฅผ ํต์งธ๋ก ๋ฐ์์
์ฐ๊ฒฐ๋ง ํ๋ฉด ๋ ์ค ์์๋๋ฐ
python์์ tensorflow๋ฅผ ์ฌ์ฉํ๋๊ฑด
pip install tensorflow
์ด๋ฌ๋ฉด ๋ก์ด์๋๋ฐ
c++์์ ๊ทธ๋ฅ make ๋ง ํด์ ๋๋๊ฒ ์๋์๋ค. ใ ใ ใ ใ ใ ใ
์ฌ๊ธฐ์ ๊ธฐ ๋ค์ง๋ค ์ฐ์ tensorflow build ํ๋ ๋ฌธ์๋ฅผ ์ฐพ์๊ณ
https://www.tensorflow.org/install/source
bazel๋ ๋ฒ์ ์ ์ ๋ง์ถฐ์ ๊น์์ผ ๋๋ค. (2.0.0 ๋ฒ์ ๊น์๋ค๊ฐ ๋ค์ ์ง์ฐ๊ณ ๊ฐ๊ณ ์ ํ๋ค.)
tensorflow ๋ฒ์ ์ ๋ฐ๋ฅธ bazel,cuda,cudnn test completed version์ ์๋๋งํฌ ์์ ํ์ธํ ์ ์๋ค.
https://www.tensorflow.org/install/source#tested_build_configurations
tensorflow ๊ณต์ ๋ฌธ์์๋ ์ ํ์์ง๋ง
bazelink ๋ฅผ ์ฐ๋ฉด ์ฝ๊ฒ ๊น๋ฆฐ๋ค๊ณ ํ๋๋ฐ ๋๋ ๋ฌด์ํ๊ณ ๊ทธ ์๋ ๊ทธ๋ฅ bazel ์ค์นํ๋ ๋งํฌ๋ก ๋ค์ด๊ฐ๋ค.
https://docs.bazel.build/versions/master/install.html
๋๋ ์ฐ๋ถํฌ๋ ์ฐ๋ถํฌ ๊ธฐ์ค์ผ๋ก ํ๊ณ installer๋ฅผ ๋ค์ด๋ฐ์์ ํ๋ ๋ฐฉ๋ฒ์ ํํ๋ค.
๊ทธ ์ธ์ ๊ฒฝ์ฐ ์๋งํฌ์์ ํ์ธํ๋ฉด ๋๋ค.
์์กด์ฑ ํจํค์ง๋ฅผ ๊น๋ฉด ๋๋ค.(์ฌ์ค ์ ๋งํ๋ฉด ๊น๋ ค์์๊ฒ์ด๋ค.)
sudo apt install g++ unzip zip
๊ทธ ๋ค์์๋ ์๋ฐ๋ฅผ ๊น๋๋ฐ ์๋ฐํ๋ก์ ํธ๋ฅผ ๋น๋ํ๊ณ ์ถ์ผ๋ฉด ๊น๋ ๊ฑด๋ฐ ๊ตณ์ด tensorflow ๋น๋ํ๋๋ฐ ํ์๋ ์์ด๋ณด์ด์ง๋ง ํน์๋ชจ๋ฅด๋ ๊น์๋ค. (ํ์์์๊ฑฐ๊ฐ๊ธดํ๋ฐ)
# Ubuntu 16.04 (LTS) uses OpenJDK 8 by default:
sudo apt-get install openjdk-8-jdk
# Ubuntu 18.04 (LTS) uses OpenJDK 11 by default:
sudo apt-get install openjdk-11-jdk
๊ทธ๋ค์์ installer๋ฅผ ๋ค์ด ๋ฐ์์ผ ํ๋ค.
https://github.com/bazelbuild/bazel/releases
์ฌ๊ธฐ์ ๋ค์ด ๋ฐ์ผ๋ฉด ๋๋ค.
r1.14 ๋ฅผ ๋น๋ํ๋ ค๊ณ ํ๋ ๊ฒฝ์ฐ ๊ทธ๋ฅ 0.26.0 ๋ฐ์ผ๋ฉด ๋๋ค. ( ๊ทธ์ธ์ ๊ฒฝ์ฐ๋ ์์์ ์... duckduckgo ๊ฐ์๋ฐ ์ ๋ค์ ธ๋ณด๋ฉด ์์๊ฑธ..?)
๊ทธ๋ฆฌ๊ณ ์๋ ์ฒ๋ผ ์คํ ๊ถํ ์ฃผ๊ณ ์คํํ๋ฉด ๋๋ค.
chmod +x bazel-<version>-installer-linux-x86_64.sh
./bazel-<version>-installer-linux-x86_64.sh --user
์ด๊ฒ ๊ฐ๋นก์น๋ค.
tensorflow ์์ gpu๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด cuda๊ด๋ จ ๋ ๊ฒ๋ค์ด ์ฐ๊ฒฐ ๋์ด์ผ ํ๋๋ฐ ์ด๊ฑธ ์๊น๊ณ ํ๋ฉด bazel๋ก configure ํ ๋ ๊ณ์ ํ์ผ ์๋ค๊ณ ๋จ๋ฉด์ ์งํ์ด ์๋๋ค.
cuda toolkit ๋ค์ด ๋งํฌ
https://developer.nvidia.com/cuda-downloads
์์์ ์ ์ ํ ํ๋ฉด ๋๋๋ฐ ๋๋ runfile ๋ฐฉ์์ผ๋ก ์ค์นํ ๊ฒ์ด๋ค.
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
sudo sh cuda_10.2.89_440.33.01_linux.run
๊ทผ๋ฐ ์ด๊ฒ๋ง ๊น๋ฉด ๋ ์ค ์์๋๋ฐ ๋ cudnn์ ๋ชป์ฐพ๋ ๋๋ค.
์ ์ ๋ง cuda toolkit์ ์ ๋ฐ ํ๋ฒ์ ๋ฃ์ด์คฌ์ผ๋ฉด ์ข๊ฒ ๋ค. ๋ด๊ฐ ๋ชจ๋ฅด๋ ๊ฑด๊ฐ..
https://developer.nvidia.com/rdp/cudnn-download
์ฌ๊ธฐ์ ๋ฐ์์ผ ๋๋๋ฐ ๋ ๋นก์น๋๊ฑด ๋ก๊ทธ์ธ์ ํด์ผ๋๋ค.
๋ก๊ทธ์ธ ํ๊ธฐ ์ซ์ ์ฌ๋์ ์ํด ๋ค์ด๋งํฌ(cuda 10.2 x86-64 linux ๋ง ๋๋ค. cudnn v7.6.5) ๋ด๊ฑฐ ๋ฐ๊ณ ์ถ์ผ๋ฉด ๋ก๊ทธ์ธํ์๊ณ ...
https://developer.nvidia.com/compute/machine-learning/cudnn/secure/7.6.5.32/Production/10.2_20191118/cudnn-10.2-linux-x64-v7.6.5.32.tgz
(์ ์ด์ ๋ค์ด๋ก๋๊ฐ ์ด๋ ์ ๋ ๋ฌ๋ค.)
๋ค์ด๋ฐ๊ณ ๋์๋ ์์ถ ํ๊ณ .
tar -xzvf cudnn-10.2-linux-x64-v7.6.5.32.tgz
๊ทธ๋ฅ ๋ฌด์ํ๊ฒ ์์ถ ํผ ๊ฑฐ๋ฅผ ๋ค usr/local/cuda (cuda ๊ธฐ๋ณธ ์ค์น ๊ฒฝ๋ก) ์ ๋ณต์ฌํ๋ฉด ๋๋ค.
(์ด๊ฒ ๋ด๊ฐ ๋ง๋ ๊ฒ ์๋๊ณ ๊ณต์ ๋ฌธ์์ ์๋ ๋ด์ฉ ์.. ์ง์ง..
https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html)
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
์.. ์ ๋ง ๊น๊ฒ ๋ง๋ค..
TensorRT๊ฐ ๋ญ๋๋ฉด ์ค์ํ์ ์ ์ํ์ผ๋ก ๋ณํํด ๋น ๋ฅด๊ฒ Inference ํ ์ ์๊ฒ ๋์์ฃผ๋ ํด์ด๋ค.
์์งํ ์ค์๊ฐ ํ ๊ป ์๋๋ฉด ํ์์๋๋ฐ....
๋ ์์์น ๊ฐ์ nvidia ํํ์ด์ง์ ๋ค์ด๊ฐ์ผํ๋ค.
https://developer.nvidia.com/nvidia-tensorrt-download
์ฌ๊ธฐ์ ๋๋ tensorRT 6์ ๋ฐ์ ๊ฒ์ด๋ค.
๋ค์ด๋ฐ์ผ๋ ค๋ฉด ์ค๋ฌธ์ ํด์ผ๋๋๋ฐ ๊ฑ ๋งค์ฐ ๊ท์ฐฎ์๊ธฐ ๋๋ฌธ์ ํ์ฌ๋ช
์ ใ
ใดใ
ในใ
ใดใ
ใน๋ฅผ ์ ์..
๋ฒ์ 6์ ๋ฐ์ ์ด์ ๋ ๊ทธ๋ฅ ์ ์๋๊ณ ubuntu16.04์ cuda10.2 ๋ฅผ ๋ง์กฑํ๋ ์ต์ ๋ฒ์ ์ด๋ผ์..?
๋ค๋ฅธ ๋ถ๋ค์ ๋์น๊ป ์ ๋ฐ๊ธฐ ๋ฐ๋๋ค. ์๊ทธ๋ฌ๋ฉด ๋ bazel์์ ๋น ๊พธ๋จน๋๋ค.
์ฌ์ฌ ์ง์น๊ธฐ ์์ํ๊ธฐ ๋๋ฌธ์ ํธํ deb ์ค์นํ์ผ์ ๋ฐ์์ ์ค์นํ๋ค.
๊ทธ๋ฅ ๋๋ธํด๋ฆญํด์ ๊น์๋ ๋๊ธดํ๋ฐ command๊ฐ ํธํ ๋ถ๋ค์ ์ํด
sudo apt install ./nv-tensorrt-repo-ubuntu1604-cuda10.2-trt6.0.1.8-ga-20191108_1-1_amd64.deb
์ ์ด์ ์ค๋น๊ฐ ๋์์ผ๋(์ฌ์ค ๋๋ 5๋ฒ ๊ณผ์ ์ bazelํํ ๋น ๊พธ๋จน๊ณ ์ํ์ฐฉ์ค๋ก 1,2,3,4 ์คํ ์ ๋ง๋ค์๋ค ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ )
tensorflow ๋ค์ด ๋ฐ์๋ ํด๋๋ก ๋ค์ด๊ฐ์
ํน์๋ ๋ค์ด์ด ์๋์์ผ๋ฉด
์๋์ฒ๋ผ ํ๋ฉด ๋๋ค. ์ฉ๋ ๊ฐ๋ง์ ์ฃผ์.. (r1.14 ๋ ๋ด๊บผ ๊ธฐ์ค์ด๋ผ.. ์ํ๋ ๋ฒ์ ์ผ๋ก.ํ๋ฉด๋จ.)
git clone https://github.com/tensorflow/tensorflow.git
git checkout r1.14
์ ๋ค์ด์ ๋ฐ์์ผ๋ configure๋ฅผ ํด๋ณผ๊น...
./configure
๊ทธ๋ฅ ์๋ ๋ด์ฉ ๋์ค๋ฉด ๋ค ์ํฐ ์ณ์ฃผ๋ฉด ๋๋ค.
(์ค๋งํ๋ python์ด ์๊น๋ฆฐ ์ฌ๋์ ์๊ฒ์ง)
Please specify the location of python. [Default is /usr/bin/python]:
Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]
Do you wish to build TensorFlow with XLA JIT support? [Y/n]: Y
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: N
Do you wish to build TensorFlow with ROCm support? [y/N]: N
Do you wish to build TensorFlow with CUDA support? [y/N]:
Do you wish to build TensorFlow with TensorRT support? [y/N]: N
Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10]:
Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]:
Please specify the TensorRT version you want to use. [Leave empty to default to TensorRT 5]:
Please specify the locally installed NCCL version you want to use. [Leave empty to use http://github.com/nvidia/nccl]:
Please specify the comma-separated list of base paths to look for CUDA libraries and headers. [Leave empty to use the default]:
Please note that each additional compute capability significantly increases your build time and binary size, and that TensorFlow only supports compute capabilities >= 3.5 [Default is: 3.5,7.0]:
Do you want to use clang as CUDA compiler? [y/N]: n
๊ทธ๋ฅ ๋๋จธ์ง ๋ค ์ํฐ
ํ๊ณ Configuration finished ๋จ๋ฉด ์๋ฃ ๋ ๊ฒ์ด๋ค.
๊ทธ๋ฆฌ๊ณ
bazel build tensorflow
ํ๋ฉด ์ ๋ถ๋ค ๋น๋๋ฅผ ํ๋ค.
์ฌ์ค core๋ง ๋ฐ๋ก ๋น๋ํ๋ฉด ๋์๋๋ฐ ๊ดํ ๋ค ๋น๋ ํ๊ฒ ๊ฐ๋ค.
๋์ค์ ๊ธฐํ ๋๋ฉด ๋ฐ๋ก ๋น๋ํ๋ ๊ฒ์ ์ฌ๋ ค๋ณด๊ฒ ๋ค.