├── Dockerfile.cpu ├── Dockerfile.gpu ├── Makefile ├── README.md └── recod_image ├── Dockerfile.cpu ├── Dockerfile.gpu └── Makefile /Dockerfile.cpu: -------------------------------------------------------------------------------- 1 | FROM tensorflow/tensorflow:1.11.0-py3 2 | MAINTAINER Miguel Rodriguez 3 | 4 | ENV OPENCV_VERSION 3.4.3 5 | ENV NUM_CORES 4 6 | 7 | # Install OpenCV 8 | RUN apt-get -y update -qq && \ 9 | apt-get -y install wget \ 10 | unzip \ 11 | 12 | # Required 13 | build-essential \ 14 | cmake \ 15 | git \ 16 | pkg-config \ 17 | libatlas-base-dev \ 18 | libgtk2.0-dev \ 19 | libavcodec-dev \ 20 | libavformat-dev \ 21 | libswscale-dev \ 22 | 23 | # Optional 24 | libtbb2 libtbb-dev \ 25 | libjpeg-dev \ 26 | libpng-dev \ 27 | libtiff-dev \ 28 | libv4l-dev \ 29 | libdc1394-22-dev \ 30 | 31 | qt4-default \ 32 | 33 | # Missing libraries for GTK 34 | libatk-adaptor \ 35 | libcanberra-gtk-module \ 36 | 37 | # Tools 38 | imagemagick \ 39 | 40 | # For use matplotlib.pyplot in python 41 | python3-tk \ 42 | python-tk 43 | WORKDIR / 44 | # Get OpenCV 45 | RUN git clone https://github.com/opencv/opencv.git &&\ 46 | cd opencv &&\ 47 | git checkout $OPENCV_VERSION &&\ 48 | cd / &&\ 49 | # Get OpenCV contrib modules 50 | git clone https://github.com/opencv/opencv_contrib &&\ 51 | cd opencv_contrib &&\ 52 | git checkout $OPENCV_VERSION &&\ 53 | mkdir /opencv/build &&\ 54 | cd /opencv/build &&\ 55 | 56 | # Lets build OpenCV 57 | cmake \ 58 | -D CMAKE_BUILD_TYPE=RELEASE \ 59 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 60 | 61 | -D INSTALL_C_EXAMPLES=OFF \ 62 | -D INSTALL_PYTHON_EXAMPLES=OFF \ 63 | 64 | -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ 65 | -D BUILD_EXAMPLES=OFF \ 66 | 67 | -D BUILD_NEW_PYTHON_SUPPORT=ON \ 68 | 69 | -D BUILD_DOCS=OFF \ 70 | -D BUILD_TESTS=OFF \ 71 | -D BUILD_PERF_TESTS=OFF \ 72 | -D WITH_TBB=ON \ 73 | -D WITH_OPENMP=ON \ 74 | -D WITH_IPP=ON \ 75 | -D WITH_CSTRIPES=ON \ 76 | -D WITH_OPENCL=ON \ 77 | -D WITH_V4L=ON \ 78 | .. &&\ 79 | make -j$NUM_CORES &&\ 80 | make install &&\ 81 | ldconfig &&\ 82 | 83 | # Clean the install from sources 84 | cd / &&\ 85 | rm -r /opencv &&\ 86 | rm -r /opencv_contrib 87 | 88 | RUN apt-get -y install libgtk-3-dev \ 89 | libboost-all-dev 90 | 91 | RUN pip3 install tflearn 92 | RUN pip3 install dlib 93 | RUN pip3 install imutils 94 | RUN pip3 install h5py 95 | RUN pip3 install tqdm 96 | RUN pip3 install jupyterlab 97 | RUN pip3 install urllib3 98 | RUN pip3 install mnist 99 | RUN pip3 install keras 100 | RUN pip3 install scikit-image 101 | 102 | CMD ["/bin/bash"] 103 | -------------------------------------------------------------------------------- /Dockerfile.gpu: -------------------------------------------------------------------------------- 1 | FROM tensorflow/tensorflow:1.11.0-gpu-py3 2 | MAINTAINER Miguel Rodriguez 3 | 4 | ENV OPENCV_VERSION 3.4.3 5 | ENV NUM_CORES 4 6 | 7 | 8 | # Install OpenCV 9 | RUN apt-get -y update -qq && \ 10 | apt-get -y install wget \ 11 | unzip \ 12 | 13 | # Required 14 | build-essential \ 15 | cmake \ 16 | git \ 17 | pkg-config \ 18 | libatlas-base-dev \ 19 | libgtk2.0-dev \ 20 | libavcodec-dev \ 21 | libavformat-dev \ 22 | libswscale-dev \ 23 | 24 | # Optional 25 | libtbb2 libtbb-dev \ 26 | libjpeg-dev \ 27 | libpng-dev \ 28 | libtiff-dev \ 29 | libv4l-dev \ 30 | libdc1394-22-dev \ 31 | 32 | qt4-default \ 33 | 34 | # Missing libraries for GTK 35 | libatk-adaptor \ 36 | libcanberra-gtk-module \ 37 | 38 | # Tools 39 | imagemagick \ 40 | 41 | # For use matplotlib.pyplot in python 42 | python3-tk \ 43 | python-tk 44 | 45 | WORKDIR / 46 | # Get OpenCV 47 | RUN git clone https://github.com/opencv/opencv.git &&\ 48 | cd opencv &&\ 49 | git checkout $OPENCV_VERSION &&\ 50 | cd / &&\ 51 | # Get OpenCV contrib modules 52 | git clone https://github.com/opencv/opencv_contrib &&\ 53 | cd opencv_contrib &&\ 54 | git checkout $OPENCV_VERSION &&\ 55 | mkdir /opencv/build &&\ 56 | cd /opencv/build &&\ 57 | 58 | # Lets build OpenCV 59 | cmake \ 60 | -D CMAKE_BUILD_TYPE=RELEASE \ 61 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 62 | 63 | -D INSTALL_C_EXAMPLES=OFF \ 64 | -D INSTALL_PYTHON_EXAMPLES=OFF \ 65 | 66 | -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ 67 | -D BUILD_EXAMPLES=OFF \ 68 | 69 | -D BUILD_NEW_PYTHON_SUPPORT=ON \ 70 | 71 | -D BUILD_DOCS=OFF \ 72 | -D BUILD_TESTS=OFF \ 73 | -D BUILD_PERF_TESTS=OFF \ 74 | -D WITH_TBB=ON \ 75 | -D WITH_OPENMP=ON \ 76 | -D WITH_IPP=ON \ 77 | -D WITH_CSTRIPES=ON \ 78 | -D WITH_OPENCL=ON \ 79 | -D WITH_V4L=ON \ 80 | .. &&\ 81 | make -j$NUM_CORES &&\ 82 | make install &&\ 83 | ldconfig &&\ 84 | 85 | # Clean the install from sources 86 | cd / &&\ 87 | rm -r /opencv &&\ 88 | rm -r /opencv_contrib 89 | 90 | RUN apt-get -y install libgtk-3-dev \ 91 | libboost-all-dev 92 | 93 | 94 | RUN pip3 install tflearn 95 | RUN pip3 install dlib 96 | RUN pip3 install imutils 97 | RUN pip3 install h5py 98 | RUN pip3 install tqdm 99 | RUN pip3 install jupyterlab 100 | RUN pip3 install urllib3 101 | RUN pip3 install mnist 102 | RUN pip3 install keras 103 | RUN pip3 install scikit-image 104 | 105 | CMD ["/bin/bash"] 106 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # COMMANDS 2 | DOCKER_COMMAND=docker 3 | NVIDIA_DOCKER_COMMAND=nvidia-docker 4 | CPU_DOCKER_FILE=Dockerfile.cpu 5 | GPU_DOCKER_FILE=Dockerfile.gpu 6 | SVC=tensorflow-opencv-py3 7 | VERSION_CPU=latest-cpu 8 | VERSION_GPU=latest-gpu 9 | REGISTRY_URL=so77id 10 | 11 | 12 | build-cpu bc: 13 | @echo "[build] Building cpu docker image..." 14 | @$(DOCKER_COMMAND) build -t $(REGISTRY_URL)/$(SVC):$(VERSION_CPU) -f $(CPU_DOCKER_FILE) . 15 | @echo "[build] Delete old versions..." 16 | @$(DOCKER_COMMAND) images|sed "1 d"|grep " *"|awk '{print $$3}'|sort|uniq|xargs $(DOCKER_COMMAND) rmi -f 17 | build-gpu bg: 18 | @echo "[build] Building gpu docker image..." 19 | @$(DOCKER_COMMAND) build -t $(REGISTRY_URL)/$(SVC):$(VERSION_GPU) -f $(GPU_DOCKER_FILE) . 20 | @echo "[build] Delete old versions..." 21 | @$(DOCKER_COMMAND) images|sed "1 d"|grep " *"|awk '{print $$3}'|sort|uniq|xargs $(DOCKER_COMMAND) rmi -f 22 | run-cpu rc: 23 | @echo "[run] Running cpu docker image..." 24 | @$(DOCKER_COMMAND) run -t -i $(REGISTRY_URL)/$(SVC):$(VERSION_CPU) 25 | run-gpu rg: 26 | @echo "[run] Running gpu docker image..." 27 | @$(NVIDIA_DOCKER_COMMAND) run -t -i $(REGISTRY_URL)/$(SVC):$(VERSION_GPU) 28 | upload-cpu uc: 29 | @echo "[upload] Uploading cpu docker image..." 30 | @$(DOCKER_COMMAND) push $(REGISTRY_URL)/$(SVC):$(VERSION_CPU) 31 | upload-gpu ug: 32 | @echo "[upload] Uploading gpu docker image..." 33 | @$(DOCKER_COMMAND) push $(REGISTRY_URL)/$(SVC):$(VERSION_GPU) 34 | clean c: 35 | @echo "[clean] Cleaning docker images..." 36 | @$(DOCKER_COMMAND) rmi -f $(REGISTRY_URL)/$(SVC):$(VERSION_CPU) 37 | @$(DOCKER_COMMAND) rmi -f $(REGISTRY_URL)/$(SVC):$(VERSION_GPU) 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Python3-Tensorflow-OpenCV3 2 | 3 | A docker version with `python3`, `tensorflow:lastest` and `opencv 3` for compile and test everything Tensorflow-OpenCV based application 4 | 5 | ## Execute scripts 6 | 7 | The following script will execute the scripts `/script/to/run; /or/set/of/them` as if they were run on your machine. 8 | 9 | In order to see what is going inside the docker we need to sync the displays with: 10 | 11 | `--env DISPLAY=$DISPLAY --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw"` if you use **Linux based systems**. 12 | 13 | `-e DISPLAY=${HOST_IP}:0` if you use **OSX systems**. 14 | 15 | 16 | Also, we will share the source code directories `-v=$(pwd)/..:$(pwd)/..` (this assumes you are doing an out-of-source build and you have a parent directory with the `build` and `src` as children). And we set the current directory as our working directory `-w=$(pwd)`. 17 | 18 | CPU version: 19 | 20 | docker run -it --rm \ 21 | --env DISPLAY=$DISPLAY --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ 22 | -v=$(pwd)/..:$(pwd)/.. -w=$(pwd) \ 23 | tensorflow-opencv-cpu-py3 \ 24 | /script/to/run; /or/set/of/them 25 | 26 | GPU version: 27 | 28 | nvidia-docker run -it --rm \ 29 | --env DISPLAY=$DISPLAY --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ 30 | -v=$(pwd)/..:$(pwd)/.. -w=$(pwd) \ 31 | tensorflow-opencv-gpu-py3 \ 32 | /script/to/run; /or/set/of/them 33 | 34 | or if you want enter in the image use the `Makefile` commands: 35 | 36 | Enter cpu version 37 | 38 | make run-cpu 39 | 40 | Enter cpu version 41 | 42 | make run-gpu 43 | 44 | 45 | ## Build the image locally 46 | 47 | You can build the image locally by executing the `Makefile` 48 | 49 | Creating cpu version 50 | 51 | make build-cpu 52 | 53 | Creating gpu version 54 | 55 | make build-gpu 56 | 57 | 58 | Based on this [repo](https://github.com/adinriv/docker-opencv) 59 | 60 | -------------------------------------------------------------------------------- /recod_image/Dockerfile.cpu: -------------------------------------------------------------------------------- 1 | FROM so77id/tensorflow-opencv-py3:latest-cpu 2 | MAINTAINER Miguel Rodriguez 3 | 4 | RUN pip3 install moviepy requests imageio==2.4.1 5 | RUN python3 -c 'import moviepy.editor as mpy' 6 | 7 | RUN pip3 install git+https://github.com/wookayin/tensorflow-plot.git@master 8 | 9 | RUN pip install slackclient 10 | 11 | RUN pip3 install torch torchvision 12 | 13 | RUN pip3 install tensorboardX 14 | 15 | RUN git clone https://github.com/so77id/torch_videovision.git 16 | 17 | ENV PYTHONPATH=$PYTHONPATH:/torch_videovision 18 | 19 | RUN pip3 install sp 20 | 21 | RUN pip3 install dgl 22 | 23 | RUN pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib 24 | 25 | CMD ["/bin/bash"] 26 | -------------------------------------------------------------------------------- /recod_image/Dockerfile.gpu: -------------------------------------------------------------------------------- 1 | FROM so77id/tensorflow-opencv-py3:latest-gpu 2 | MAINTAINER Miguel Rodriguez 3 | 4 | RUN pip3 install moviepy requests imageio==2.4.1 5 | RUN python3 -c 'import moviepy.editor as mpy' 6 | 7 | RUN pip3 install git+https://github.com/wookayin/tensorflow-plot.git@master 8 | 9 | RUN pip install slackclient 10 | 11 | RUN pip3 install torch torchvision 12 | 13 | RUN pip3 install tensorboardX 14 | 15 | RUN git clone https://github.com/so77id/torch_videovision.git 16 | 17 | ENV PYTHONPATH=$PYTHONPATH:/torch_videovision 18 | 19 | RUN pip3 install sp 20 | 21 | RUN pip3 install dgl 22 | 23 | RUN pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib 24 | 25 | CMD ["/bin/bash"] 26 | -------------------------------------------------------------------------------- /recod_image/Makefile: -------------------------------------------------------------------------------- 1 | # COMMANDS 2 | DOCKER_COMMAND=docker 3 | NVIDIA_DOCKER_COMMAND=nvidia-docker 4 | CPU_DOCKER_FILE=Dockerfile.cpu 5 | GPU_DOCKER_FILE=Dockerfile.gpu 6 | SVC=mrodriguez-recod 7 | VERSION_CPU=latest-cpu 8 | VERSION_GPU=latest-gpu 9 | REGISTRY_URL=so77id 10 | 11 | 12 | build-cpu bc: 13 | @echo "[build] Building cpu docker image..." 14 | @$(DOCKER_COMMAND) build -t $(REGISTRY_URL)/$(SVC):$(VERSION_CPU) -f $(CPU_DOCKER_FILE) . 15 | @echo "[build] Delete old versions..." 16 | @$(DOCKER_COMMAND) images|sed "1 d"|grep " *"|awk '{print $$3}'|sort|uniq|xargs $(DOCKER_COMMAND) rmi -f 17 | build-gpu bg: 18 | @echo "[build] Building gpu docker image..." 19 | @$(DOCKER_COMMAND) build -t $(REGISTRY_URL)/$(SVC):$(VERSION_GPU) -f $(GPU_DOCKER_FILE) . 20 | @echo "[build] Delete old versions..." 21 | @$(DOCKER_COMMAND) images|sed "1 d"|grep " *"|awk '{print $$3}'|sort|uniq|xargs $(DOCKER_COMMAND) rmi -f 22 | run-cpu rc: 23 | @echo "[run] Running cpu docker image..." 24 | @$(DOCKER_COMMAND) run -t -i $(REGISTRY_URL)/$(SVC):$(VERSION_CPU) 25 | run-gpu rg: 26 | @echo "[run] Running gpu docker image..." 27 | @$(NVIDIA_DOCKER_COMMAND) run -t -i $(REGISTRY_URL)/$(SVC):$(VERSION_GPU) 28 | upload-cpu uc: 29 | @echo "[upload] Uploading cpu docker image..." 30 | @$(DOCKER_COMMAND) push $(REGISTRY_URL)/$(SVC):$(VERSION_CPU) 31 | upload-gpu ug: 32 | @echo "[upload] Uploading gpu docker image..." 33 | @$(DOCKER_COMMAND) push $(REGISTRY_URL)/$(SVC):$(VERSION_GPU) 34 | clean c: 35 | @echo "[clean] Cleaning docker images..." 36 | @$(DOCKER_COMMAND) rmi -f $(REGISTRY_URL)/$(SVC):$(VERSION_CPU) 37 | @$(DOCKER_COMMAND) rmi -f $(REGISTRY_URL)/$(SVC):$(VERSION_GPU) 38 | --------------------------------------------------------------------------------