Skip to content

Commit

Permalink
legacy segmenter regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
mittagessen committed Jul 29, 2024
1 parent 514e11f commit b96d0cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 4 additions & 4 deletions kraken/kraken.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,12 @@ def segment(ctx, model, boxes, text_direction, scale, maxcolseps,


from kraken.lib.vgsl import TorchVGSLModel
models = []
model = []
for loc in locations:
message(f'Loading ANN {loc}\t', nl=False)
try:
models.append(TorchVGSLModel.load_model(loc))
models[-1].to(ctx.meta['device'])
model.append(TorchVGSLModel.load_model(loc))
model[-1].to(ctx.meta['device'])
except Exception:
if ctx.meta['raise_failed']:
raise
Expand All @@ -555,7 +555,7 @@ def segment(ctx, model, boxes, text_direction, scale, maxcolseps,
'remove_hlines': remove_hlines,
'pad': pad}))

return partial(segmenter, boxes, models, text_direction, scale, maxcolseps,
return partial(segmenter, boxes, model, text_direction, scale, maxcolseps,
black_colseps, remove_hlines, pad, mask, ctx.meta['device'])


Expand Down
8 changes: 0 additions & 8 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,3 @@ def test_segment_color(self):
with tempfile.NamedTemporaryFile() as fp:
result = self.runner.invoke(cli, ['-r', '-i', self.color_img, fp.name, 'segment'])
self.assertEqual(result.exit_code, 1)

def test_segment_color_noraise(self):
"""
Tests that segmentation does not return 1 when given color image in noraise mode.
"""
with tempfile.NamedTemporaryFile() as fp:
result = self.runner.invoke(cli, ['-i', self.color_img, fp.name, 'segment'])
self.assertEqual(result.exit_code, 0)

0 comments on commit b96d0cd

Please sign in to comment.