| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import base64
- import os
- import requests
- API_URL = "https://q8d4u1u6c45dn7pd.aistudio-app.com/layout-parsing"
- TOKEN = "16455708d55afac2f074f4ae5a88fc6c7bae7920"
- file_path = "E:\\project\\arbitration_system\\evidence_extractor\\test\\F86-ZC1-2023-0001\\证人证言\\F86-ZC1-2023-0001-009_04.png"
- with open(file_path, "rb") as file:
- file_bytes = file.read()
- file_data = base64.b64encode(file_bytes).decode("ascii")
- headers = {
- "Authorization": f"token {TOKEN}",
- "Content-Type": "application/json"
- }
- payload = {
- "file": file_data,
- "fileType": 1,
- "useDocOrientationClassify": False,
- "useDocUnwarping": False,
- "useChartRecognition": False,
- }
- response = requests.post(API_URL, json=payload, headers=headers)
- print(f"响应状态码: {response.status_code}")
- if response.status_code == 200:
- result = response.json()["result"]
- # 提取 parsing_res_list
- for layout_result in result.get("layoutParsingResults", []):
- pruned_result = layout_result.get("prunedResult", {})
- parsing_res_list = pruned_result.get("parsing_res_list", [])
- if parsing_res_list:
- print("\n=== parsing_res_list ===")
- print(parsing_res_list)
- else:
- print(f"请求失败,状态码: {response.status_code}")
|