From 17dbeec45c9827b524e162468db3d8f26553af06 Mon Sep 17 00:00:00 2001 From: Aymeric DUJARDIN Date: Fri, 14 Jun 2019 19:06:20 +0200 Subject: [PATCH] Improving README + docker fix --- README.md | 40 +++++++++++++++++++++++++++++++++++----- cmake_apt_update.sh | 19 +++++++++++++++++++ docker/Dockerfile | 19 ++++++++++++------- docker/README.md | 11 +++-------- 4 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 cmake_apt_update.sh diff --git a/README.md b/README.md index 1e2fc8b1a..c6ee526bc 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,42 @@ This is a brief explanation on how to enable the ZED camera support. - Windows 7 64bits or later, Ubuntu 16.04 or 18.04 - [ZED SDK](https://www.stereolabs.com/developers/) and its dependencies ([CUDA](https://developer.nvidia.com/cuda-downloads)) -- **Darknet** : https://github.com/AlexeyAB/darknet +- **Darknet** : https://github.com/AlexeyAB/darknet and its dependencies ([cuDNN](https://developer.nvidia.com/cudnn) and OpenCV) -## Installing Darknet +## Preparing Darknet installation + +### cuDNN + +In order to get the best performance, [cuDNN](https://developer.nvidia.com/cudnn) should be install before compiling darknet. Heads over to this [TensorFlow documentation article](https://www.tensorflow.org/install/gpu#install_cuda_with_apt) which explains how to setup both CUDA and cuDNN on Ubuntu and Windows. + +### OpenCV + +OpenCV binaries can be downloaded and install from [opencv.org](https://opencv.org/releases/). + +Alternatively, on Ubuntu : + + sudo apt install pkg-config libopencv-dev + +### CMake + +On Windows, download and install CMAKE using the binary [available here](https://cmake.org/download/). + +On Ubuntu, cmake can be installed using the package manager, i.e : `sudo apt install cmake` + +However the default version of cmake might be too old, it can easily be updated using the script (located in this repository): + +```bash +sudo bash cmake_apt_update.sh +``` + +## Compiling Darknet [Download](https://github.com/AlexeyAB/darknet) and compile darknet, following the instructions: - [How to compile on Linux](https://github.com/AlexeyAB/darknet#how-to-compile-on-linux) - [How to compile on Windows](https://github.com/AlexeyAB/darknet#how-to-compile-on-windows-using-vcpkg) -### ZED Support Using CMake +### ZED Support Using CMake (recommended) If the ZED SDK is installed, CMake will automatically detect it and compile with the ZED support. During the CMake configuration, a message will confirm that the ZED SDK was found. @@ -33,17 +59,21 @@ If the ZED SDK is installed, CMake will automatically detect it and compile with -- Found OpenMP_C: -fopenmp (found version "4.5") ... + ### ZED support Using Makefile To enable the ZED support in YOLO using the Makefile, simply enable [`GPU` and `ZED_CAMERA`](https://github.com/AlexeyAB/darknet/blob/cce34712f6928495f1fbc5d69332162fc23491b9/Makefile#L8), it's also recommended to enable `CUDNN` for improved performances. ## 2. Launching the sample - ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights zed_camera +Download the yolo weights, either [yolov3](https://pjreddie.com/media/files/yolov3.weights) or [yolov3-tiny](https://pjreddie.com/media/files/yolov3-tiny.weights) for instance, and put them in the local folder. + + + ./uselib data/coco.names cfg/yolov3.cfg yolov3.weights zed_camera SVO files are also supported : - ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights /path/to/svo/file.svo + ./uselib data/coco.names cfg/yolov3.cfg yolov3.weights /path/to/svo/file.svo ## How to use YOLO 3D in Python diff --git a/cmake_apt_update.sh b/cmake_apt_update.sh new file mode 100644 index 000000000..696ceda94 --- /dev/null +++ b/cmake_apt_update.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit +fi + +# https://apt.kitware.com/ +if [ -n "$(uname -a | grep Ubuntu)" ]; then + apt-get update ; apt-get install lsb-release apt-transport-https ca-certificates gnupg software-properties-common wget -y + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - + codename=`lsb_release --codename | cut -f2` + apt-add-repository 'deb https://apt.kitware.com/ubuntu/ '$codename' main' + apt-get install kitware-archive-keyring + apt-key --keyring /etc/apt/trusted.gpg del C1F34CDD40CD72DA + apt-get cmake +else + echo "This script is only meant for Ubuntu" +fi \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index e6cfcc3b1..9c7390865 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,10 +1,10 @@ -FROM stereolabs/zed:ubuntu1604-cuda9.0-zed2.7-gl +FROM stereolabs/zed:ubuntu1604-cuda9.0-zed2.8-gl ENV CUDNN_VERSION 7.4.1.5 -RUN apt-get update && apt-get upgrade -y -RUN apt-get install python3-dev python3-pip unzip sudo libopencv-dev -y -RUN apt-get install -y --no-install-recommends libcudnn7=$CUDNN_VERSION-1+cuda9.0 libcudnn7-dev=$CUDNN_VERSION-1+cuda9.0 && apt-mark hold libcudnn7 +RUN apt-get update && apt-get upgrade -y ; \ + apt-get install python3-dev python3-pip unzip sudo libopencv-dev apt-transport-https ca-certificates gnupg software-properties-common wget -y ; \ + apt-get install -y --no-install-recommends libcudnn7=$CUDNN_VERSION-1+cuda9.0 libcudnn7-dev=$CUDNN_VERSION-1+cuda9.0 && apt-mark hold libcudnn7 RUN sudo chmod 777 -R /usr/local/zed ; \ pip3 install --upgrade pip opencv-python ; \ @@ -15,12 +15,17 @@ USER docker WORKDIR /home/docker RUN git clone http://github.com/stereolabs/zed-python.git ; \ - cd zed-python; sudo pip3 install -r requirements.txt; sudo python3 setup.py install + cd zed-python; sudo pip3 install -r requirements.txt; sudo python3 setup.py install ; cd .. ; sudo rm -rf zed-python RUN git clone https://github.com/stereolabs/zed-yolo.git ; \ - cd zed-yolo/libdarknet ; make -j8 + cd zed-yolo ; sudo bash cmake_apt_update.sh ; \ + cd libdarknet ; make -j8 + +RUN git clone https://github.com/alexeyAB/darknet.git ; \ + cd darknet ; cmake . ; make -j8 WORKDIR /home/docker/zed-yolo/ RUN wget https://pjreddie.com/media/files/yolov3-tiny.weights ; \ - ln -s /home/docker/zed-yolo/yolov3-tiny.weights /home/docker/zed-yolo/zed_python_sample/ + ln -s /home/docker/zed-yolo/yolov3-tiny.weights /home/docker/zed-yolo/zed_python_sample/ ; \ + ln -s /home/docker/zed-yolo/yolov3-tiny.weights /home/docker/darknet/ CMD /bin/bash diff --git a/docker/README.md b/docker/README.md index 7a93505d2..5de11f348 100644 --- a/docker/README.md +++ b/docker/README.md @@ -35,14 +35,9 @@ python3 darknet_zed.py -s /data/ ### Run the C++ sample -From within the container compile the C++ sample : +From within the container the C++ sample can be started : ```Bash -cd /home/docker/zed-yolo/zed_cpp_sample/ ; mkdir build ; cd build; cmake .. ; make ; cd /home/docker/zed-yolo/ -``` - -Then start it : - -```Bash -zed_cpp_sample/build/darknet_zed libdarknet/data/coco.names libdarknet/cfg/yolov3-tiny.cfg yolov3-tiny.weights /data/ +cd ~/darknet +./uselib libdarknet/data/coco.names libdarknet/cfg/yolov3-tiny.cfg yolov3-tiny.weights /data/ ```