x
This commit is contained in:
@@ -18,6 +18,7 @@ services:
|
||||
- "10002:7860"
|
||||
environment:
|
||||
- GRADIO_SERVER_NAME=0.0.0.0
|
||||
- GRADIO_TEMP_DIR=/tmp/gradio
|
||||
- MINERU_API_BASE=http://mineru-nginx:8000
|
||||
- MINERU_MODEL_SOURCE=${MINERU_MODEL_SOURCE:-huggingface}
|
||||
- HF_HUB_CACHE=${HF_HUB_CACHE:-/opt/models/huggingface}
|
||||
|
||||
@@ -100,8 +100,16 @@ async def process_pdf(file_obj, backend, lang, progress=gr.Progress()):
|
||||
return "Please upload a PDF file.", "", ""
|
||||
|
||||
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:
|
||||
# 1. 探测 API
|
||||
|
||||
Reference in New Issue
Block a user