변수명 재정의
This commit is contained in:
12
test/test.py
12
test/test.py
@@ -228,10 +228,10 @@ def process_pdf(llm, sampling_params, pdf_path):
|
|||||||
contents += content + page_num_separator
|
contents += content + page_num_separator
|
||||||
|
|
||||||
# Save results
|
# Save results
|
||||||
json_path = os.path.join(
|
result_json_path = os.path.join(
|
||||||
f"{config.OUTPUT_PATH}/result", f"{file_name_without_ext}.json"
|
f"{config.OUTPUT_PATH}/result", f"{file_name_without_ext}.json"
|
||||||
)
|
)
|
||||||
pdf_out_path = os.path.join(
|
result_pdf_path = os.path.join(
|
||||||
config.OUTPUT_PATH, f"{file_name_without_ext}_layouts.pdf"
|
config.OUTPUT_PATH, f"{file_name_without_ext}_layouts.pdf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -247,10 +247,10 @@ def process_pdf(llm, sampling_params, pdf_path):
|
|||||||
"parsed": contents,
|
"parsed": contents,
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(json_path, "w", encoding="utf-8") as f:
|
with open(result_json_path, "w", encoding="utf-8") as f:
|
||||||
json.dump(output_data, f, ensure_ascii=False, indent=4)
|
json.dump(output_data, f, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
pil_to_pdf_img2pdf(draw_images, pdf_out_path)
|
pil_to_pdf_img2pdf(draw_images, result_pdf_path)
|
||||||
print(
|
print(
|
||||||
f"{Colors.GREEN}Finished processing {pdf_path}. Results saved in {config.OUTPUT_PATH}{Colors.RESET}"
|
f"{Colors.GREEN}Finished processing {pdf_path}. Results saved in {config.OUTPUT_PATH}{Colors.RESET}"
|
||||||
)
|
)
|
||||||
@@ -283,7 +283,7 @@ def process_image(llm, sampling_params, image_path):
|
|||||||
print(result_out)
|
print(result_out)
|
||||||
|
|
||||||
# Save results
|
# Save results
|
||||||
output_json_path = os.path.join(
|
result_json_path = os.path.join(
|
||||||
f"{config.OUTPUT_PATH}/result", f"{file_name_without_ext}.json"
|
f"{config.OUTPUT_PATH}/result", f"{file_name_without_ext}.json"
|
||||||
)
|
)
|
||||||
result_image_path = os.path.join(
|
result_image_path = os.path.join(
|
||||||
@@ -316,7 +316,7 @@ def process_image(llm, sampling_params, image_path):
|
|||||||
"parsed": processed_text,
|
"parsed": processed_text,
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(output_json_path, "w", encoding="utf-8") as f:
|
with open(result_json_path, "w", encoding="utf-8") as f:
|
||||||
json.dump(output_data, f, ensure_ascii=False, indent=4)
|
json.dump(output_data, f, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
result_image.save(result_image_path)
|
result_image.save(result_image_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user