Skip to content

Commit

Permalink
feat(rapidocr_api): 为uvicorn日志添加时间戳 (#309)
Browse files Browse the repository at this point in the history
* Update README.md

* uvicorn 日志加时间戳

* Update README.md

* add vim for edit files in container

* Create readme.md

* Update readme.md

* Update README.md

* Delete python/rapidocr_paddle/ch_ppocr_det/readme.md

* Create readme.md

* Update readme.md

* Update readme.md
  • Loading branch information
imweijh authored Jan 1, 2025
1 parent 7bc2ac3 commit 8913c7a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
6 changes: 6 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ ENV DEBIAN_FRONTEND=noninteractive
# 设置工作目录
WORKDIR /app

# 安装vim,如果不需要临时修改容器文件,此步骤可以删
RUN apt-get update && \
apt-get install -y --no-install-recommends vim && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN set -eux; \
pip install --no-cache-dir rapidocr_api pillow rapidocr-onnxruntime==1.3.25 -i https://mirrors.aliyun.com/pypi/simple; \
pip uninstall -y opencv-python; \
Expand Down
32 changes: 30 additions & 2 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### See [Documentation](https://rapidai.github.io/RapidOCRDocs/install_usage/rapidocr_api/usage/)

### Dockerfile简单用法:
build时使用宿主的网络
```
docker build -t rapidocr_api:0.1.4 --network host .
Expand All @@ -12,10 +13,37 @@ build时使用宿主的网络

调试运行:
```
docker run --rm -p 9003:9003 --name rapidocr_api rapidocr_api:0.1.4
docker run --rm -p 9003:9003 --name rapidocr_api -e TZ=Asia/Shanghai rapidocr_api:0.1.4
```

运行:
```
docker run -d -p 9003:9003 --name rapidocr_api rapidocr_api:0.1.4
docker run -d -p 9003:9003 --name rapidocr_api -e TZ=Asia/Shanghai rapidocr_api:0.1.4
```

接口web界面:
```
http://<ip>:9003/docs
```

### Docker 临时修改并验证的方法:
```
docker run -p 9003:9003 --name rapidocr_api -e TZ=Asia/Shanghai rapidocr_api:0.1.4
```
进入container修改python源文件,Dockerfile最好加上apt-get install vim安装
```
docker exec -it rapidocr_api /bin/bash
cd /usr/local/lib/python3.10/site-packages/rapidocr_api
...
# 修改参数文件
vi /usr/local/lib/python3.10/site-packages/rapidocr_onnxruntime/config.yaml
# 改好后exit退出
```
重启container
```
docker restart rapidocr_api
```
查看日志:
```
docker logs -f rapidocr_api
```
6 changes: 6 additions & 0 deletions api/rapidocr_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,19 @@ def main():
"-workers", "--workers", type=int, default=1, help="number of worker process"
)
args = parser.parse_args()

# 修改 uvicorn 的默认日志配置
log_config = uvicorn.config.LOGGING_CONFIG
log_config["formatters"]["access"]["fmt"] = "%(asctime)s %(levelname)s %(message)s"
log_config["formatters"]["default"]["fmt"] = "%(asctime)s %(levelname)s %(message)s"

uvicorn.run(
"rapidocr_api.main:app",
host=args.ip,
port=args.port,
reload=0,
workers=args.workers,
log_config=log_config,
)


Expand Down
4 changes: 4 additions & 0 deletions python/rapidocr_onnxruntime/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## config.yaml 修改参数:
改大 `limit_side_len` 比如到 `1984` 会提升识别准确度,但会增加内存和识别变慢

可能需要同时调整改大 `box_thresh` ,比如到 `0.7`,避免引入噪音

0 comments on commit 8913c7a

Please sign in to comment.