From 561a6f8a904fac0c3444dacf480dc24cf562917a Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Thu, 10 Oct 2019 16:40:48 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=20sbb=5Ftextline=5Fdetector:=20Use=20?= =?UTF-8?q?click=20instead=20of=20argparse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qurator/sbb_textline_detector/main.py | 20 ++++++++------------ requirements.txt | 1 + 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/qurator/sbb_textline_detector/main.py b/qurator/sbb_textline_detector/main.py index b09d665..c7d47e2 100644 --- a/qurator/sbb_textline_detector/main.py +++ b/qurator/sbb_textline_detector/main.py @@ -23,7 +23,7 @@ from scipy.signal import find_peaks from scipy.ndimage import gaussian_filter1d import xml.etree.ElementTree as ET import warnings -import argparse +import click with warnings.catch_warnings(): warnings.simplefilter("ignore") @@ -1314,18 +1314,14 @@ class textlineerkenner: self.write_into_page_xml(contours, page_coord, self.dir_out) -def main(): - parser = argparse.ArgumentParser() - - parser.add_argument('-i', '--image', dest='inp1', default=None, help='image filename.') - parser.add_argument('-o', '--out', dest='inp2', default=None, help='directory to write output xml data.') - parser.add_argument('-m', '--model', dest='inp3', default=None, help='directory of models.') - - options = parser.parse_args() - - possibles = globals() +@click.command() +@click.option('--image', '-i', help='image filename', type=click.Path(exists=True, dir_okay=False)) +@click.option('--out', '-o', help='directory to write output xml data', type=click.Path(exists=True, file_okay=False)) +@click.option('--model', '-m', help='directory of models', type=click.Path(exists=True, file_okay=False)) +def main(image, out, model): + possibles = globals() # XXX unused? possibles.update(locals()) - x = textlineerkenner(options.inp1, options.inp2, options.inp3) + x = textlineerkenner(image, out, model) x.run() diff --git a/requirements.txt b/requirements.txt index 4b9bf38..58d61f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ shapely scikit-learn tensorflow-gpu < 2.0 scipy +click