cli: add negative flag variants (--no/-no)

pull/19/head
Konstantin Baierer 4 years ago
parent 2929ba1ee3
commit 8cd4067fc5

@ -49,38 +49,38 @@ from sbb_newspapers_org_image.eynollah import eynollah
type=click.Path(exists=True, file_okay=False), type=click.Path(exists=True, file_okay=False),
) )
@click.option( @click.option(
"--enable_plotting", "--enable-plotting/--disable-plotting",
"-ep", "-ep/-noep",
is_flag=True, is_flag=True,
help="If set, will plot intermediary files and images", help="If set, will plot intermediary files and images",
) )
@click.option( @click.option(
"--allow_enhancement", "--allow-enhancement/--no-allow-enhancement",
"-ae", "-ae/-noae",
is_flag=True, is_flag=True,
help="if this parameter set to true, this tool would check that input image need resizing and enhancement or not. If so output of resized and enhanced image and corresponding layout data will be written in out directory", help="if this parameter set to true, this tool would check that input image need resizing and enhancement or not. If so output of resized and enhanced image and corresponding layout data will be written in out directory",
) )
@click.option( @click.option(
"--curved_line", "--curved-line/--no-curvedline",
"-cl", "-cl/-nocl",
is_flag=True, is_flag=True,
help="if this parameter set to true, this tool will try to return contoure of textlines instead of rectabgle bounding box of textline. This should be taken into account that with this option the tool need more time to do process.", help="if this parameter set to true, this tool will try to return contoure of textlines instead of rectabgle bounding box of textline. This should be taken into account that with this option the tool need more time to do process.",
) )
@click.option( @click.option(
"--full_layout", "--full-layout/--no-full-layout",
"-fl", "-fl/-nofl",
is_flag=True, is_flag=True,
help="if this parameter set to true, this tool will try to return all elements of layout.", help="if this parameter set to true, this tool will try to return all elements of layout.",
) )
@click.option( @click.option(
"--allow_scaling", "--allow_scaling/--no-allow-scaling",
"-as", "-as/-noas",
is_flag=True, is_flag=True,
help="if this parameter set to true, this tool would check the scale and if needed it will scale it to perform better layout detection", help="if this parameter set to true, this tool would check the scale and if needed it will scale it to perform better layout detection",
) )
@click.option( @click.option(
"--headers_off", "--headers-off/--headers-on",
"-ho", "-ho/-noho",
is_flag=True, is_flag=True,
help="if this parameter set to true, this tool would ignore headers role in reading order", help="if this parameter set to true, this tool would ignore headers role in reading order",
) )

@ -176,6 +176,7 @@ class eynollah:
self.model_textline_dir = dir_models + "/model_textline_newspapers.h5" #'/model_hor_ver_home_trextline_very_good.h5'# '/model_hor_ver_1_great.h5'#'/model_curved_office_works_great.h5' self.model_textline_dir = dir_models + "/model_textline_newspapers.h5" #'/model_hor_ver_home_trextline_very_good.h5'# '/model_hor_ver_1_great.h5'#'/model_curved_office_works_great.h5'
def predict_enhancement(self, img): def predict_enhancement(self, img):
self.logger.debug("enter predict_enhancement")
model_enhancement, session_enhancemnet = self.start_new_session_and_model(self.model_dir_of_enhancemnet) model_enhancement, session_enhancemnet = self.start_new_session_and_model(self.model_dir_of_enhancemnet)
img_height_model = model_enhancement.layers[len(model_enhancement.layers) - 1].output_shape[1] img_height_model = model_enhancement.layers[len(model_enhancement.layers) - 1].output_shape[1]
@ -279,6 +280,7 @@ class eynollah:
return int(float(dpi)) return int(float(dpi))
def calculate_width_height_by_columns(self, img, num_col, width_early, label_p_pred): def calculate_width_height_by_columns(self, img, num_col, width_early, label_p_pred):
self.logger.debug("enter calculate_width_height_by_columns")
if num_col == 1 and width_early < 1100: if num_col == 1 and width_early < 1100:
img_w_new = 2000 img_w_new = 2000
img_h_new = int(img.shape[0] / float(img.shape[1]) * 2000) img_h_new = int(img.shape[0] / float(img.shape[1]) * 2000)
@ -341,6 +343,7 @@ class eynollah:
return img_new, num_column_is_classified return img_new, num_column_is_classified
def resize_image_with_column_classifier(self, is_image_enhanced): def resize_image_with_column_classifier(self, is_image_enhanced):
self.logger.debug("enter resize_image_with_column_classifier")
img = cv2.imread(self.image_filename) img = cv2.imread(self.image_filename)
img = img.astype(np.uint8) img = img.astype(np.uint8)
@ -444,6 +447,7 @@ class eynollah:
return is_image_enhanced, img, image_res, num_col, num_column_is_classified return is_image_enhanced, img, image_res, num_col, num_column_is_classified
def get_image_and_scales(self, img_org, img_res, scale): def get_image_and_scales(self, img_org, img_res, scale):
self.logger.debug("enter get_image_and_scales")
self.image = np.copy(img_res) self.image = np.copy(img_res)
self.image_org = np.copy(img_org) self.image_org = np.copy(img_org)
self.height_org = self.image.shape[0] self.height_org = self.image.shape[0]
@ -462,11 +466,10 @@ class eynollah:
#self.plotter.scale_y = self.scale_y #self.plotter.scale_y = self.scale_y
#self.plotter.scale_x = self.scale_x #self.plotter.scale_x = self.scale_x
def get_image_and_scales_after_enhancing(self, img_org, img_res): def get_image_and_scales_after_enhancing(self, img_org, img_res):
self.logger.debug("enter get_image_and_scales_after_enhancing")
self.image = np.copy(img_res) self.image = np.copy(img_res)
self.image = self.image.astype(np.uint8) self.image = self.image.astype(np.uint8)
self.image_org = np.copy(img_org) self.image_org = np.copy(img_org)

Loading…
Cancel
Save