์ ๋ dataset ๊ตฌ์ถ๊ณผ train ์ vessl server (ubuntu) ํ๊ฒฝ์์ ์งํ ํ๊ณ ,
viewer ๋ exe ๋ก ์คํํด์ผ๋๊ธฐ ๋๋ฌธ์ window ํ๊ฒฝ์์ ์งํ ํ์ต๋๋ค.
gaussian splatting ์ ํ๊ฒฝ์ฌํญ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
name: gaussian_splatting channels: - pytorch - conda-forge - defaults dependencies: - cudatoolkit=11.6 - plyfile - python=3.7.13 - pip=22.3.1 - pytorch=1.12.1 - torchaudio=0.12.1 - torchvision=0.13.1 - tqdm - pip: - submodules/diff-gaussian-rasterization - submodules/simple-knn - submodules/fused-ssim - opencv-python - joblib |
[Ubuntu Environment]
Ubuntu 20.04
Cuda 11.4
GPU: NVIDIA RTX 3090 (RAM 24GB)
[Window Environment]
Window 10
cuda 11.8
GPU: NVIDIA GeForce RTX 3090 (RAM 24GB)
์ผ๋จ ubuntu vessl ์๋ฒ์์๋ถํฐ ์์ ์ ์์ํ์ต๋๋ค.
git clone https://github.com/graphdeco-inria/gaussian-splatting --recursive
์ ๋ช ๋ น์ด ์ ๋ ฅํด์ git clone ํ์ต๋๋ค.
conda env create --file environment.yml
conda activate gaussian_splatting
gaussian splatting ๋ชจ๋ธ์ input ์ผ๋ก ๋ฃ์ด์ผํ๋ ๋ฐ์ดํฐ๋ ๋ค์ ๋๊ฐ์ ๋๋ค.
1. ๋ค๊ฐ๋์์ ์์งํ ๋ฐ์ดํฐ (images)
2. ์ด๋ฏธ์ง๋ณ ๊ณต๊ฐ ์ ๋ณด (sparse, aka pointscloud.ply)
์ฌ์ฉ์๊ฐ mp4 ์์์ ์ง์ด๋ฃ์ผ๋ฉด ffmpeg, colmap ์ ์ฌ์ฉํ์ฌ images/sparse ํํ๋ก convert ํ ์ ์์ต๋๋ค.
"mp4 to images to sparse"
โ ffmpeg: ๋์์ mp4 ๋ฅผ ์ด๋ฏธ์ง ํ๋ ์ ์ํ์ค๋ก ๋ณํ
ffmpeg -i input.mp4 -vf fps=1 frame_%04d.png
๋ค์๊ณผ ๊ฐ์ ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ๋์์์ ๊ฐ ํ๋ ์์ ๊ฐ๋ณ ์ด๋ฏธ์ง ํ์ผ๋ก ์ถ์ถํ ์ ์์ต๋๋ค.
โ colmap: structure-from-motion (SfM) ๋ฐ multi-view stero (MVS) ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง ๊ฐ์ ํน์ง์ ๋งค์นํ์ฌ ์นด๋ฉ๋ผ์ ์์น์ 3d ์ ๊ตฐ์ ๊ณ์ฐํฉ๋๋ค.
์ด๋ ์ด๋ฏธ์ง์์ sparse point cloud (ํฌ์์ ๊ตฐ)์ ์์ฑํ๋ ์ญํ ์ ํฉ๋๋ค.
1. FFmpeg
์ฒซ ๋ฒ์งธ input ๋ฐ์ดํฐ๋ฅผ ์์ฑํ๊ธฐ ์ํด FFmpeg ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
FFmpeg ์ ๊ฒฝ์ฐ ubuntu ํ๊ฒฝ์์๋ apt-get ์ ์ฌ์ฉํ์ฌ install ํ ์ ์์ต๋๋ค.
์ค์น๋ ๋ชจ๋ ffmpeg ๋ฅผ ์ ๊ฑฐํ๊ณ reinstall ํด์ฃผ์ง ์์ผ๋ฉด ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํฉ๋๋ค.
"ffmpeg error while loading shared libraries libopenh264.so.5 cannot open shared object file"
1. ์ค์น๋ ๋ชจ๋ ffmpeg ๋ฅผ ์ ๊ฑฐ
apt-get remove ffmpeg
sudo apt-get purge ffmpeg
2. anaconda ์์ ffmpeg ๋ชจ๋์ ์ญ์
conda remove ffmpeg
3. ์ฌ์ค์น
apt-get install ffmpeg
4. version ํ์ธ
ffmpeg -version
ffmpeg version check
ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 |
2. COLMAP
apt-get update
apt-get install colmap
colmap -h ๋ช ๋ น์ด๋ฅผ ํตํด์ version ์ check ํ ์ ์์ต๋๋ค.
์ ์ ๊ฒฝ์ฐ๋ "COLMAP 3.6 -- Structure-from-Motion and Multi-View Stereo" ๋ฒ์ ์ด์์ต๋๋ค.
3. Imagemagick
convert -version
apt install imagemagick
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101
์ ์ด์ ๋ค์ด๋ฐ์ software ๋ ๋ค ๋ค์ด ๋ฐ์ ๊ฒ ๊ฐ์ต๋๋ค.
gaussian-splatting ์ root ํด๋๋ผ๊ณ ํ๊ณ gaussian splatting ์ ๋ง๋ค์ด๋ด ์๋ค.
1. ๊ฐ์ธ ์์ ํ์ผ์ ์ค๋นํด๋ด ์๋ค.
gaussian-splatting/data/my_video ํด๋์ my_video_input.mp4 ๋ฅผ ๋ฃ์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ gaussian-splatting/data/my_video/input ํด๋๋ฅผ ๋ง๋ค์ด์ค๋๋ค.
2. ffmpeg ์ฌ์ฉํ์ฌ ์์์ ๋ค๊ฐ๋์ ์ด๋ฏธ์ง ํํ๋ก ๋ง๋ญ๋๋ค.
cd gaussian-splatting/data/my_video/input
ffmpeg -i gaussian-splatting/data/my_video/my_video_input.mp4 -qscale:v 1 -qmin 1 -vf fps=10 %04d.jpg
์คํํด๋ณด๋ฉด data/my_video ์ images ๋ผ๋ ํด๋๊ฐ ์๊ธฐ๊ณ , ๊ฑฐ๊ธฐ์ ๋ค๊ฐ๋์ ์ด๋ฏธ์ง๊ฐ frame ๋ณ๋ก ์ ์ฅ๋์ด์์ต๋๋ค.
์ ๋ ์ฝ 160 ์ฅ ์ ๋ ์ ์ฅ๋์ด์๋ค์.
3. colmap ์ ์ฌ์ฉํ์ฌ sparse ์ ๋ณด๋ฅผ ๋ง๋ญ๋๋ค.
cd gaussian-splatting
python convert.py -s data/my_video
์ด๋ ๊ฒ ํ๋ฉด ๋ณดํต์ window ์์๋ ๋ ํ ๋ฐ์, ์ ๋ dataset ๊ตฌ์ถ์ vessl ubuntu sever ํ๊ฒฝ์์ ์งํํ๊ณ ์๊ธฐ ๋๋ฌธ์ ๋ฐ๋ก gui ๊ฐ ์๋ค๊ณ ์๋ฌ๊ฐ ๋น๋๋ค....
๊ทธ๋์ ์ ๋ ๊ฐ์ ๋์คํ๋ ์ด๋ฅผ ์์ฑํ์ฌ ์งํํ์์ต๋๋ค.
apt update
apt install xvfb
xvfb-run -a python convert.py -s data/my_video
xvfb-run ์ ๊ฐ์ ๋์คํ๋ ์ด ํ๊ฒฝ์ ์๋์ผ๋ก ์์ฑํ์ฌ ํ๋ก๊ทธ๋จ์ ์คํํฉ๋๋ค.
๊ทธ ๋ค์ ์๋ฌ:
์๋ฌ ๋ฉ์์ง๋ฅผ ๋ณด๋ฉด COLMAP์ Mapper ๋จ๊ณ์์ ์ต์
--Mapper.ba_global_function_tolerance๋ฅผ ์ธ์ํ์ง ๋ชปํ๋ค๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ด๋ ์ฌ์ฉ ์ค์ธ COLMAP ๋ฒ์ ์ด ํด๋น ์ต์
์ ์ง์ํ์ง ์๊ธฐ ๋๋ฌธ์
๋๋ค.
--Mapper.ba_global_function_tolerance๋ ํน์ ์ต์ ํ ์กฐ๊ฑด๊ณผ ๊ด๋ จ๋ ์ต์ ์ ๋๋ค. COLMAP์ ๊ธฐ๋ณธ ์ค์ ์ผ๋ก๋ ์ถฉ๋ถํ ์ข์ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์์ผ๋ฏ๋ก ํ์ํ์ง ์๋ค๊ณ ํ๋จํ๊ธฐ ๋๋ฌธ์ ์ ๊ฑฐ ํ ์งํ ํ์์ต๋๋ค.
convert.py ๋ฅผ ์๋์ ๊ฐ์ด ์์ ํ์์ต๋๋ค.
### Bundle adjustment
# The default Mapper tolerance is unnecessarily large,
# decreasing it speeds up bundle adjustment steps.
mapper_cmd = (colmap_command + " mapper \
--database_path " + args.source_path + "/distorted/database.db \
--image_path " + args.source_path + "/input \
--output_path " + args.source_path )
# + "/distorted/sparse \
# --Mapper.ba_global_function_tolerance=0.000001")
exit_code = os.system(mapper_cmd)
if exit_code != 0:
logging.error(f"Mapper failed with code {exit_code}. Exiting.")
exit(exit_code)
์์ ๋ถ๋ถ์ ์ฃผ์์ฒ๋ฆฌ ํ์ต๋๋ค.
์ ์ด์ ์ฌ๊ธฐ์ ์ ๋ ๋ ๋ค๋ฅธ ์๋ฌ๊ฐ ๋ํ๋ฌ๋๋ฐ์.
์ค๋ฅ ๋ฉ์์ง๋ data/my_video/distorted/sparse/0 ๊ฒฝ๋ก์ ํ์ํ 3D ์ฌ๊ตฌ์ฑ ๋ฐ์ดํฐ ํ์ผ์ด ์๋ค๊ณ ๋ณด๊ณ ์์์ต๋๋ค.
ํ์ง๋ง data/my_video/0/์๋ cameras.bin, images.bin, points3D.bin, project.ini ๋ฑ์ด ์กด์ฌํ์ต๋๋ค.
์ด ๋ฌธ์ ๋ ๊ฒฝ๋ก ์ค์ ๋ฌธ์ ์ธ๊ฒ ๊ฐ์์ต๋๋ค.
convert.py ๋ฅผ ๋ณด๋ฉด
files = os.listdir(args.source_path + "/sparse")
os.makedirs(args.source_path + "/sparse/0", exist_ok=True)
# Copy each file from the source directory to the destination directory
for file in files:
if file == '0':
continue
source_file = os.path.join(args.source_path, "sparse", file)
destination_file = os.path.join(args.source_path, "sparse", "0", file)
shutil.move(source_file, destination_file)
if(args.resize):
print("Copying and resizing...")
์ด ๋ถ๋ถ์์ ํด๊ฒฐ ๋ฐฉ๋ฒ
1. convert.py์ ์
๋ ฅ ๊ฒฝ๋ก ํ์ธ
convert.py ์ฝ๋์์ ํ๋ก๊ทธ๋จ์ด ์ค์ ๋ก ์ด๋ค ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ๊ณ ์๋์ง ํ์ธํด ๋ณด์ธ์. distorted/sparse/0๊ฐ ์๋ ์์ฑ๋ ๊ฒฝ๋ก์ผ ์ ์์ต๋๋ค.
2. convert.py์์ distorted/sparse/0 ๊ฒฝ๋ก ๋์ data/my_video/0๋ฅผ ์ฐธ์กฐํ๋๋ก ์ค์ ํฉ๋๋ค:
python convert.py -s data/my_video/0
์ ์ ๊ฒฝ์ฐ์๋ data/my_video/distorted/0 ํด๋๋ฅผ data/my_video/distorted/sparse/0์ผ๋ก ์ฎ๊ฒผ์ต๋๋ค.
์ฌ์ค convert.py ์์ ๊ฒฝ๋ก๋ฅผ ๋ฐ๊ฟ์ค์ผํ๋๋ฐ, ๊ฑด๋ค์ด๊ธฐ ๋ฌด์์์์...
xvfb-run -a python convert.py -s data/my_video
๊ทธ๋ ๊ฒ ๋๋ฉด data/my_video ๊ฒฝ๋ก์ distorted, sparse ํด๋์ colmap ์ sh ํ์ผ ๋ฑ๋ฑ์ด ์ ์ฅ๋๊ฒ์ ํ์ธํ ์ ์์ต๋๋ค.
ํ์ต์ ์งํํฉ์๋ค.
cd gaussian-splatting
python train.py -s data/my-video
์์ ๋ช ๋ น์ด๋ฅผ ๋ค์ ์คํํด์ฃผ๋ฉด gaussian-splatting ํด๋์ ์ซ์์ ์์ด๊ฐ ์์ธ ์ ๋ชฉ์ ํด๋๊ฐ ๋ง๋ค์ด์ง๋๋ค.
ํด๋น ํด๋๋ฅผ ์ ๋ my_video ๋ก ์ด๋ฆ์ ๋ณ๊ฒฝํด์ฃผ์์ต๋๋ค.
์ ์ด์ viewer ๋ก gaussian-splatting ์ด ์ ๊ตฌํ๋์๋์ง ํ์ธํด๋ด ์๋ค.
viewer ๋ exe ํ์ผ์ด๊ธฐ ๋๋ฌธ์ ubuntu ํ๊ฒฝ์์ ์คํํ ์ ์์ต๋๋ค.
๋ฐ๋ผ์, ํด๋น output ํด๋๋ฅผ window ์ปดํจํฐ๋ก ์ฎ๊ธด ํ viewer ๋ฅผ ์คํํด์ ๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
scp -P (ํฌํธ๋ฒํธ) -r (์ฌ์ฉ์ id)@(ssh ip):/(๊ฒฝ๋ก)/gaussian-splatting/output/my_video .
๊ทธ๋ฆฌ๊ณ ๋์ window ์ ํ๊ฒฝ์ค์ ์ ๋์ผํ๊ฒ ํด์ค ๋ค, window ์ปดํจํฐ์ viewer ๋ฅผ ๋ค์ด๋ฐ์์ผํฉ๋๋ค.
- link ์ ๋ค์ด๊ฐ์, Pre-built Windows Binaries ํญ์ here๋ฅผ ๋๋ฌ ๋ค์ด๋ฐ์ต๋๋ค.
- zip ํด์ ํ ํ, (root ํด๋)/viewer ํด๋๋ก ์ด๋ํฉ๋๋ค.
cd (root ํด๋)/viewers/bin
SIBR_gaussianViewer_app.exe -m (root ํด๋)/output/my_video
์ดํ ์์ ๊ฐ์ด ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ๋ฉด, gaussian_splatting ์ด ์ ๋ณด์ ๋๋ค.