Skip to content

Commit

Permalink
Add paddle deps (#327)
Browse files Browse the repository at this point in the history
* Add paddle deps

* Update ui
  • Loading branch information
moria97 authored Jan 2, 2025
1 parent 99869bd commit 5caac11
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ ENV VIRTUAL_ENV=/app/.venv \
ENABLE_HTTPX=false

RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 curl

# setup paddleocr dependencies
RUN mkdir -p /root/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer \
&& curl https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_det_infer.tar -o /root/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer/ch_PP-OCRv4_det_infer.tar \
&& tar xvf /root/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer/ch_PP-OCRv4_det_infer.tar -C /root/.paddleocr/whl/det/ch/

RUN mkdir -p /root/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer \
&& curl https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_rec_infer.tar -o /root/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer/ch_PP-OCRv4_rec_infer.tar \
&& tar xvf /root/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer/ch_PP-OCRv4_rec_infer.tar -C /root/.paddleocr/whl/rec/ch/

RUN mkdir -p /root/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer \
&& curl https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar -o /root/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.tar \
&& tar xvf /root/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.tar -C /root/.paddleocr/whl/cls/

WORKDIR /app

COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY . .
CMD ["pai_rag", "serve"]
13 changes: 13 additions & 0 deletions Dockerfile_gpu
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ ENV VIRTUAL_ENV=/app/.venv \

RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 curl

# setup paddleocr dependencies
RUN mkdir -p /root/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer \
&& curl https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_det_infer.tar -o /root/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer/ch_PP-OCRv4_det_infer.tar \
&& tar xvf /root/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer/ch_PP-OCRv4_det_infer.tar -C /root/.paddleocr/whl/det/ch/

RUN mkdir -p /root/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer \
&& curl https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_rec_infer.tar -o /root/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer/ch_PP-OCRv4_rec_infer.tar \
&& tar xvf /root/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer/ch_PP-OCRv4_rec_infer.tar -C /root/.paddleocr/whl/rec/ch/

RUN mkdir -p /root/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer \
&& curl https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar -o /root/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.tar \
&& tar xvf /root/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.tar -C /root/.paddleocr/whl/cls/

WORKDIR /app
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/local_develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ For local development, please refer to the following steps:
pai_rag ui [--host HOST] [--port PORT] [rag-url RAG_URL]
```

You can also open http://localhost:8002/admin/ to configure the RAG service and upload local data.
You can also open http://localhost:8002/ to configure the RAG service and upload local data.

6. [Optional] Local load_data tool

Expand Down
2 changes: 1 addition & 1 deletion docs/develop/local_develop_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
pai_rag ui [--host HOST] [--port PORT] [rag-url RAG_URL]
```

你也可以打开http://localhost:8002/admin/ 来配置RAG服务以及上传本地数据。
你也可以打开http://localhost:8002/ 来配置RAG服务以及上传本地数据。

6. 【可选】本地工具-上传数据

Expand Down
15 changes: 8 additions & 7 deletions src/pai_rag/app/web/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ def make_homepage():

def configure_webapp(app: FastAPI, web_url, rag_url=DEFAULT_LOCAL_URL) -> gr.Blocks:
rag_client.set_endpoint(rag_url)
home = make_homepage()
home.queue(concurrency_count=1, max_size=64)
home._queue.set_url(urljoin(web_url, "admin/"))
logger.info(f"web_url: {web_url}")
gr.mount_gradio_app(app, home, path="/admin")

chat_page = create_chat_ui()
chat_page.queue(concurrency_count=1, max_size=64)
chat_page._queue.set_url(urljoin(web_url, "/"))
gr.mount_gradio_app(app, chat_page, path="/")
chat_page._queue.set_url(urljoin(web_url, "chat/"))
gr.mount_gradio_app(app, chat_page, path="/chat")

home = make_homepage()
home.queue(concurrency_count=1, max_size=64)
home._queue.set_url(urljoin(web_url, "/"))
logger.info(f"web_url: {web_url}")
gr.mount_gradio_app(app, home, path="/")
return

0 comments on commit 5caac11

Please sign in to comment.