mirror of
https://github.com/qurator-spk/sbb_binarization.git
synced 2025-06-08 03:40:14 +02:00
rewrite "normal" CLI with click
This commit is contained in:
parent
645ec4124a
commit
fad7b7aff1
1 changed files with 9 additions and 16 deletions
|
@ -2,22 +2,15 @@
|
||||||
sbb_binarize CLI
|
sbb_binarize CLI
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from click import command, option, argument, version_option
|
||||||
|
|
||||||
from .sbb_binarize import SbbBinarizer
|
from .sbb_binarize import SbbBinarizer
|
||||||
|
|
||||||
def main():
|
@command()
|
||||||
parser = ArgumentParser()
|
@version_option()
|
||||||
|
@option('--patches/--no-patches', default=True, help='by enabling this parameter you let the model to see the image in patches.')
|
||||||
parser.add_argument('-i', '--image', default=None, help='image.')
|
@option('--model-dir', '-m', required=True, help='directory containing models for prediction')
|
||||||
parser.add_argument('-p', '--patches', default=False, help='by setting this parameter to true you let the model to see the image in patches.')
|
@argument('input_image')
|
||||||
parser.add_argument('-s', '--save', default=False, help='save prediction with a given name here. The name and format should be given (outputname.tif).')
|
@argument('output_image')
|
||||||
parser.add_argument('-m', '--model', default=None, help='models directory.')
|
def main(patches, model_dir, input_image, output_image):
|
||||||
|
SbbBinarizer(model_dir).run(image_path=input_image, use_patches=patches, save=output_image)
|
||||||
options = parser.parse_args()
|
|
||||||
|
|
||||||
binarizer = SbbBinarizer(model_dir=options.model)
|
|
||||||
binarizer.run(image_path=options.image, patches=options.patches, save=options.save)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue