Skip to content

Latest commit

 

History

History
111 lines (81 loc) · 2.98 KB

install.md

File metadata and controls

111 lines (81 loc) · 2.98 KB

1. Installation

1.1. Prerequisites

  • Linux (Windows is not officially supported now)
  • Python 3.7
  • Pytorch >= 1.6
  • torchvision 0.7.0
  • CUDA 10.1

Our version OS and packages versions we used for bellow tests was:

  • OS: Ubuntu 18.04
  • CUDA: 10.1
  • GCC (G++): 8.4.0 (CUDA 10.1 do not support for g++ version later 8)
  • Pytorch: 1.6.0
  • torchvision: 0.7.0

1.2. Installation introduction

  1. Create conda virtual environment and afterward activate it.
conda create -n gen_ocr python=3.7 -y
conda activate gen_ocr
  1. Install Pytorch and torchvision. following the official Pytorch instructions
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch
Make sure that your CUDA compilation and CUDA runtime is matched version in order to avoid unexpected error. To check your CUDA runtime version in termial `nvcc --version`.
  1. Clone general_ocr repository
git clone https://github.com/phamdinhkhanh/general_ocr.git
cd general_ocr
  1. Download onnxruntime-linux from ONNX Runtime releases, extract it, expose ONNXRUNTIME_DIR and finally add the lib path to LD_LIBRARY_PATH as below:
wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz

tar -zxvf onnxruntime-linux-x64-1.8.1.tgz
cd onnxruntime-linux-x64-1.8.1
export ONNXRUNTIME_DIR=$(pwd)
export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH
  1. Install onnxruntime
pip install onnxruntime==1.8.1
  1. Install build requirements packages.
cd .. # general_ocr root repository directory
pip install -r requirements.txt
GENERAL_OCR_WITH_OPS=1 GENERAL_OCR_WITH_ORT=1 python -m pip install -v -e .
export PYTHONPATH=$(pwd):$PYTHONPATH

1.3. Full set-up Script

Full setup script is there:

# create and activate conda enviroment
conda create -n gen_ocr python=3.7 -y
conda activate gen_ocr

# install pytorch and torchvision
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch

# clone general_ocr
git clone https://github.com/phamdinhkhanh/general_ocr.git
cd general_ocr

# download onnxruntime-linux and expose its lib to LD_LIBRARY_PATH
wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz

tar -zxvf onnxruntime-linux-x64-1.8.1.tgz
cd onnxruntime-linux-x64-1.8.1
export ONNXRUNTIME_DIR=$(pwd)
export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH

# install onnxruntime
pip install onnxruntime==1.8.1

# install requirements.txt
cd .. # general_ocr root repository directory
pip install -r requirements.txt
GENERAL_OCR_WITH_OPS=1 GENERAL_OCR_WITH_ORT=1 python -m pip install -v -e .
export PYTHONPATH=$(pwd):$PYTHONPATH

Run script below to test your installation is successful:

conda activate gen_ocr
python general_ocr/utils/ocr.py demo/demo_text_ocr.jpg --print-result --imshow --det PANet_IC15 --recog SEG