mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-07-01 06:59:54 +02:00
Merge 32889ef1e0
into 9b4e78c55c
This commit is contained in:
commit
ba8a53a1c0
2 changed files with 13 additions and 16 deletions
|
@ -48,8 +48,7 @@ def machine_based_reading_order(dir_xml, dir_out_modal_image, dir_out_classes, i
|
|||
@main.command()
|
||||
@click.option('--patches/--no-patches', default=True, help='by enabling this parameter you let the model to see the image in patches.')
|
||||
@click.option('--model_dir', '-m', type=click.Path(exists=True, file_okay=False), required=True, help='directory containing models for prediction')
|
||||
@click.argument('input_image', required=False)
|
||||
@click.argument('output_image', required=False)
|
||||
@click.option("--input-image", "-i", help="input image", type=click.Path(exists=True, dir_okay=False))
|
||||
@click.option(
|
||||
"--dir_in",
|
||||
"-di",
|
||||
|
@ -57,16 +56,14 @@ def machine_based_reading_order(dir_xml, dir_out_modal_image, dir_out_classes, i
|
|||
type=click.Path(exists=True, file_okay=False),
|
||||
)
|
||||
@click.option(
|
||||
"--dir_out",
|
||||
"-do",
|
||||
help="directory for output images",
|
||||
type=click.Path(exists=True, file_okay=False),
|
||||
"--output",
|
||||
"-o",
|
||||
help="output image (if using -i) or output image directory (if using -di)",
|
||||
type=click.Path(file_okay=True, dir_okay=True),
|
||||
)
|
||||
def binarization(patches, model_dir, input_image, output_image, dir_in, dir_out):
|
||||
assert (dir_out is None) == (dir_in is None), "Options -di and -do are mutually dependent"
|
||||
assert (input_image is None) == (output_image is None), "INPUT_IMAGE and OUTPUT_IMAGE are mutually dependent"
|
||||
assert (dir_in is None) != (input_image is None), "Specify either -di and -do options, or INPUT_IMAGE and OUTPUT_IMAGE"
|
||||
SbbBinarizer(model_dir).run(image_path=input_image, use_patches=patches, save=output_image, dir_in=dir_in, dir_out=dir_out)
|
||||
def binarization(patches, model_dir, input_image, dir_in, output):
|
||||
assert (dir_in is None) != (input_image is None), "Specify either -di and or -i not both"
|
||||
SbbBinarizer(model_dir).run(image_path=input_image, use_patches=patches, output=output, dir_in=dir_in)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -314,8 +314,8 @@ class SbbBinarizer:
|
|||
prediction_true = prediction_true.astype(np.uint8)
|
||||
return prediction_true[:,:,0]
|
||||
|
||||
def run(self, image=None, image_path=None, save=None, use_patches=False, dir_in=None, dir_out=None):
|
||||
print(dir_in,'dir_in')
|
||||
def run(self, image=None, image_path=None, output=None, use_patches=False, dir_in=None):
|
||||
# print(dir_in,'dir_in')
|
||||
if not dir_in:
|
||||
if (image is not None and image_path is not None) or \
|
||||
(image is None and image_path is None):
|
||||
|
@ -343,8 +343,8 @@ class SbbBinarizer:
|
|||
kernel = np.ones((5, 5), np.uint8)
|
||||
img_last[:, :][img_last[:, :] > 0] = 255
|
||||
img_last = (img_last[:, :] == 0) * 255
|
||||
if save:
|
||||
cv2.imwrite(save, img_last)
|
||||
if output:
|
||||
cv2.imwrite(output, img_last)
|
||||
return img_last
|
||||
else:
|
||||
ls_imgs = os.listdir(dir_in)
|
||||
|
@ -374,4 +374,4 @@ class SbbBinarizer:
|
|||
img_last[:, :][img_last[:, :] > 0] = 255
|
||||
img_last = (img_last[:, :] == 0) * 255
|
||||
|
||||
cv2.imwrite(os.path.join(dir_out,image_stem+'.png'), img_last)
|
||||
cv2.imwrite(os.path.join(output, image_stem + '.png'), img_last)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue