remove "patches" parameter, always use_patches

pull/5/head
Konstantin Baierer 4 years ago
parent 2bc6ccc4c0
commit 6543e74deb

@ -16,11 +16,6 @@
"default": "page", "default": "page",
"description": "PAGE XML hierarchy level to operate on" "description": "PAGE XML hierarchy level to operate on"
}, },
"patches": {
"description": "by setting this parameter to true you let the model to see the image in patches.",
"type": "boolean",
"default": true
},
"model": { "model": {
"description": "models directory.", "description": "models directory.",
"type": "string", "type": "string",

@ -48,7 +48,6 @@ class SbbBinarizeProcessor(Processor):
assert_file_grp_cardinality(self.output_file_grp, 1) assert_file_grp_cardinality(self.output_file_grp, 1)
oplevel = self.parameter['operation_level'] oplevel = self.parameter['operation_level']
use_patches = self.parameter['patches'] # pylint: disable=attribute-defined-outside-init
model_path = self.parameter['model'] # pylint: disable=attribute-defined-outside-init model_path = self.parameter['model'] # pylint: disable=attribute-defined-outside-init
binarizer = SbbBinarizer(model_dir=model_path) binarizer = SbbBinarizer(model_dir=model_path)
@ -64,7 +63,7 @@ class SbbBinarizeProcessor(Processor):
if oplevel == 'page': if oplevel == 'page':
LOG.info("Binarizing on 'page' level in page '%s'", page_id) LOG.info("Binarizing on 'page' level in page '%s'", page_id)
page_image, page_xywh, _ = self.workspace.image_from_page(page, page_id, feature_filter='binarized') page_image, page_xywh, _ = self.workspace.image_from_page(page, page_id, feature_filter='binarized')
bin_image = cv2pil(binarizer.run(image=pil2cv(page_image), use_patches=use_patches)) bin_image = cv2pil(binarizer.run(image=pil2cv(page_image), use_patches=True))
# update METS (add the image file): # update METS (add the image file):
bin_image_path = self.workspace.save_image_file(bin_image, bin_image_path = self.workspace.save_image_file(bin_image,
file_id + '.IMG-BIN', file_id + '.IMG-BIN',
@ -78,7 +77,7 @@ class SbbBinarizeProcessor(Processor):
LOG.warning("Page '%s' contains no text/table regions", page_id) LOG.warning("Page '%s' contains no text/table regions", page_id)
for region in regions: for region in regions:
region_image, region_xywh = self.workspace.image_from_segment(region, page_image, page_xywh, feature_filter='binarized') region_image, region_xywh = self.workspace.image_from_segment(region, page_image, page_xywh, feature_filter='binarized')
region_image_bin = cv2pil(binarizer.run(image=pil2cv(region_image), use_patches=use_patches)) region_image_bin = cv2pil(binarizer.run(image=pil2cv(region_image), use_patches=True))
region_image_bin_path = self.workspace.save_image_file( region_image_bin_path = self.workspace.save_image_file(
region_image_bin, region_image_bin,
"%s_%s.IMG-BIN" % (file_id, region.id), "%s_%s.IMG-BIN" % (file_id, region.id),
@ -93,7 +92,7 @@ class SbbBinarizeProcessor(Processor):
LOG.warning("Page '%s' contains no text lines", page_id) LOG.warning("Page '%s' contains no text lines", page_id)
for region_id, line in region_line_tuples: for region_id, line in region_line_tuples:
line_image, line_xywh = self.workspace.image_from_segment(line, page_image, page_xywh, feature_filter='binarized') line_image, line_xywh = self.workspace.image_from_segment(line, page_image, page_xywh, feature_filter='binarized')
line_image_bin = cv2pil(binarizer.run(image=pil2cv(line_image), use_patches=use_patches)) line_image_bin = cv2pil(binarizer.run(image=pil2cv(line_image), use_patches=True))
line_image_bin_path = self.workspace.save_image_file( line_image_bin_path = self.workspace.save_image_file(
line_image_bin, line_image_bin,
"%s_%s_%s.IMG-BIN" % (file_id, region_id, line.id), "%s_%s_%s.IMG-BIN" % (file_id, region_id, line.id),

Loading…
Cancel
Save