Skip to content

Commit

Permalink
Merge branch 'master-tr2'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	updateHistory.md
  • Loading branch information
alisen39 committed Jul 30, 2020
2 parents 96e319e + 1000efd commit b392361
Show file tree
Hide file tree
Showing 29 changed files with 333 additions and 249 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.git
fontend/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
backend/libtorch/lib/libtorch.so
test/

doc/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM python:3.7-slim

RUN sed -i 's#http://deb.debian.org#https://mirrors.163.com#g' /etc/apt/sources.list
RUN apt update && apt install -y libglib2.0-dev libsm6 libxrender1 libxext-dev supervisor
RUN apt update && apt install -y libglib2.0-dev libsm6 libxrender1 libxext-dev supervisor \
&& rm -rf /var/lib/apt/lists/*

RUN /usr/local/bin/python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
COPY ./requirements.txt ./TrWebOCR/
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ python backend/main.py
```

项目默认运行在8089端口,看到以下输出则代表运行成功:
```shell script
# tr 1.5.0 https://github.com/myhub/tr
server is running: 0.0.0.0:8089
```

``` shell script
python backend/main.py [--port=8089][--open_gpu=0]
# --port 指定运行时端口号 默认是8089
# --open_gpu 是否开启gpu 默认是0(不开启),可设置为1(开启)
```
### Docker部署
使用 Dockerfile 构建 或者直接 Pull镜像
```shell script
Expand Down Expand Up @@ -118,6 +118,10 @@ res = requests.post(url=url, data={'img': img_b64})
![验证码识别](https://images.alisen39.com/20200501173211.png)

## 更新记录

* 2020年07月26日
更新tr2.0版,支持GPU

* 2020年07月23日
修改README

Expand Down
Binary file removed backend/libtorch/lib/libc10.so
Binary file not shown.
Binary file removed backend/libtorch/lib/libcaffe2_detectron_ops.so
Binary file not shown.
Binary file not shown.
Binary file removed backend/libtorch/lib/libgomp-7c85b1e2.so.1
Binary file not shown.
Binary file removed backend/libtorch/lib/libtorch.so.part.0
Binary file not shown.
Binary file removed backend/libtorch/lib/libtorch.so.part.1
Binary file not shown.
Binary file removed backend/libtorch/lib/libtorch.so.part.2
Binary file not shown.
Binary file removed backend/libtorch/lib/libtorch.so.part.3
Binary file not shown.
Binary file removed backend/libtorch/lib/libtorch.so.part.4
Binary file not shown.
Binary file removed backend/libtorch/lib/libtorch.so.part.5
Binary file not shown.
Binary file removed backend/libtorch/lib/libtorch.so.part.6
Binary file not shown.
35 changes: 25 additions & 10 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
# time: 2020/4/28 14:54
import os
import sys

BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_PATH)

from tornado.options import define, options
import tornado.web
import tornado.httpserver
import tornado.ioloop
import logging
from tornado.web import StaticFileHandler

BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_PATH)
from backend.tools.get_host_ip import host_ip
from backend.webInterface import tr_run
from backend.webInterface import tr_index
from backend.tools import manage_running_platform
from backend.tools import log
import logging
logger = logging.getLogger(log.LOGGER_ROOT_NAME+'.'+__name__)


logger = logging.getLogger(log.LOGGER_ROOT_NAME + '.' + __name__)

current_path = os.path.dirname(__file__)
settings = dict(
Expand All @@ -27,6 +28,9 @@


def make_app():
from backend.webInterface import tr_run
from backend.webInterface import tr_index

return tornado.web.Application([
(r"/api/tr-run/", tr_run.TrRun),
(r"/", tr_index.Index),
Expand All @@ -37,14 +41,25 @@ def make_app():


if __name__ == "__main__":
define("port", default=8089, type=int, help='指定运行时端口号')
define("open_gpu", default=0, type=int, help='是否开启gpu')

tornado.options.parse_command_line()
port = options.port
open_gpu = options.open_gpu

port = 8089
if open_gpu == 0:
manage_running_platform.change_version('cpu')
else:
manage_running_platform.change_version('gpu')
app = make_app()

server = tornado.httpserver.HTTPServer(app)
# server.listen(port)
server.bind(port)
server.start(1)
print(f'server is running: {host_ip()}:{port}')
print(f'Server is running: http://{host_ip()}:{port}')
print(f'Now version is: {manage_running_platform.get_run_version()}')

# tornado.ioloop.IOLoop.instance().start()
tornado.ioloop.IOLoop.current().start()
Loading

0 comments on commit b392361

Please sign in to comment.