Conflicts: cv_analysis/figure_detection.py cv_analysis/layout_parsing.py cv_analysis/table_parsing.py scripts/annotate.py
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
import argparse
|
|
|
|
from cv_analysis.table_parsing import annotate_tables_in_pdf
|
|
from cv_analysis.redaction_detection import annotate_redactions_in_pdf
|
|
from cv_analysis.layout_parsing import annotate_layout_in_pdf
|
|
from cv_analysis.figure_detection import detect_figures_in_pdf
|
|
from cv_analysis.fig_detection_with_layout import detect_figures_with_layout_parsing
|
|
|
|
|
|
def parse_args():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("pdf_path")
|
|
parser.add_argument("page_index", type=int)
|
|
parser.add_argument("--type", choices=["table", "redaction", "layout", "figure", "figure2"])
|
|
parser.add_argument("--show", action="store_true", default=False)
|
|
|
|
args = parser.parse_args()
|
|
|
|
return args
|
|
|
|
|
|
if __name__ == "__main__":
|
|
args = parse_args()
|
|
if args.type == "table":
|
|
annotate_tables_in_pdf(args.pdf_path, page_index=args.page_index, show=args.show)
|
|
elif args.type == "redaction":
|
|
annotate_redactions_in_pdf(args.pdf_path, page_index=args.page_index, show=args.show)
|
|
elif args.type == "layout":
|
|
annotate_layout_in_pdf(args.pdf_path, page_index=args.page_index, show=args.show)
|
|
elif args.type == "figure":
|
|
detect_figures_in_pdf(args.pdf_path, page_index=args.page_index, show=args.show)
|
|
elif args.type == "figure2":
|
|
detect_figures_with_layout_parsing(args.pdf_path, page_index=args.page_index, show=args.show)
|