x
This commit is contained in:
@@ -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