From 7784ce7433a19f5c37aea8b52cdbbcd1b57cc1eb Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sat, 25 Jul 2020 01:43:17 +0900 Subject: [PATCH 01/11] add Dockerfile --- .dockerignore | 0 docker/Dockerfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .dockerignore create mode 100644 docker/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..e69de29bb diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..dbc7210e7 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,45 @@ +FROM nvidia/cuda:9.2-cudnn7-devel-ubuntu16.04 + +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +# Install some basic utilities +RUN apt-get update && apt-get install -y \ + build-essential \ + bzip2 \ + ca-certificates \ + git \ + curl \ + libx11-6 \ + sudo \ + && rm -rf /var/lib/apt/lists/* + +# Create a working directory +RUN mkdir /work +WORKDIR /work + +# Create a non-root user and switch to it +RUN adduser --disabled-password --gecos '' --shell /bin/bash user \ + && chown -R user:user /work +RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user +USER user + +# All users can use /home/user as their home directory +ENV HOME=/home/user +RUN chmod 777 /home/user + +# Install Miniconda and Python 3.6 +ENV CONDA_AUTO_UPDATE_CONDA=false +ENV PATH=/home/user/miniconda/bin:$PATH +RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh \ + && chmod +x ~/miniconda.sh \ + && ~/miniconda.sh -b -p ~/miniconda \ + && rm ~/miniconda.sh \ + && conda install -y python==3.6.8 \ + && conda clean -ya + +# CUDA 9.2-specific steps +RUN conda install -y -c pytorch \ + cuda92 \ + "pytorch=0.4.1=py36_cuda9.2.148_cudnn7.1.4_1" \ + "torchvision=0.2.1=py36_1" \ + && conda clean -ya From ea4e2f7cbcb96bedc45fd0c1d466599fab84ce76 Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sat, 25 Jul 2020 02:28:53 +0900 Subject: [PATCH 02/11] build M3D-RPN source --- .dockerignore | 3 +++ docker/Dockerfile | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/.dockerignore b/.dockerignore index e69de29bb..a9b473a48 100644 --- a/.dockerignore +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!data +!lib diff --git a/docker/Dockerfile b/docker/Dockerfile index dbc7210e7..2216a9c2a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,6 +9,7 @@ RUN apt-get update && apt-get install -y \ ca-certificates \ git \ curl \ + libboost-dev \ libx11-6 \ sudo \ && rm -rf /var/lib/apt/lists/* @@ -43,3 +44,11 @@ RUN conda install -y -c pytorch \ "pytorch=0.4.1=py36_cuda9.2.148_cudnn7.1.4_1" \ "torchvision=0.2.1=py36_1" \ && conda clean -ya + +# Build M3D-RPN source +COPY --chown=user:user lib /work/lib +COPY --chown=user:user data /work/data +RUN cd /work/lib/nms && make +RUN cd /work \ + && sh data/kitti_split1/devkit/cpp/build.sh \ + && sh data/kitti_split2/devkit/cpp/build.sh From 5e5afc09126d4b4ee03c1266fdc8db7c7fd11545 Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sat, 25 Jul 2020 16:02:40 +0900 Subject: [PATCH 03/11] add .gitignote --- .gitignore | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..c33716030 --- /dev/null +++ b/.gitignore @@ -0,0 +1,224 @@ +/data/kitti +/data/kitti_split1/training +/data/kitti_split1/validation +/data/kitti_split2/training +/data/kitti_split2/validation + +/weights + +# Created by https://www.toptal.com/developers/gitignore/api/python,virtualenv,jupyternotebooks,visualstudiocode,macos,linux +# Edit at https://www.toptal.com/developers/gitignore?templates=python,virtualenv,jupyternotebooks,visualstudiocode,macos,linux + +### JupyterNotebooks ### +# gitignore template for Jupyter Notebooks +# website: http://jupyter.org/ + +.ipynb_checkpoints +*/.ipynb_checkpoints/* + +# IPython +profile_default/ +ipython_config.py + +# Remove previous ipynb_checkpoints +# git rm -r .ipynb_checkpoints/ + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook + +# IPython + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +### VirtualEnv ### +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +pip-selfcheck.json + +### VisualStudioCode ### +.vscode/* +#!.vscode/settings.json +#!.vscode/tasks.json +#!.vscode/launch.json +#!.vscode/extensions.json +*.code-workspace + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history + +# End of https://www.toptal.com/developers/gitignore/api/python,virtualenv,jupyternotebooks,visualstudiocode,macos,linux \ No newline at end of file From 2d655f2b84c67f2c82350cedbaadeffc6e0077b9 Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sat, 25 Jul 2020 20:52:01 +0900 Subject: [PATCH 04/11] make Dockerfile with which train/test scripts work --- .dockerignore | 11 +++++++++- .gitignore | 1 + docker/Dockerfile | 47 ++++++++++++++++++++++++++--------------- docker/build.sh | 3 +++ docker/exec.sh | 3 +++ docker/requirements.txt | 6 ++++++ docker/run.sh | 17 +++++++++++++++ scripts/test_rpn_3d.py | 4 ++-- 8 files changed, 72 insertions(+), 20 deletions(-) create mode 100755 docker/build.sh create mode 100755 docker/exec.sh create mode 100644 docker/requirements.txt create mode 100755 docker/run.sh diff --git a/.dockerignore b/.dockerignore index a9b473a48..ad2463d2f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,12 @@ * -!data !lib +!data/kitti_split1/devkit +!data/kitti_split1/setup_split.py +!data/kitti_split1/test.txt +!data/kitti_split1/train.txt +!data/kitti_split1/trainval.txt +!data/kitti_split1/val.txt +!data/kitti_split2/devkit +!data/kitti_split2/kitti_ids_new.mat +!data/kitti_split2/setup_split.py +!docker/requirements.txt diff --git a/.gitignore b/.gitignore index c33716030..0278b435f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /data/kitti_split1/validation /data/kitti_split2/training /data/kitti_split2/validation +/output /weights diff --git a/docker/Dockerfile b/docker/Dockerfile index 2216a9c2a..1f40aef09 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,7 +10,11 @@ RUN apt-get update && apt-get install -y \ git \ curl \ libboost-dev \ + libgl1-mesa-dev \ + libsm6 \ libx11-6 \ + libxext-dev \ + libxrender1 \ sudo \ && rm -rf /var/lib/apt/lists/* @@ -18,19 +22,9 @@ RUN apt-get update && apt-get install -y \ RUN mkdir /work WORKDIR /work -# Create a non-root user and switch to it -RUN adduser --disabled-password --gecos '' --shell /bin/bash user \ - && chown -R user:user /work -RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user -USER user - -# All users can use /home/user as their home directory -ENV HOME=/home/user -RUN chmod 777 /home/user - # Install Miniconda and Python 3.6 ENV CONDA_AUTO_UPDATE_CONDA=false -ENV PATH=/home/user/miniconda/bin:$PATH +ENV PATH=/root/miniconda/bin:$PATH RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh \ && chmod +x ~/miniconda.sh \ && ~/miniconda.sh -b -p ~/miniconda \ @@ -45,10 +39,29 @@ RUN conda install -y -c pytorch \ "torchvision=0.2.1=py36_1" \ && conda clean -ya -# Build M3D-RPN source -COPY --chown=user:user lib /work/lib -COPY --chown=user:user data /work/data +# Install Python modules +COPY docker/requirements.txt /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt + +# Build NMS +COPY lib /work/lib RUN cd /work/lib/nms && make -RUN cd /work \ - && sh data/kitti_split1/devkit/cpp/build.sh \ - && sh data/kitti_split2/devkit/cpp/build.sh + +# Build KITTI devkit for kitti_split1 +# TODO: check if this is necessary or not +RUN mkdir -p /work/data/kitti_split1 +COPY data/kitti_split1/devkit /work/data/kitti_split1/devkit +COPY data/kitti_split1/setup_split.py /work/data/kitti_split1/setup_split.py +COPY data/kitti_split1/test.txt /work/data/kitti_split1/test.txt +COPY data/kitti_split1/train.txt /work/data/kitti_split1/train.txt +COPY data/kitti_split1/trainval.txt /work/data/kitti_split1/trainval.txt +COPY data/kitti_split1/val.txt /work/data/kitti_split1/val.txt +RUN cd /work && sh data/kitti_split1/devkit/cpp/build.sh + +# Build KITTI devkit for kitti_split_2 +# TODO: check if this is necessary or not +RUN mkdir -p /work/data/kitti_split2 +COPY data/kitti_split2/devkit /work/data/kitti_split2/devkit +COPY data/kitti_split2/kitti_ids_new.mat /work/data/kitti_split2/kitti_ids_new.mat +COPY data/kitti_split2/setup_split.py /work/data/kitti_split2/setup_split.py +RUN cd /work && sh data/kitti_split2/devkit/cpp/build.sh diff --git a/docker/build.sh b/docker/build.sh new file mode 100755 index 000000000..ac8dbbd13 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build -t m3d_rpn -f docker/Dockerfile . diff --git a/docker/exec.sh b/docker/exec.sh new file mode 100755 index 000000000..bb8e751c3 --- /dev/null +++ b/docker/exec.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker exec -it m3d_rpn /bin/bash diff --git a/docker/requirements.txt b/docker/requirements.txt new file mode 100644 index 000000000..68057c591 --- /dev/null +++ b/docker/requirements.txt @@ -0,0 +1,6 @@ +easydict==1.9 +opencv-python==3.1.0.5 +shapely==1.6.4 +#torch==0.4.1 # installed in Dockerfile +#torchvision==0.2.1 # installaed in Dockerfile +visdom==0.1.8.5 diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 000000000..40627ad76 --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +THIS_DIR=$(cd $(dirname $0); pwd) +PROJ_DIR=`dirname ${THIS_DIR}` + +OUT_DIR=${PROJ_DIR}/output +mkdir -p -m 777 ${OUT_DIR} + +nvidia-docker run --rm -it \ + -v ${PROJ_DIR}/data/kitti:/work/data/kitti \ + -v ${PROJ_DIR}/models:/work/models \ + -v ${OUT_DIR}:/work/output \ + -v ${PROJ_DIR}/scripts:/work/scripts \ + -v ${PROJ_DIR}/weights:/work/weights \ + -p 8100:8100 \ + --name m3d_rpn \ + m3d_rpn /bin/bash diff --git a/scripts/test_rpn_3d.py b/scripts/test_rpn_3d.py index 715d19010..be0b7506e 100644 --- a/scripts/test_rpn_3d.py +++ b/scripts/test_rpn_3d.py @@ -18,8 +18,8 @@ # ----------------------------------------- from lib.imdb_util import * -conf_path = '/home/garrick/Desktop/M3D-RPN-Release/m3d_rpn_depth_aware_test_config.pkl' -weights_path = '/home/garrick/Desktop/M3D-RPN-Release/m3d_rpn_depth_aware_test' +conf_path = 'weights/M3D-RPN-Release/m3d_rpn_depth_aware_test_config.pkl' +weights_path = 'weights/M3D-RPN-Release/m3d_rpn_depth_aware_test' # load config conf = edict(pickle_read(conf_path)) From 662309a8b77d36257c5084dfc3e7d0f4d9b34af6 Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sat, 25 Jul 2020 22:36:15 +0900 Subject: [PATCH 05/11] use nvidai-docker wheh docker build --- docker/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/build.sh b/docker/build.sh index ac8dbbd13..762929dfe 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker build -t m3d_rpn -f docker/Dockerfile . +nvidia-docker build -t m3d_rpn -f docker/Dockerfile . From a8130fd8d01dfb0c6111aa117051a5fa1cfc1a28 Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sat, 25 Jul 2020 22:36:45 +0900 Subject: [PATCH 06/11] change path to pretrained weight and config --- .gitignore | 4 ++-- docker/run.sh | 4 ++-- scripts/test_rpn_3d.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 0278b435f..97490c840 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ /data/kitti_split2/training /data/kitti_split2/validation /output - -/weights +/M3D-RPN-Release +/M3D-RPN-Release.zip # Created by https://www.toptal.com/developers/gitignore/api/python,virtualenv,jupyternotebooks,visualstudiocode,macos,linux # Edit at https://www.toptal.com/developers/gitignore?templates=python,virtualenv,jupyternotebooks,visualstudiocode,macos,linux diff --git a/docker/run.sh b/docker/run.sh index 40627ad76..e000607c0 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -6,12 +6,12 @@ PROJ_DIR=`dirname ${THIS_DIR}` OUT_DIR=${PROJ_DIR}/output mkdir -p -m 777 ${OUT_DIR} -nvidia-docker run --rm -it \ +nvidia-docker run --rm -it --ipc=host \ -v ${PROJ_DIR}/data/kitti:/work/data/kitti \ -v ${PROJ_DIR}/models:/work/models \ -v ${OUT_DIR}:/work/output \ -v ${PROJ_DIR}/scripts:/work/scripts \ - -v ${PROJ_DIR}/weights:/work/weights \ + -v ${PROJ_DIR}/M3D-RPN-Release:/work/M3D-RPN-Release \ -p 8100:8100 \ --name m3d_rpn \ m3d_rpn /bin/bash diff --git a/scripts/test_rpn_3d.py b/scripts/test_rpn_3d.py index be0b7506e..294546d76 100644 --- a/scripts/test_rpn_3d.py +++ b/scripts/test_rpn_3d.py @@ -18,8 +18,8 @@ # ----------------------------------------- from lib.imdb_util import * -conf_path = 'weights/M3D-RPN-Release/m3d_rpn_depth_aware_test_config.pkl' -weights_path = 'weights/M3D-RPN-Release/m3d_rpn_depth_aware_test' +conf_path = 'M3D-RPN-Release/m3d_rpn_depth_aware_test_config.pkl' +weights_path = 'M3D-RPN-Release/m3d_rpn_depth_aware_test' # load config conf = edict(pickle_read(conf_path)) From f4e0d3b70545a817478c12f877b23aac6318106c Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sat, 25 Jul 2020 23:11:26 +0900 Subject: [PATCH 07/11] COPY scripts and models --- .dockerignore | 4 +++- docker/Dockerfile | 30 ++++++++++++------------------ docker/run.sh | 16 ++++++++++++---- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/.dockerignore b/.dockerignore index ad2463d2f..43d5c6828 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ * -!lib !data/kitti_split1/devkit !data/kitti_split1/setup_split.py !data/kitti_split1/test.txt @@ -10,3 +9,6 @@ !data/kitti_split2/kitti_ids_new.mat !data/kitti_split2/setup_split.py !docker/requirements.txt +!lib +!models +!scripts diff --git a/docker/Dockerfile b/docker/Dockerfile index 1f40aef09..83891c800 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -43,25 +43,19 @@ RUN conda install -y -c pytorch \ COPY docker/requirements.txt /tmp/requirements.txt RUN pip install -r /tmp/requirements.txt -# Build NMS +# Copy data/ and build KITTI devkit +RUN mkdir /work/data +COPY data/kitti_split1 /work/data/kitti_split1 +COPY data/kitti_split2 /work/data/kitti_split2 +RUN cd /work && sh data/kitti_split1/devkit/cpp/build.sh +RUN cd /work && sh data/kitti_split2/devkit/cpp/build.sh + +# Copy lib/ and build NMS COPY lib /work/lib RUN cd /work/lib/nms && make -# Build KITTI devkit for kitti_split1 -# TODO: check if this is necessary or not -RUN mkdir -p /work/data/kitti_split1 -COPY data/kitti_split1/devkit /work/data/kitti_split1/devkit -COPY data/kitti_split1/setup_split.py /work/data/kitti_split1/setup_split.py -COPY data/kitti_split1/test.txt /work/data/kitti_split1/test.txt -COPY data/kitti_split1/train.txt /work/data/kitti_split1/train.txt -COPY data/kitti_split1/trainval.txt /work/data/kitti_split1/trainval.txt -COPY data/kitti_split1/val.txt /work/data/kitti_split1/val.txt -RUN cd /work && sh data/kitti_split1/devkit/cpp/build.sh +# Copy models/ +COPY models /work/models -# Build KITTI devkit for kitti_split_2 -# TODO: check if this is necessary or not -RUN mkdir -p /work/data/kitti_split2 -COPY data/kitti_split2/devkit /work/data/kitti_split2/devkit -COPY data/kitti_split2/kitti_ids_new.mat /work/data/kitti_split2/kitti_ids_new.mat -COPY data/kitti_split2/setup_split.py /work/data/kitti_split2/setup_split.py -RUN cd /work && sh data/kitti_split2/devkit/cpp/build.sh +# Copy scripts/ +COPY scripts /work/scripts diff --git a/docker/run.sh b/docker/run.sh index e000607c0..bdb9c6373 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -3,15 +3,23 @@ THIS_DIR=$(cd $(dirname $0); pwd) PROJ_DIR=`dirname ${THIS_DIR}` +# NOTICE: Change `KITTI_DIR`, `WEIGHT_DIR`, and `OUT_DIR` bellow based on your settings +# NOTICE: The paths must be absolute ones! + +# Directory containing the input KITTI object3d data +KITTI_DIR=${PROJ_DIR}/data/kitti + +# Directory containing the pretrained weight and config (necessary to run testing) +WEIGHT_DIR=${PROJ_DIR}/M3D-RPN-Release + +# Directory to which training/testing results will be saved OUT_DIR=${PROJ_DIR}/output mkdir -p -m 777 ${OUT_DIR} nvidia-docker run --rm -it --ipc=host \ - -v ${PROJ_DIR}/data/kitti:/work/data/kitti \ - -v ${PROJ_DIR}/models:/work/models \ + -v ${KITTI_DIR}:/work/data/kitti \ + -v ${WEIGHT_DIR}:/work/M3D-RPN-Release \ -v ${OUT_DIR}:/work/output \ - -v ${PROJ_DIR}/scripts:/work/scripts \ - -v ${PROJ_DIR}/M3D-RPN-Release:/work/M3D-RPN-Release \ -p 8100:8100 \ --name m3d_rpn \ m3d_rpn /bin/bash From 8e4f7f93d384075aef8f89acb6eca5da3a49d53d Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sun, 26 Jul 2020 00:04:34 +0900 Subject: [PATCH 08/11] add README.md --- docker/README.md | 120 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 docker/README.md diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..33fe1d9fa --- /dev/null +++ b/docker/README.md @@ -0,0 +1,120 @@ +# M3D-RPN training and testing with nvidia-docker + +[Motoki Kimura](https://github.com/motokimura) + +Tested with: + +``` +- Ubuntu 18.04 LTS +- nvidia-driver==450.51.05 +- docker==19.03.12 +- nvidia-driver==2.4.0 +``` + +## Setup + +### nvidia-driver + +Install nvidia-driver appropriate to your NVIDIA GPU. + +### docker/nvidia-docker2 + +Install [docker](https://docs.docker.com/engine/install/ubuntu/) +and [nvidia-docker2](https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(version-2.0)). + +### KITTI + +Download the full [KITTI](http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d) detection dataset and extract them. + +Default path is set to `M3D-RPN/data/kitti`. + +### Pretrained weights + +Download a zip file by following [the original README](https://github.com/garrickbrazil/M3D-RPN#testing) +and extract it. + +Default path is set to `M3D-RPN/data/M3D-RPN-Release`. + +## Testing + +Build docker image: + +``` +./docker/build.sh +``` + +Run container: + +``` +./docker/run.sh +``` + +NOTICE: if your KITTI data or pretrained weights are not located in the default paths written above, +you need to update `KITTI_DIR` and `WEIGHT_DIR` defined in `run.sh`. + +Now you should be in the container, and can apply trainval spliting by: + +``` +(in container) python data/kitti_split1/setup_split.py +(in container) python data/kitti_split2/setup_split.py +``` + +Finally you can start testing: + +``` +(in container) python scripts/test_rpn_3d.py +``` + +Results will be saved under `M3D-RPN/data/output` +(defined by `OUT_DIR` in `run.sh`). + +## Training + +Build docker image: + +``` +./docker/build.sh +``` + +Run container: + +``` +./docker/run.sh +``` + +NOTICE: if your KITTI data or pretrained weights are not located in the default paths written above, +you need to update `KITTI_DIR` and `WEIGHT_DIR` defined in `run.sh`. + +Now you should be in the container, and can apply trainval spliting by: + +``` +(in container) python data/kitti_split1/setup_split.py +(in container) python data/kitti_split2/setup_split.py +``` + +Before training, launch visdom server: + +``` +(in container) python -m visdom.server -port 8100 -readonly +``` + +Launch **a new terminal (session)** and run a new process in the container: + +``` +./docker/exec.sh +``` + +Start training: + +``` +# First train the warmup (without depth-aware) +(in container) python scripts/train_rpn_3d.py --config=kitti_3d_multi_warmup + +# Then train the main experiment (with depth-aware) +(in container) python scripts/train_rpn_3d.py --config=kitti_3d_multi_main +``` + +The training status can be monitored at [http://localhost:8100](http://localhost:8100). + +Results will be saved under `M3D-RPN/data/output` +(defined by `OUT_DIR` in `run.sh`). From b5fc3d0eeacb783239c61010f9c0876526340af0 Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sun, 26 Jul 2020 11:03:57 +0900 Subject: [PATCH 09/11] update README.md --- docker/README.md | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/docker/README.md b/docker/README.md index 33fe1d9fa..9e8bf795a 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,35 +5,35 @@ Tested with: ``` -- Ubuntu 18.04 LTS -- nvidia-driver==450.51.05 -- docker==19.03.12 -- nvidia-driver==2.4.0 +- OS: Ubuntu 18.04 LTS +- NVIDIA Driver: 450.51.05 +- Docker: 19.03.12 +- NVIDIA Docker 2: 2.4.0 ``` ## Setup -### nvidia-driver +- **NVIDIA Driver** -Install nvidia-driver appropriate to your NVIDIA GPU. + Find an appropriate version from [here](https://www.nvidia.com/Download/index.aspx) and install it. -### docker/nvidia-docker2 +- **Docker & NVIDIA Docker 2** -Install [docker](https://docs.docker.com/engine/install/ubuntu/) -and [nvidia-docker2](https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(version-2.0)). + Install [Docker](https://docs.docker.com/engine/install/ubuntu/) +and [NVIDIA Docker 2](https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(version-2.0)). -### KITTI +- **KITTI** -Download the full [KITTI](http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d) detection dataset and extract them. + Download [KITTI 3D Object Detection](http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d) dataset and extract them. -Default path is set to `M3D-RPN/data/kitti`. + Default path is set to `M3D-RPN/data/kitti`. -### Pretrained weights +- **Pretrained weights** -Download a zip file by following [the original README](https://github.com/garrickbrazil/M3D-RPN#testing) + Download a zip file by following [the original README](https://github.com/garrickbrazil/M3D-RPN#testing) and extract it. -Default path is set to `M3D-RPN/data/M3D-RPN-Release`. + Default path is set to `M3D-RPN/data/M3D-RPN-Release`. ## Testing @@ -49,7 +49,7 @@ Run container: ./docker/run.sh ``` -NOTICE: if your KITTI data or pretrained weights are not located in the default paths written above, +Notice: if your KITTI data or pretrained weights are not located in the default paths written above, you need to update `KITTI_DIR` and `WEIGHT_DIR` defined in `run.sh`. Now you should be in the container, and can apply trainval spliting by: @@ -59,7 +59,7 @@ Now you should be in the container, and can apply trainval spliting by: (in container) python data/kitti_split2/setup_split.py ``` -Finally you can start testing: +Start testing: ``` (in container) python scripts/test_rpn_3d.py @@ -82,7 +82,7 @@ Run container: ./docker/run.sh ``` -NOTICE: if your KITTI data or pretrained weights are not located in the default paths written above, +Notice: if your KITTI data or pretrained weights are not located in the default paths written above, you need to update `KITTI_DIR` and `WEIGHT_DIR` defined in `run.sh`. Now you should be in the container, and can apply trainval spliting by: @@ -98,7 +98,8 @@ Before training, launch visdom server: (in container) python -m visdom.server -port 8100 -readonly ``` -Launch **a new terminal (session)** and run a new process in the container: +Launch **a new terminal**. +Then, start a new bash session in the container: ``` ./docker/exec.sh From c7ff52b48140220c5a2a95f2a9c65580748d636b Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sun, 26 Jul 2020 16:31:10 +0900 Subject: [PATCH 10/11] update README --- .gitignore | 3 +- docker/README.md | 70 +++++++++++++++++++++++++++++++++--------- docker/run.sh | 6 ++-- scripts/test_rpn_3d.py | 34 ++++++++++++++++++-- 4 files changed, 91 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 97490c840..bdc5dc2a3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,7 @@ /data/kitti_split2/training /data/kitti_split2/validation /output -/M3D-RPN-Release -/M3D-RPN-Release.zip +/weights # Created by https://www.toptal.com/developers/gitignore/api/python,virtualenv,jupyternotebooks,visualstudiocode,macos,linux # Edit at https://www.toptal.com/developers/gitignore?templates=python,virtualenv,jupyternotebooks,visualstudiocode,macos,linux diff --git a/docker/README.md b/docker/README.md index 9e8bf795a..0d1e21b38 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,4 +1,4 @@ -# M3D-RPN training and testing with nvidia-docker +# Train & Test M3D-RPN with NVIDIA Docker [Motoki Kimura](https://github.com/motokimura) @@ -11,29 +11,31 @@ Tested with: - NVIDIA Docker 2: 2.4.0 ``` +May work with other versions. + ## Setup - **NVIDIA Driver** - Find an appropriate version from [here](https://www.nvidia.com/Download/index.aspx) and install it. + Find an appropriate version to your NVIDIA device from [here](https://www.nvidia.com/Download/index.aspx) and install it. - **Docker & NVIDIA Docker 2** Install [Docker](https://docs.docker.com/engine/install/ubuntu/) and [NVIDIA Docker 2](https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(version-2.0)). -- **KITTI** +- **KITTI dataset** Download [KITTI 3D Object Detection](http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d) dataset and extract them. Default path is set to `M3D-RPN/data/kitti`. -- **Pretrained weights** +- **M3D-RPN weights** Download a zip file by following [the original README](https://github.com/garrickbrazil/M3D-RPN#testing) and extract it. - Default path is set to `M3D-RPN/data/M3D-RPN-Release`. + Default path is set to `M3D-RPN/weights/M3D-RPN-Release`. ## Testing @@ -49,8 +51,8 @@ Run container: ./docker/run.sh ``` -Notice: if your KITTI data or pretrained weights are not located in the default paths written above, -you need to update `KITTI_DIR` and `WEIGHT_DIR` defined in `run.sh`. +Notice: if your KITTI data or pretrained weights are not located in the default paths described above, +you have to update `KITTI_DIR` and `WEIGHT_DIR` in `run.sh`. Now you should be in the container, and can apply trainval spliting by: @@ -62,11 +64,46 @@ Now you should be in the container, and can apply trainval spliting by: Start testing: ``` -(in container) python scripts/test_rpn_3d.py +# trainval split #1 +(in container) python scripts/test_rpn_3d.py --config=weights/M3D-RPN-Release/m3d_rpn_depth_aware_val1_config.pkl --weight=weights/M3D-RPN-Release/m3d_rpn_depth_aware_val1 + +# trainval split #2 +(in container) python scripts/test_rpn_3d.py --config=weights/M3D-RPN-Release/m3d_rpn_depth_aware_val2_config.pkl --weight=weights/M3D-RPN-Release/m3d_rpn_depth_aware_val2 +``` + +After waiting for a while, you will see: + +``` +# trainval split #1 +test_iter m3d_rpn_depth_aware_val1 2d car --> easy: 0.9024, mod: 0.8367, hard: 0.6769 +test_iter m3d_rpn_depth_aware_val1 gr car --> easy: 0.2594, mod: 0.2118, hard: 0.1790 +test_iter m3d_rpn_depth_aware_val1 3d car --> easy: 0.2027, mod: 0.1706, hard: 0.1521 +test_iter m3d_rpn_depth_aware_val1 2d pedestrian --> easy: 0.6622, mod: 0.5838, hard: 0.5018 +test_iter m3d_rpn_depth_aware_val1 gr pedestrian --> easy: 0.1305, mod: 0.1160, hard: 0.1115 +test_iter m3d_rpn_depth_aware_val1 3d pedestrian --> easy: 0.1142, mod: 0.1128, hard: 0.1034 +test_iter m3d_rpn_depth_aware_val1 2d cyclist --> easy: 0.6680, mod: 0.4901, hard: 0.4206 +test_iter m3d_rpn_depth_aware_val1 gr cyclist --> easy: 0.1196, mod: 0.1013, hard: 0.1013 +test_iter m3d_rpn_depth_aware_val1 3d cyclist --> easy: 0.1050, mod: 0.1001, hard: 0.0909 ``` -Results will be saved under `M3D-RPN/data/output` -(defined by `OUT_DIR` in `run.sh`). +``` +# trainval split #2 +test_iter m3d_rpn_depth_aware_val2 2d car --> easy: 0.9362, mod: 0.8473, hard: 0.6765 +test_iter m3d_rpn_depth_aware_val2 gr car --> easy: 0.2686, mod: 0.2115, hard: 0.1714 +test_iter m3d_rpn_depth_aware_val2 3d car --> easy: 0.2040, mod: 0.1648, hard: 0.1334 +test_iter m3d_rpn_depth_aware_val2 2d pedestrian --> easy: 0.7691, mod: 0.6016, hard: 0.5192 +test_iter m3d_rpn_depth_aware_val2 gr pedestrian --> easy: 0.1340, mod: 0.1144, hard: 0.1151 +test_iter m3d_rpn_depth_aware_val2 3d pedestrian --> easy: 0.1280, mod: 0.1130, hard: 0.1117 +test_iter m3d_rpn_depth_aware_val2 2d cyclist --> easy: 0.5147, mod: 0.4277, hard: 0.3491 +test_iter m3d_rpn_depth_aware_val2 gr cyclist --> easy: 0.0290, mod: 0.0909, hard: 0.0909 +test_iter m3d_rpn_depth_aware_val2 3d cyclist --> easy: 0.0222, mod: 0.0909, hard: 0.0909 +``` + +Detailed results are saved under `M3D-RPN/data/output` +(defined as `OUT_DIR` in `run.sh`). + +You can test your own model by setting paths to the config and weight files +with `--weight` and `--config` options in the same way. ## Training @@ -82,8 +119,8 @@ Run container: ./docker/run.sh ``` -Notice: if your KITTI data or pretrained weights are not located in the default paths written above, -you need to update `KITTI_DIR` and `WEIGHT_DIR` defined in `run.sh`. +Notice: if your KITTI data or pretrained weights are not located in the default paths described above, +you have to update `KITTI_DIR` and `WEIGHT_DIR` defined in `run.sh`. Now you should be in the container, and can apply trainval spliting by: @@ -117,5 +154,10 @@ Start training: The training status can be monitored at [http://localhost:8100](http://localhost:8100). -Results will be saved under `M3D-RPN/data/output` -(defined by `OUT_DIR` in `run.sh`). +The training config, trained weights, etc. are saved under `M3D-RPN/data/output` +(defined as `OUT_DIR` in `run.sh`). + +You can configure hyper parameters (e.g., trainval split) by changing +`M3D-RPN/scripts/config/kitti_3d_multi_warmup.py` and `M3D-RPN/scripts/config/kitti_3d_multi_main.py`. + +Notice: if you want to change the hyperparameters, you have to change the files **before** executing `build.sh`. diff --git a/docker/run.sh b/docker/run.sh index bdb9c6373..dd98ddcef 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -9,8 +9,8 @@ PROJ_DIR=`dirname ${THIS_DIR}` # Directory containing the input KITTI object3d data KITTI_DIR=${PROJ_DIR}/data/kitti -# Directory containing the pretrained weight and config (necessary to run testing) -WEIGHT_DIR=${PROJ_DIR}/M3D-RPN-Release +# Directory containing the pretrained weight and config files +WEIGHT_DIR=${PROJ_DIR}/weights # Directory to which training/testing results will be saved OUT_DIR=${PROJ_DIR}/output @@ -18,7 +18,7 @@ mkdir -p -m 777 ${OUT_DIR} nvidia-docker run --rm -it --ipc=host \ -v ${KITTI_DIR}:/work/data/kitti \ - -v ${WEIGHT_DIR}:/work/M3D-RPN-Release \ + -v ${WEIGHT_DIR}:/work/weights \ -v ${OUT_DIR}:/work/output \ -p 8100:8100 \ --name m3d_rpn \ diff --git a/scripts/test_rpn_3d.py b/scripts/test_rpn_3d.py index 294546d76..f76a8e67e 100644 --- a/scripts/test_rpn_3d.py +++ b/scripts/test_rpn_3d.py @@ -18,15 +18,43 @@ # ----------------------------------------- from lib.imdb_util import * -conf_path = 'M3D-RPN-Release/m3d_rpn_depth_aware_test_config.pkl' -weights_path = 'M3D-RPN-Release/m3d_rpn_depth_aware_test' + +def parse_args(argv): + from getopt import getopt + opts, args = getopt(argv, '', ['config=', 'weight=', 'outdir=']) + # defaults (trainval split #1) + conf_path = 'weights/M3D-RPN-Release/m3d_rpn_depth_aware_val1_config.pkl' + weights_path = 'weights/M3D-RPN-Release/m3d_rpn_depth_aware_val1' + outdir = None + # read opts + for opt, arg in opts: + if opt in ('--config'): + conf_path = arg + if opt in ('--weight'): + weights_path = arg + if opt in ('--outdir'): + outdir = arg + + if outdir is None: + # if --outdir option is not used, give the weight file name to output directory + outdir = os.path.basename(weights_path) + + return conf_path, weights_path, outdir + + +conf_path, weights_path, outdir = parse_args(sys.argv[1:]) +print() +print('CONFIG: {}'.format(conf_path)) +print('WEIGHT: {}'.format(weights_path)) +print('OUTDIR: {}'.format(outdir)) +print() # load config conf = edict(pickle_read(conf_path)) conf.pretrained = None data_path = os.path.join(os.getcwd(), 'data') -results_path = os.path.join('output', 'tmp_results', 'data') +results_path = os.path.join('output', outdir, 'data') # make directory mkdir_if_missing(results_path, delete_if_exist=True) From d7ff59a20497be523b8656d79a67b34586b78707 Mon Sep 17 00:00:00 2001 From: Motoki Kimura Date: Sun, 26 Jul 2020 23:14:05 +0900 Subject: [PATCH 11/11] update README --- docker/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 0d1e21b38..5fe60ef7f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -160,4 +160,5 @@ The training config, trained weights, etc. are saved under `M3D-RPN/data/output` You can configure hyper parameters (e.g., trainval split) by changing `M3D-RPN/scripts/config/kitti_3d_multi_warmup.py` and `M3D-RPN/scripts/config/kitti_3d_multi_main.py`. -Notice: if you want to change the hyperparameters, you have to change the files **before** executing `build.sh`. +Notice: if you changed the files, you have to re-build and re-launch the container +to reflect the changes.