Skip to content

Commit

Permalink
Correctly set default transformation in untagged recognition
Browse files Browse the repository at this point in the history
Crashed before when line type was not ('type', 'default')
  • Loading branch information
mittagessen committed Jul 3, 2024
1 parent 491e95a commit aaf2b7a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions kraken/rpred.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ def __init__(self,
valid_norm = True
self.next_iter = self._recognize_box_line

if isinstance(nets, defaultdict) and nets.default_factory:
network = nets.default_factory()
batch, channels, height, width = network.nn.input
self.ts = defaultdict(lambda: ImageInputTransforms(batch, height, width, channels, (pad, 0), valid_norm))
else:
self.ts = {}

if self.have_tags:
tags = set()
for x in bounds.lines:
Expand Down Expand Up @@ -148,11 +155,8 @@ def __init__(self,
network = nets[tag]
batch, channels, height, width = network.nn.input
self.ts[tag] = ImageInputTransforms(batch, height, width, channels, (pad, 0), valid_norm)
elif isinstance(nets, defaultdict) and nets.default_factory:
network = nets.default_factory()
batch, channels, height, width = network.nn.input
self.ts = {('type', 'default'): ImageInputTransforms(batch, height, width, channels, (pad, 0), valid_norm)}
else:

if not isinstance(self.ts, defaultdict) and not self.ts:
raise ValueError('No tags in input data and no default model in mapping given.')

self.im = im
Expand Down

0 comments on commit aaf2b7a

Please sign in to comment.