Skip to content

Instantly share code, notes, and snippets.

@lazykyama
Created April 16, 2020 11:56
Show Gist options
  • Save lazykyama/0a94c844dd57ba97562ae6fddf48aeef to your computer and use it in GitHub Desktop.
Save lazykyama/0a94c844dd57ba97562ae6fddf48aeef to your computer and use it in GitHub Desktop.
Setup kocr environment based on Theano container.
# Dockerfile for kocr based on NGC's Theano container.
FROM nvcr.io/nvidia/theano:18.06
LABEL maintainer="lazykyama"
# Install dependencies.
RUN apt-get update && \
apt-get install -y openssl \
libssl-dev \
libtool-bin \
libcv-dev \
libhighgui-dev \
libcvaux-dev \
python-opencv && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip
RUN pip install pillow==5.0.0 h5py==2.7.1 Keras==2.1.4
# Set pkgconfig for OpenCV 2.4.9.1
ADD opencv.pc /usr/local/lib/pkgconfig/
# Set backend framework and memory layout as Keras default.
ADD dummy_import.py /opt
WORKDIR /opt
RUN python dummy_import.py && \
rm dummy_import.py && \
sed -i -e s/channels_last/channels_first/ ~/.keras/keras.json && \
sed -i -e s/tensorflow/theano/ ~/.keras/keras.json
# Checkout core codes.
RUN git clone https://github.com/faxocr/kocr.git && \
cd kocr && \
git fetch origin pull/3/head:replace_preprocessing && \
git checkout replace_preprocessing
RUN cd /opt/kocr/src && make
try:
import keras
except ImportError:
pass
# Package Information for pkg-config
prefix=/usr/local
exec_prefix=${prefix}
libdir=
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include
Name: OpenCV
Description: Open Source Computer Vision Library
Version: 2.4.9.1
Cflags: -I${includedir_old} -I${includedir_new}
Libs: -lopencv_video -lopencv_objdetect -lopencv_ml -lopencv_legacy -lopencv_imgproc -lopencv_highgui -lopencv_flann -lopencv_features2d -lopencv_core -lopencv_contrib -lopencv_calib3d -lrt -lpthread -lm -ldl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment