chineseocr / chineseocr

yolo3+ocr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chineseocr的gpu版本的docker镜像已经实现, 采用接口方式

GandalfLiu opened this issue · comments

docker pull ld1995docker/chineseocr:latest

直接拉取镜像运行 docker run --gpus all -d -p 8080:8080 chineseocr:latest 最后在通过接口方式实现识别 localhost:8080/ocr 就是接口, 部署采用gunicorn

字段

import requests
files = {"file": ("file_name", open(path, "rb"), "image/png")}
requests.post(url, files=files)
配置
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.67       Driver Version: 418.67       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla P4            On   | 00000000:00:08.0 Off |                    0 |
| N/A   41C    P0    23W /  75W |   7447MiB /  7611MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     15054      C   /root/miniconda3/bin/python                 7437MiB |
+-----------------------------------------------------------------------------+

机器要求:安装好了nvidia驱动, 可以不用安装cuda, 安装的docker 版本大于等于19.03 ,安装nvidia-docker github地址: https://github.com/NVIDIA/nvidia-docker

贴一下Dockerfile

FROM nvidia/cuda:9.0-cudnn7-devel
MAINTAINER xxx
LABEL version="1.0"
EXPOSE 8080
WORKDIR /ocr
ADD . /ocr
RUN apt-get update 
RUN apt-get install libglib2.0 libsm6 libxrender1 libxext-dev gcc -y
# 下载miniconda并且将Miniconda3-latest-Linux-x86_64.sh放在chineseocr文件中使用3.6的python环境
RUN cd /ocr/chineseocr && sh -c '/bin/echo -e "\nyes\n\nyes" | sh Miniconda3-latest-Linux-x86_64.sh'
RUN echo -e "\ny" && /root/miniconda3/bin/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
RUN /root/miniconda3/bin/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
RUN /root/miniconda3/bin/conda config --set show_channel_urls yes
RUN /root/miniconda3/bin/conda install python=3.6
RUN echo -e "\ny" && /root/miniconda3/bin/conda install -c conda-forge mahotas
RUN echo -e "\ny" && /root/miniconda3/bin/pip install flask jieba easydict opencv-contrib-python==4.0.0.21 Cython h5py pandas requests bs4 gunicorn matplotlib lxml -i https://mirrors.aliyun.com/pypi/simple
RUN /root/miniconda3/bin/pip install web.py==0.40.dev0 -i https://mirrors.aliyun.com/pypi/simple
RUN /root/miniconda3/bin/pip install -U pillow -i https://mirrors.aliyun.com/pypi/simple
RUN /root/miniconda3/bin/pip install keras==2.1.5 tensorflow==1.8 tensorflow-gpu==1.8 -i https://mirrors.aliyun.com/pypi/simple
RUN cd /ocr/pack && /root/miniconda3/bin/pip install * -i https://mirrors.aliyun.com/pypi/simple
RUN cd /ocr/pack && rm *
RUN cd /root && mkdir logs && cd logs && touch access.log && touch error.log
CMD ["/root/miniconda3/bin/gunicorn", "--chdir", "/ocr/chineseocr", "example:app", "-c", "/ocr/chineseocr/gconfig.py"]
ENV LANG C.UTF-8 LC_ALL=C.UTF-8
commented

近期会升级到tf2.0