Sign inSign up

apparvi/cv2020

By apparvi

Updated about 6 years ago

Jupyter/docker-stacks, variable inspector, OpenCV with extra, PyTorch

Image
0

232

apparvi/cv2020 repository overview

cv2020 Docker image

The image is based on last years image with some updated packages and PyTorch.

Command breakthrough

# Download image
docker pull apparvi/cv2020

# Create a container and run with:
docker run -it --name cv2020 --user $(id -u):$(id -g) --group-add users -v "$(pwd)":/home/jovyan/work -p 8888:8888 apparvi/cv2020 start.sh jupyter lab --NotebookApp.custom_display_url='http://127.0.0.1:8888' --notebook-dir=/home/jovyan/work

# Command explained (full command above):
# -it attach terminal
# --name cv2020 give a name to the container for easier reference later
# --user $(id -u):$(id -g) use your own user id and group id to get proper file permissions for the files created in shared volumes
# --group-add users add your user id to group users to get access to some important folders within the image
# -v "$(pwd)":/home/jovyan/work mount current wd to containers wd. In the image your user is "jovyan"(inhabitant of Jupyter)
# -p 8888:8888 map host port 8888 to be used for Jupyter Notebook
# apparvi/cv2020 specify the image to be used
# start-notebook.sh jupyter lab image entry point, use jupyter lab instead of notebook
# --NotebookApp.custom_display_url='http://127.0.0.1:8888' fix the terminal link
# --notebook-dir=/home/jovyan/work specify the Jupyter working directory

# Start the same container later
docker start -i cv2020

The DockerFile used to create this image:

FROM jupyter/scipy-notebook:2ce7c06a61a1

# update jupyterlab for the variableinspector extension
RUN conda update -c conda-forge jupyterlab

# Install jupyterlab_variableinspector extension
RUN git clone https://github.com/lckr/jupyterlab-variableInspector && \
    cd jupyterlab-variableInspector/ && \
    npm install && \
    npm run build && \
    jupyter labextension install .

# Install pyflinn, line_profiler
RUN pip install --upgrade pip && \
    conda update -n base conda && \
    conda install --quiet --yes pyflann line_profiler

# install older version of pytorch for the SSD code
RUN conda install --yes -c pytorch pytorch==1.2.0

# Building OpenCV

# Change, if you want to build with a different version of OpenCV
ENV OPENCV_VERSION 4.1.1

# Change to root
USER root

# Install OpenCV dependencies that are not already there
RUN apt-get update && apt-get install --yes \
    cmake \
    libgtk2.0-dev \
    libavcodec-dev \
    libavformat-dev \
    libswscale-dev

ENV OPENCV_CONTRIB_GIT_DIR=/opt/opencv_contrib
ENV OPENCV_GIT_DIR=/opt/opencv
ENV OPENCV_BUILD_DIR=/tmp/opencv/build
ENV CONDA_DIR=/opt/conda

RUN echo 'Prepare OpenCV extra modules' && \
    git clone https://github.com/opencv/opencv_contrib.git $OPENCV_CONTRIB_GIT_DIR && \
    cd $OPENCV_CONTRIB_GIT_DIR && \
    git checkout $OPENCV_VERSION && \
    echo 'Prepare OpenCV' && \
    git clone https://github.com/opencv/opencv.git $OPENCV_GIT_DIR && \
    cd $OPENCV_GIT_DIR && \
    git checkout $OPENCV_VERSION && \
    echo 'Prepare build (Python directories specified in the parent image)' && \
    mkdir -p $OPENCV_BUILD_DIR && \
    cd $OPENCV_BUILD_DIR && \
    cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_CONTRIB_GIT_DIR/modules \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D PYTHON3_EXECUTABLE=$CONDA_DIR/bin/python3.7 \
    -D PYTHON3_LIBRARY=$CONDA_DIR/lib/libpython3.7m.so \
    -D PYTHON3_INCLUDE_DIR=$CONDA_DIR/include/python3.7m \
    -D PYTHON3_NUMPY_INCLUDE_DIRS=$CONDA_DIR/lib/python3.7/site-packages/numpy/core/include \
    -D PYTHON3_PACKAGES_PATH=$CONDA_DIR/lib/python3.7/site-packages \
    $OPENCV_GIT_DIR && \
    echo 'Install' && \
    make -j $(nproc) && make install && ldconfig && \
    echo 'Clean installation and temporary files' && \
    rm -rf /opt/opencv* && \
    rm -rf /tmp/*

# Back to the default directory
WORKDIR /home/$NB_USER/work

# Switch back to jovyan to avoid accidental container runs as root
USER $NB_USER

Tag summary

Content type

Image

Digest

Size

4.1 GB

Last updated

about 6 years ago

docker pull apparvi/cv2020