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