From 5caac1166df18e5d9aaa5c9c0662cb2a70599620 Mon Sep 17 00:00:00 2001 From: Yue Fei Date: Thu, 2 Jan 2025 14:49:21 +0800 Subject: [PATCH] Add paddle deps (#327) * Add paddle deps * Update ui --- Dockerfile | 15 +++++++++++++++ Dockerfile_gpu | 13 +++++++++++++ docs/develop/local_develop.md | 2 +- docs/develop/local_develop_zh.md | 2 +- src/pai_rag/app/web/webui.py | 15 ++++++++------- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index f86f4937..474a12fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Dockerfile_gpu b/Dockerfile_gpu index 96daa8a9..64fb764b 100644 --- a/Dockerfile_gpu +++ b/Dockerfile_gpu @@ -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 . . diff --git a/docs/develop/local_develop.md b/docs/develop/local_develop.md index f33b3c3e..59a76d5f 100644 --- a/docs/develop/local_develop.md +++ b/docs/develop/local_develop.md @@ -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 diff --git a/docs/develop/local_develop_zh.md b/docs/develop/local_develop_zh.md index 8f5913a0..8cc19c45 100644 --- a/docs/develop/local_develop_zh.md +++ b/docs/develop/local_develop_zh.md @@ -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. 【可选】本地工具-上传数据 diff --git a/src/pai_rag/app/web/webui.py b/src/pai_rag/app/web/webui.py index 174b8413..bc710c9c 100644 --- a/src/pai_rag/app/web/webui.py +++ b/src/pai_rag/app/web/webui.py @@ -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