x
This commit is contained in:
@@ -20,13 +20,7 @@ services:
|
||||
- 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}
|
||||
- MODELSCOPE_CACHE=${MODELSCOPE_CACHE:-/opt/models/modelscope}
|
||||
volumes:
|
||||
- ${INPUT_DIR:-./data/input}:/data/input:ro
|
||||
- ${OUTPUT_DIR:-./data/output}:/data/output
|
||||
- ${MODEL_DIR:-./data/models}:/opt/models
|
||||
- ./scripts:/opt/scripts:ro
|
||||
command:
|
||||
[
|
||||
|
||||
@@ -106,13 +106,15 @@ async def process_pdf(file_obj, backend, lang, progress=gr.Progress()):
|
||||
|
||||
tmp_dir = tempfile.mkdtemp(prefix="mineru-client-")
|
||||
|
||||
# 兼容不同 Gradio 版本的 file 返回值
|
||||
if isinstance(file_obj, str):
|
||||
# Gradio 6.0 binary mode:file_obj 是 bytes
|
||||
if isinstance(file_obj, bytes):
|
||||
file_path = os.path.join(tmp_dir, "input.pdf")
|
||||
file_name = "input.pdf"
|
||||
with open(file_path, "wb") as f:
|
||||
f.write(file_obj)
|
||||
elif 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", "", ""
|
||||
|
||||
@@ -208,7 +210,7 @@ def create_ui():
|
||||
file_input = gr.File(
|
||||
label="Upload PDF",
|
||||
file_types=[".pdf"],
|
||||
type="filepath",
|
||||
type="binary",
|
||||
)
|
||||
backend_dd = gr.Dropdown(
|
||||
label="Backend",
|
||||
|
||||
Reference in New Issue
Block a user