chore: parse args in scripts, add colors for drawing lines
This commit is contained in:
parent
102617fe2f
commit
1d3b077ace
@ -6,13 +6,24 @@ from cv_analysis.utils.annotate import annotate_pdf
|
|||||||
|
|
||||||
pipe = make_image_analysis_pipeline(infer_lines)
|
pipe = make_image_analysis_pipeline(infer_lines)
|
||||||
|
|
||||||
# FIXME: Implement argparsing
|
|
||||||
|
|
||||||
pdf_bytes = open("test/test_data/article.pdf", "rb").read()
|
def parse_args():
|
||||||
vlp_output = json.load(open("test/test_data/article.json", "r"))
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("pdf", type=str, help="Path to the PDF file")
|
||||||
|
parser.add_argument("vlp_output", type=str, help="Path to the VLP output JSON file")
|
||||||
|
parser.add_argument("--output", type=str, help="Path to the output PDF file", default="/tmp/output.pdf")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
|
pdf_bytes = open(args.pdf, "rb").read()
|
||||||
|
vlp_output = json.load(open(args.vlp_output, "r"))
|
||||||
|
|
||||||
best_result = list(pipe(data={"pdf": pdf_bytes, "vlp_output": vlp_output}))
|
best_result = list(pipe(data={"pdf": pdf_bytes, "vlp_output": vlp_output}))
|
||||||
|
|
||||||
# print(best_result)
|
# print(best_result)
|
||||||
|
|
||||||
annotate_pdf(pdf_bytes, best_result, output_path = "/tmp/deine-mutter.pdf")
|
annotate_pdf(pdf_bytes, best_result, output_path=args.output)
|
||||||
|
|||||||
@ -32,7 +32,7 @@ def annotate_page(page: fitz.Page, prediction):
|
|||||||
for line in prediction["tableLines"]:
|
for line in prediction["tableLines"]:
|
||||||
start = itemgetter("x1", "y1")(line)
|
start = itemgetter("x1", "y1")(line)
|
||||||
end = itemgetter("x2", "y2")(line)
|
end = itemgetter("x2", "y2")(line)
|
||||||
page.draw_line(start, end)
|
page.draw_line(start, end, color=(1, 0, 0.5), width=1)
|
||||||
return page
|
return page
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user