mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-06-16 09:59:13 +02:00
Eynollah_ocr: drop fixed input sizes…
- tr-ocr: no need to resize images in advance (done by model, anyway) - cnn-rnn-ocr: get model size from model's input shape
This commit is contained in:
parent
24c7d4c277
commit
348ac95ad3
1 changed files with 6 additions and 19 deletions
|
|
@ -87,7 +87,6 @@ class Eynollah_ocr(Eynollah):
|
|||
img: MatLike,
|
||||
page_tree: ET.ElementTree,
|
||||
page_ns,
|
||||
tr_ocr_input_height_and_width,
|
||||
) -> EynollahOcrResult:
|
||||
|
||||
total_bb_coordinates = []
|
||||
|
|
@ -117,20 +116,14 @@ class Eynollah_ocr(Eynollah):
|
|||
img_crop[mask_poly == 0] = 255 # FIXME: or median color?
|
||||
|
||||
if h > 0.1 * w:
|
||||
cropped_lines.append(resize_image(img_crop,
|
||||
tr_ocr_input_height_and_width,
|
||||
tr_ocr_input_height_and_width) )
|
||||
cropped_lines.append(img_crop)
|
||||
cropped_lines_meging_indexing.append(0)
|
||||
else:
|
||||
splited_images, _ = return_textlines_split_if_needed(img_crop, None)
|
||||
if splited_images:
|
||||
cropped_lines.append(resize_image(splited_images[0],
|
||||
tr_ocr_input_height_and_width,
|
||||
tr_ocr_input_height_and_width))
|
||||
cropped_lines.append(splited_images[0])
|
||||
cropped_lines.append(splited_images[1])
|
||||
cropped_lines_meging_indexing.append(1)
|
||||
cropped_lines.append(resize_image(splited_images[1],
|
||||
tr_ocr_input_height_and_width,
|
||||
tr_ocr_input_height_and_width))
|
||||
cropped_lines_meging_indexing.append(-1)
|
||||
else:
|
||||
cropped_lines.append(img_crop)
|
||||
|
|
@ -172,9 +165,8 @@ class Eynollah_ocr(Eynollah):
|
|||
img_bin: Optional[MatLike],
|
||||
page_tree: ET.ElementTree,
|
||||
page_ns,
|
||||
image_width,
|
||||
image_height,
|
||||
) -> EynollahOcrResult:
|
||||
_, image_height, image_width, _ = self.model_zoo.get('ocr').input_shape
|
||||
|
||||
total_bb_coordinates = []
|
||||
cropped_lines_rgb = []
|
||||
|
|
@ -482,18 +474,13 @@ class Eynollah_ocr(Eynollah):
|
|||
img=img,
|
||||
page_tree=page_tree,
|
||||
page_ns=page_ns,
|
||||
|
||||
tr_ocr_input_height_and_width = 384
|
||||
)
|
||||
else:
|
||||
result = self.run_cnn(
|
||||
img=img,
|
||||
page_tree=page_tree,
|
||||
page_ns=page_ns,
|
||||
|
||||
img_bin=img_bin,
|
||||
image_width=512,
|
||||
image_height=32,
|
||||
)
|
||||
|
||||
self.write_ocr(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue