This commit is contained in:
2026-06-16 09:49:16 +08:00
parent 0e2b2f3994
commit e932b07fa6
2 changed files with 11 additions and 2 deletions
+1
View File
@@ -18,6 +18,7 @@ services:
- "10002:7860" - "10002:7860"
environment: environment:
- GRADIO_SERVER_NAME=0.0.0.0 - GRADIO_SERVER_NAME=0.0.0.0
- GRADIO_TEMP_DIR=/tmp/gradio
- MINERU_API_BASE=http://mineru-nginx:8000 - MINERU_API_BASE=http://mineru-nginx:8000
- MINERU_MODEL_SOURCE=${MINERU_MODEL_SOURCE:-huggingface} - MINERU_MODEL_SOURCE=${MINERU_MODEL_SOURCE:-huggingface}
- HF_HUB_CACHE=${HF_HUB_CACHE:-/opt/models/huggingface} - HF_HUB_CACHE=${HF_HUB_CACHE:-/opt/models/huggingface}
+10 -2
View File
@@ -100,8 +100,16 @@ async def process_pdf(file_obj, backend, lang, progress=gr.Progress()):
return "Please upload a PDF file.", "", "" return "Please upload a PDF file.", "", ""
tmp_dir = tempfile.mkdtemp(prefix="mineru-client-") tmp_dir = tempfile.mkdtemp(prefix="mineru-client-")
file_path = file_obj.name if hasattr(file_obj, "name") else os.path.join(tmp_dir, "input.pdf")
file_name = os.path.basename(file_path) # 兼容不同 Gradio 版本的 file 返回值
if isinstance(file_obj, str):
file_path = file_obj
file_name = os.path.basename(file_path)
elif hasattr(file_obj, 'name'):
file_path = file_obj.name
file_name = os.path.basename(file_path)
else:
return "Unsupported file object type", "", ""
async with httpx.AsyncClient(timeout=httpx.Timeout(120)) as client: async with httpx.AsyncClient(timeout=httpx.Timeout(120)) as client:
# 1. 探测 API # 1. 探测 API